Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-812

SchemaTool ignores multi-columns (composite) indexes when creating a foreign key

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.4.2
    • Fix Version/s: None
    • Component/s: Schema Managers
    • Labels:
    • Environment:
      MySQL

      Description

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

      ALTER TABLE sales ADD CONSTRAINT FK_36D222EF603EE73 FOREIGN KEY (vid) REFERENCES vendor (id);
      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.

      Regards,

        Activity

          People

          • Assignee:
            Steve Müller
            Reporter:
            Peter Huynh
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated: