2

I'm using postgresql in a Symfony2 proyect with Postgis configured in Mac (not sure if that last one makes any difference).

The problem is that validating my schema AFTER running

doctrine:schema:update --force

will result on this error:

[Mapping] OK - The mapping files are correct.

[Database] FAIL - The database schema is not in sync with the current mapping file.

When updating again, Doctrine will try to add everything again, failing of course.

Thanks for the help.

EDIT: result for app/console --ansi doctrine:schema:update --dump-sql

ALTER T

ABLE actions ADD id VARCHAR(255) NOT NULL;
ALTER TABLE actions ADD display VARCHAR(255) NOT NULL;
ALTER TABLE actions ADD description VARCHAR(255) DEFAULT NULL;
ALTER TABLE actions ADD PRIMARY KEY (id);

-- lots more tables.. 

ALTER TABLE subclassifications ADD PRIMARY KEY (id);
ALTER TABLE users ADD id INT NOT NULL;
ALTER TABLE users ADD company_id INT DEFAULT NULL;
ALTER TABLE users ADD profile_id INT DEFAULT NULL;
ALTER TABLE users ADD name VARCHAR(255) NOT NULL;
ALTER TABLE users ADD password VARCHAR(255) NOT NULL;
ALTER TABLE users ADD salt VARCHAR(255) NOT NULL;
ALTER TABLE users ADD email VARCHAR(255) NOT NULL;
ALTER TABLE users ADD state INT NOT NULL;
ALTER TABLE users ADD accessCode INT NOT NULL;
ALTER TABLE users ADD CONSTRAINT FK_1483A5E9979B1AD6 FOREIGN KEY (company_id) REFERENCES companies (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;
ALTER TABLE users ADD CONSTRAINT FK_1483A5E9CCFA12B8 FOREIGN KEY (profile_id) REFERENCES profiles (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE;
CREATE INDEX IDX_1483A5E9979B1AD6 ON users (company_id);
CREATE INDEX IDX_1483A5E9CCFA12B8 ON users (profile_id);
ALTER TABLE users ADD PRIMARY KEY (id);

The point here is that the same dump will work the first time, but when making any change, the dump should be only the incremental changes, not the complete database.

2
  • Also, can you please post the output of doctrine:schema:update --dump-sql? Commented Feb 25, 2014 at 14:28
  • @PedroCordeiro, added the sql dump generated by doctrine. Commented Feb 26, 2014 at 19:49

1 Answer 1

2

There are a few things that might be wrong here.

First one: which version of Doctrine are you using? Up until 2.3 I had the same thing. Updating to 2.4 fixed it.

Second one: Do you have columnDefinition anywhere in your mapping? If you have it, that's the problem. columnDefinition breaks portability. It also breaks Doctrine Migrations.

Sign up to request clarification or add additional context in comments.

3 Comments

I have Doctrine 2.4.2 (always up to date thanks to composer) and I didn't find any columnDefinition in my mapping files. Any other ideas?
please post the output of doctrine:schema:update --dump-sql
with sf 2.3 i confirm it was the culprit in my case: such cases would have to be altered in this way: columnDefinition: BOOLEAN DEFAULT 1 > options: { default: 1 } and for a datetime case like that (the type though has to be datetime, it will be applied as timestamp in the query): columnDefinition: timestamp DEFAULT CURRENT_TIMESTAMP > options: { default: CURRENT_TIMESTAMP }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.