migrations icon indicating copy to clipboard operation
migrations copied to clipboard

Migrations schema dump result SQL has incorrect order

Open Bart-Westenenk opened this issue 7 months ago • 0 comments

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 create
  • php bin/console doctrine:database:update --force
  • php bin/console doctrine:migrations:schema-dump
  • php bin/console doctrine:database:drop --force
  • php bin/console doctrine:database:create
  • php 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.

Bart-Westenenk avatar Mar 04 '25 17:03 Bart-Westenenk