Browse Source

Merge pull request #10772 from cakephp/issue-10765

Don't add auto increment to columns that turn it off.
Mark Story 8 years ago
parent
commit
48e03939b0

+ 2 - 1
src/Database/Schema/MysqlSchema.php

@@ -382,7 +382,8 @@ class MysqlSchema extends BaseSchema
         }
         $addAutoIncrement = (
             [$name] == (array)$schema->primaryKey() &&
-            !$schema->hasAutoincrement()
+            !$schema->hasAutoincrement() &&
+            !isset($data['autoIncrement'])
         );
         if (in_array($data['type'], ['integer', 'biginteger']) &&
             ($data['autoIncrement'] === true || $addAutoIncrement)

+ 5 - 0
tests/TestCase/Database/Schema/MysqlSchemaTest.php

@@ -594,6 +594,11 @@ SQL;
             ],
             [
                 'post_id',
+                ['type' => 'integer', 'length' => 20, 'null' => false, 'autoIncrement' => false],
+                '`post_id` INTEGER(20) NOT NULL'
+            ],
+            [
+                'post_id',
                 ['type' => 'biginteger', 'length' => 20, 'autoIncrement' => true],
                 '`post_id` BIGINT AUTO_INCREMENT'
             ],