DDC-454: Failure in Schema Diff ForeignKey handling when several tables are added #564

Open
opened 2026-01-22 12:42:51 +01:00 by admin · 0 comments
Owner

Originally created by @doctrinebot on GitHub (Mar 21, 2010).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user @beberlei:

If you add several new tables and make a schema diff, these tables foreign key relations to each other are not sorted properly leading to possible errors:

benny@benny-pc:~/code/php/wsnetbeans/whitewashing$ doctrine orm:schema-tool --update --dump-sql
Doctrine Command Line Interface

CREATE TABLE blog*posts_tags (post_id INT NOT NULL, tag_id VARCHAR(255) NOT NULL, INDEX blog_posts_tags_tag_id_idx (tag_id), PRIMARY KEY(post_id, tag*id)) ENGINE = InnoDB;
ALTER TABLE blog*posts_tags ADD FOREIGN KEY (post_id) REFERENCES blog*posts(id);
ALTER TABLE blog*posts_tags ADD FOREIGN KEY (tag_id) REFERENCES blog*tags(id);
CREATE TABLE blog*tags (tag*name VARCHAR(255) NOT NULL, id VARCHAR(255) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB;
Originally created by @doctrinebot on GitHub (Mar 21, 2010). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user @beberlei: If you add several new tables and make a schema diff, these tables foreign key relations to each other are not sorted properly leading to possible errors: ``` benny@benny-pc:~/code/php/wsnetbeans/whitewashing$ doctrine orm:schema-tool --update --dump-sql Doctrine Command Line Interface CREATE TABLE blog*posts_tags (post_id INT NOT NULL, tag_id VARCHAR(255) NOT NULL, INDEX blog_posts_tags_tag_id_idx (tag_id), PRIMARY KEY(post_id, tag*id)) ENGINE = InnoDB; ALTER TABLE blog*posts_tags ADD FOREIGN KEY (post_id) REFERENCES blog*posts(id); ALTER TABLE blog*posts_tags ADD FOREIGN KEY (tag_id) REFERENCES blog*tags(id); CREATE TABLE blog*tags (tag*name VARCHAR(255) NOT NULL, id VARCHAR(255) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB; ```
admin added the Bug label 2026-01-22 12:42:51 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#564