Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-464

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

    Details

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

      Description

      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.

        Issue Links

          Activity

          Julien Rosset created issue -
          Benjamin Eberlei made changes -
          Field Original Value New Value
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 2.5 [ 10523 ]
          Resolution Fixed [ 1 ]
          Hide
          Andreas Goetz added a comment -

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

          Show
          Andreas Goetz added a comment - I'm still seeing this problem in 2.5.1 on mysql. Any advice?
          Hide
          Steve Müller added a comment -

          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.

          Show
          Steve Müller added a comment - 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.
          Show
          Andreas Goetz added a comment - Only a partial fix, see https://github.com/andig/dbal/commit/bd07dced2bf4638d6e12c23a92b452922e8f173b
          Hide
          Andreas Goetz added a comment -
          Show
          Andreas Goetz added a comment - Sorry, I've meant https://github.com/doctrine/dbal/pull/786
          Hide
          Doctrine Bot added a comment -

          A related Github Pull-Request [GH-786] was assigned:
          https://github.com/doctrine/dbal/pull/786

          Show
          Doctrine Bot added a comment - A related Github Pull-Request [GH-786] was assigned: https://github.com/doctrine/dbal/pull/786
          Hide
          Doctrine Bot added a comment -

          A related Github Pull-Request [GH-786] was merged:
          https://github.com/doctrine/dbal/pull/786

          Show
          Doctrine Bot added a comment - A related Github Pull-Request [GH-786] was merged: https://github.com/doctrine/dbal/pull/786
          Steve Müller made changes -
          Link This issue is referenced by DBAL-1132 [ DBAL-1132 ]

          This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

          • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DBAL-464, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

            People

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

              Dates

              • Created:
                Updated:
                Resolved: