Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-732

MySQL 5.6 - Cannot change column 'fkProjectId': used in a foreign key constraint

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.3.4
    • Fix Version/s: None
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      I'm using doctrine migrations to change a null field to a not null field. MySQL 5.6 is strict on altering tables with foreign key constraint's.

      Generated SQL

      ALTER TABLE badges CHANGE fkProjectId fkProjectId INT NOT NULL

      Result in the following error

      Cannot change column 'fkProjectId': used in a foreign key constraint 'FK_1483A5E9F28AE4EA'

      More info:

      As of 5.6.7, the server prohibits changes to foreign key columns with the potential to cause loss of referential integrity. A workaround is to use ALTER TABLE ... DROP FOREIGN KEY before changing the column definition and ALTER TABLE ... ADD FOREIGN KEY afterward.

      Original issue:

        Issue Links

          Activity

          Hide
          Marco Pivetta added a comment -

          Cliff Odijk what versions of DBAL/ORM are affected by the bug?

          Show
          Marco Pivetta added a comment - Cliff Odijk what versions of DBAL/ORM are affected by the bug?
          Hide
          Cliff Odijk added a comment -

          Doctrine 2.3.4 / 2a37b007dda8e21bdbb8fa445be8fa0064199e13.

          Show
          Cliff Odijk added a comment - Doctrine 2.3.4 / 2a37b007dda8e21bdbb8fa445be8fa0064199e13.
          Hide
          Steve Müller added a comment -

          Marco Pivetta I wonder whether we should introduce MySqlPlatform567 to fix this which adds this behaviour. We could also fix this is MySqlPlatform directly but I don't know if this impacts performance for older versions of MySQL that don't require this behaviour.

          Show
          Steve Müller added a comment - Marco Pivetta I wonder whether we should introduce MySqlPlatform567 to fix this which adds this behaviour. We could also fix this is MySqlPlatform directly but I don't know if this impacts performance for older versions of MySQL that don't require this behaviour.
          Hide
          Timothée Martin added a comment -

          I encounter the same issue with doctrine/dbal 2.4.2 (commit fec965d330c958e175c39e61c3f6751955af32d0).

          Have you any idea of when this bug will be fixed? Or may be can you guide me on how to fix it and I could make a PR on doctrine/dbal.

          Thanks.

          Show
          Timothée Martin added a comment - I encounter the same issue with doctrine/dbal 2.4.2 (commit fec965d330c958e175c39e61c3f6751955af32d0). Have you any idea of when this bug will be fixed? Or may be can you guide me on how to fix it and I could make a PR on doctrine/dbal. Thanks.
          Hide
          Steve Müller added a comment -

          Cliff Odijk , Timothée Martin I will work on this issue as soon as I have time. Expect a fix for this in the upcoming weeks. Thank you for your patience.

          Show
          Steve Müller added a comment - Cliff Odijk , Timothée Martin I will work on this issue as soon as I have time. Expect a fix for this in the upcoming weeks. Thank you for your patience.
          Hide
          Cliff Odijk added a comment -

          The same error occurs with MariaDB version 10.0.7

          • InnoDB version 5.6.10
          • doctrine/orm version v2.4.1
          • doctrine/dbal version v2.4.2
          Show
          Cliff Odijk added a comment - The same error occurs with MariaDB version 10.0.7 InnoDB version 5.6.10 doctrine/orm version v2.4.1 doctrine/dbal version v2.4.2
          Hide
          Steve Müller added a comment -

          I already started work on this but didn't have time to finish it, yet. I will try to find some time for this this evening.

          Show
          Steve Müller added a comment - I already started work on this but didn't have time to finish it, yet. I will try to find some time for this this evening.

            People

            • Assignee:
              Steve Müller
              Reporter:
              Cliff Odijk
            • Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: