Skip to content

Loading…

DBAL-464: MySQL fails when try to drop a primary index with Auto Increment #1663

Closed
doctrinebot opened this Issue · 8 comments

2 participants

@doctrinebot

Jira issue originally created by user darkelfe:

When an update of schema tries to drop a primary key with "auto increment" property (example : @ORM\GeneratedValue(strategy="AUTO")), the execution will fail : it say :
[Doctrine\DBAL\DBALException]

An exception occurred while executing 'ALTER TABLE odesadicola DROP PRIMARY KEY':

SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key

Apparently, this error occurs because Doctrine try to execute a "drop primary key" on a table and the resulting column of old primary key will be "auto increment".

The answer is to remove "auto increment" attribut of primary key column juste before try to drop the primary key itself.

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot

Comment created by andig:

I'm still seeing this problem in 2.5.1 on mysql. Any advice?

@doctrinebot

Comment created by @deeky666:

It has been fixed and the test case here is also passing: https://github.com/doctrine/dbal/blob/master/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php#L121-L145

Please provide more context and information to make the error reproducable. Thanks.

@doctrinebot

Comment created by andig:

Only a partial fix, see andig@bd07dce

@doctrinebot

Comment created by andig:

Sorry, I've meant #786

@doctrinebot

Comment created by @doctrinebot:

A related Github Pull-Request [GH-786] was assigned:
#786

@doctrinebot

Comment created by @doctrinebot:

A related Github Pull-Request [GH-786] was merged:
#786

@doctrinebot doctrinebot added the Bug label
@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.5 milestone
@doctrinebot doctrinebot closed this
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.