phinx
phinx copied to clipboard
SQLiteAdapter adds autoincrement to integer column when changing primary key
If I do:
$this->table('foo')
->addColumn('id_2', 'integer')
->create();
$this->table('foo')
->changePrimaryKey('id_2')
->update();
After the create I'll have:
CREATE TABLE `foo` (`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `id_2` INTEGER NULL);
and after the update I'll have:
CREATE TABLE IF NOT EXISTS "foo" (`id` INTEGER NOT NULL, `id_2` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT);
where even though didn't specify it, id_2 now has AUTOINCREMENT because it's an integer column. None of the other adapters does this, and it doesn't make sense that sqlite does either.
Solved in https://github.com/cakephp/migrations/pull/954 for Migrations. Feel free to port, seems like an important fix.