Skip to content

Loading…

DBAL-732: MySQL 5.6 - Cannot change column 'fkProjectId': used in a foreign key constraint #1958

Open
doctrinebot opened this Issue · 10 comments

2 participants

@doctrinebot

Jira issue originally created by user cmodijk:

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
{quote}
ALTER TABLE badges CHANGE fkProjectId fkProjectId INT NOT NULL
{quote}

Result in the following error
{quote}
Cannot change column 'fkProjectId': used in a foreign key constraint 'FK_1483A5E9F28AE4EA'
{quote}

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:

@doctrinebot

Comment created by @ocramius:

[~cmodijk] what versions of DBAL/ORM are affected by the bug?

@doctrinebot

Comment created by cmodijk:

Doctrine 2.3.4 / 2a37b00.

@doctrinebot

Comment created by @deeky666:

[~ocramius] 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.

@doctrinebot

Comment created by tmartin:

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

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.

@doctrinebot

Comment created by @deeky666:

[cmodijk] , [tmartin] 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.

@doctrinebot

Comment created by cmodijk:

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
@doctrinebot

Comment created by @deeky666:

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.

@doctrinebot

Comment created by xplorer:

I have the same issue

@doctrinebot

Comment created by maxmukhin:

The same issue in the project.

@doctrinebot doctrinebot added the Bug label
@deeky666 deeky666 was assigned by doctrinebot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.