database migration in Yii

前端 未结 2 901
慢半拍i
慢半拍i 2021-02-04 20:57

In order to doing migration in Yii I used this lines

 c         


        
2条回答
  •  孤独总比滥情好
    2021-02-04 21:14

    Just supply them as non-associative values in the array like this:

    $this-> createTable('{{users}}',array(
       'id' => 'pk',
       'username' => 'VARCHAR (80) NOT NULL',
       'password' => 'VARCHAR (80) NOT NULL',
       'email' => 'VARCHAR (128) NOT NULL',
       'activekey' => 'VARCHAR (128) NOT NULL DEFAULT \'\'',
       'createtime' => 'INTEGER (10) NOT NULL DEFAULT \'0\' ',
       'lastvisit' => 'INTEGER (10) NOT NULL DEFAULT \'0\' ',
       'superuser' => 'INTEGER (1) NOT NULL DEFAULT \'0\' ',
       'status'=> 'INTEGER (1) NOT NULL DEFAULT \'0\' ',
       'UNIQUE KEY `username` (`username`)',
       'UNIQUE KEY `email` (`email`)',
       'KEY `status` (`status`)',
       'KEY `superuser` (`superuser`)',
    ));
    

    This way they will be added to the end of the create statement without any change.

提交回复
热议问题