DBAL-812: SchemaTool ignores multi-columns (composite) indexes when creating a foreign key #2045

doctrinebot opened this Issue Feb 13, 2014 · 3 comments

2 participants


Jira issue originally created by user ekcolysp:

When using the schema tool to generate the differences between the db and the entities, I notice the following:

CREATE INDEX IDX_36D222EF603EE73 ON sales (vid);

Normally, it doesn't bother me, however I have had an existing composite index consists of (vid, submit). This leads to the redundant index IDX_36D222EF603EE73 and therefore forcing unnecessary overheads.

It would be nice to have a mean to disable this from happening.

The code in question can be found at https://github.com/doctrine/dbal/blob/594e326bd58d1d7af578f0dc3143655b9d119d45/lib/Doctrine/DBAL/Schema/Table.php#L543.

A helpful member from #doctrine IRC also pointed out that it does not check the unique constraints also.



Comment created by @ocramius:

Just a hint on this: looks like the current logic just checks hashed indexes, ignoring the "uniq" prefixed indexes to avoid duplicates.


Comment created by @deeky666:

[~ekcolysp] I get the point here. However after having a quick look into this it seems this behaviour exists for a good reason. See here: https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Schema/Index.php#L191-L195
The question is how could this reasonable extended to fulfil the needs you explained. I am not entirely sure about this and this peace of code is rather sensitive and critical. I don't want to rush any assumptions here.


Comment created by ekcolysp:

Hi Steve,

I fully understand your reservation.

Thanks for looking into things.


@deeky666 deeky666 was assigned by doctrinebot Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment