migrations
migrations copied to clipboard
Migrations schema dump result SQL has incorrect order
Bug Report
| Q | A |
|---|---|
| BC Break | no |
| Version | 3.4.1 |
Summary
Foreign key constraints depend on both tables and columns existing. The schema dump command first creates the table, then adds the foreign keys while the foreign table does not exist yet.
Current behavior
doctrine:migrations:schema-dump dumps the schema table per table.
How to reproduce
Have a relatively simple schema with 2 entities that depend on eachother using associations (and thus foreign key constraints)
Run the following commands, and see that the last command fails:
php bin/console doctrine:database createphp bin/console doctrine:database:update --forcephp bin/console doctrine:migrations:schema-dumpphp bin/console doctrine:database:drop --forcephp bin/console doctrine:database:createphp bin/console doctrine:migrations:migrate -n
Expected behavior
I expect the last commad to complete and run the migration given by doctrine:migrations:schema-dump succesfully.