[DBAL-205] MySQL SchemaManager doesn't handle composite foreign keys properly Created: 19/Jan/12  Updated: 21/Jan/12  Resolved: 21/Jan/12

Status: Resolved
Project: Doctrine DBAL
Component/s: Schema Managers
Affects Version/s: 2.1.5
Fix Version/s: 2.1.6, 2.2
Security Level: All

Type: Bug Priority: Major
Reporter: Sascha Beining Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


The MySQL SchemaManager can not properly generate a Schema from the database if a table has a foreign key that spans multiple columns.
Therefore the comparator tries to drop the one index as individual indexes.

That leads to an error if the resulting SQL is executed because these indexes do not exist (i.e. via app/console doctrine:schema:update --force)

symfony2#app/console doctrine:schema:update --dump-sql
DROP INDEX IDX_C1B1712387FE7372 ON table1;
DROP INDEX IDX_C1B1712364DE5A5 ON table1;
DROP INDEX IDX_C1B17123511B8B3E ON table1;
ALTER TABLE table1 ADD CONSTRAINT FK_C1B1712387FE737264DE5A5511B8B3E FOREIGN KEY (column1, column2, column3) REFERENCES table2(column1, column2, column3);

Generated at Thu Sep 03 13:23:09 EDT 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.