I tried generating a migration for a table which has a composite (two-column) primary key.
The result that I got from the generator was
public function safeUp()
{
$tableOptions = 'ENGINE=InnoDB';
$this->createTable('{{%test}}',[
'a'=> $this->primaryKey(20),
'b'=> $this->primaryKey(20),
'c'=> $this->integer(11),
], $tableOptions);
}
However this will not import on MariaDB 10.1.22 (and possible on MySQL) with the following error:
Exception: 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
I think that when there is a composite primary key, you should generate the PK using this example
I tried generating a migration for a table which has a composite (two-column) primary key. The result that I got from the generator was
However this will not import on MariaDB 10.1.22 (and possible on MySQL) with the following error:
Exception: 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
I think that when there is a composite primary key, you should generate the PK using this example