database migration in Yii

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

In order to doing migration in Yii I used this lines

 c         


        
2条回答
  •  北海茫月
    2021-02-04 21:15

    $this->createTable('{{users}}',
        array(
            'id' => 'pk',
            'username' => 'varchar(80) NOT NULL',
            'password' => 'varchar(80) NOT NULL',
            'email' => 'varchar(128) NOT NULL',
            'activkey' => '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\'',
        ),
    );
    
    $this->createIndex('username', '{{user}}', 'username', true);
    $this->createIndex('email', '{{user}}', 'email', true);
    $this->createIndex('superuser', '{{user}}', 'superuser', false);
    $this->createIndex('status', '{{user}}', 'status', false);
    

    See http://www.yiiframework.com/doc/api/1.1/CDbMigration#createIndex-detail for more details.

提交回复
热议问题