mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Incorrect order of alters in doctrine:schema:update --force #6118
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @4n70w4 on GitHub (Dec 5, 2018).
Bug Report
Summary
I changed the yml files for my 2 entityes. I understand now alters occur in alphabetical order?
Current behavior
Then executed:
php bin/console doctrine:generate:entities MyBundle --no-backupThen try to update db schema:
php bin/console doctrine:schema:update --forceBut I get an error:
Because column id in table user need create before create relation from bonus to user.
How to reproduce
Initial only User entity:
php bin/console doctrine:generate:entities MyBundle --no-backupphp bin/console doctrine:schema:update --forceIn next version add Bonus entity and change User entity:
php bin/console doctrine:generate:entities MyBundle --no-backupphp bin/console doctrine:schema:update --forceExpected behavior
I expect the execution of alters in the correct order.
@4n70w4 commented on GitHub (Dec 5, 2018):
Also in this case command generate incorrect alter for user.id:
ALTER TABLE user ADD id INT AUTO_INCREMENT NOT NULL;And got error:
Error Code: 1075. Incorrect table definition; there can be only one auto column and it must be defined as a keyCorrect alter like this:
ALTER TABLE user ADD id INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id);@Ocramius commented on GitHub (Dec 5, 2018):
@4n70w4 can you please bump the dependencies and try again? Just need to make sure latest stable is affected as well.
@4n70w4 commented on GitHub (Dec 5, 2018):
Ok, updated to:
Problem with
Error Code: 1075. Incorrect table definition; there can be only one auto column and it must be defined as a keysolved.But case from topic not solved.
php bin/console doctrine:schema:update --force --dump-sqlThe following SQL statements will be executed:
Alter with constraint before alter with foreign field.