I have created a yii2 (v2.0.6) migration for a simple MySQL (v5.6.21) table. Everything works, except that I cannot figure out how to AUTO_INCREMENT the primary key. The problem seems to be that I am using a small integer rather than the more standard long integer datatype. Here is my migration code:
$this->createTable('{{%status}}', [
    'id' =>          $this->smallInteger(8)->unique(),
    //'id' =>        $this->primaryKey(11),
    'description' => $this->string(20),
]);
$this->addPrimaryKey('','status','id');
I could get around the problem by using the ->primaryKey() method, which is commented out in line 3 above, but then yii creates a long integer datatype, and I am trying to avoid that. Any insight into the problem will be much appreciated.
Why not a simply primaryKey?, the format for integer(8) , integer(11) or primary key is always the same  is always an integer long 
then or you need a small int (max  5 digit) or you can use  the normal $this->primaryKey() because 
SMALLINT is for    storage of 2  byte (value -32768    32767) an then
smallInteger(8)  is not coherent.  the numer 8 is for output not for store format. If you want  8 digit you  need at least 
INT of 4 byte   -2147483648 2147483647  or more 
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With