Uploaded image for project: 'Doctrine DBAL'
  1. Doctrine DBAL
  2. DBAL-464

MySQL fails when try to drop a primary index with Auto Increment


    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.2
    • Fix Version/s: 2.5
    • Component/s: None
    • Security Level: All
    • Labels:
    • Environment:
      Linux (ubuntu), PHP 5.3.10, MySQL 5.5.29, Symfony2


      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 :
      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.

        Issue Links


          darkelfe Julien Rosset created issue -
          beberlei Benjamin Eberlei made changes -
          Field Original Value New Value
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 2.5 [ 10523 ]
          Resolution Fixed [ 1 ]
          deeky666 Steve Müller made changes -
          Link This issue is referenced by DBAL-1132 [ DBAL-1132 ]


            • Assignee:
              beberlei Benjamin Eberlei
              darkelfe Julien Rosset
            • Votes:
              0 Vote for this issue
              4 Start watching this issue


              • Created: