I created a yii2 migration (v2.0.6) for a simple MySQL table (v5.6.21). Everything works, except that I cannot figure out how to make AUTO_INCREMENT the primary key. The problem is that I am using a small integer rather than the more standard long integer data type. Here is my migration code:
$this->createTable('{{%status}}', [
'id' => $this->smallInteger(8)->unique(),
'description' => $this->string(20),
]);
$this->addPrimaryKey('','status','id');
I could solve the problem with the → primaryKey () method, which is commented out on line 3 above, but then yii creates a long integer data type, and I try to avoid this. Any understanding of the problem would be greatly appreciated.
source
share