<?php

use yii\db\Migration;

class m170523_070338_admin extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%admin}}', [
            'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
            'username' => 'varchar(30) NOT NULL',
            'password' => 'varchar(32) NOT NULL',
            'password_hash' => 'varchar(255) NOT NULL',
            'password_reset_token' => 'varchar(50) NOT NULL',
            'auth_key' => 'varchar(32) NOT NULL',
            'last_logintime' => 'int(10) unsigned NOT NULL',
            'status' => 'tinyint(1) unsigned NOT NULL',
            'nickname' => 'varchar(30) NOT NULL',
            'updated_at' => 'int(10) unsigned NOT NULL',
            'role' => 'int(10) unsigned NOT NULL',
            'super' => 'tinyint(1) unsigned NOT NULL DEFAULT \'0\'',
            'created_at' => 'int(10) unsigned NOT NULL',
            'PRIMARY KEY (`id`)'
        ], "ENGINE=MyISAM  DEFAULT CHARSET=utf8");
        
        /* 索引设置 */
        
        
        /* 表数据 */
        
        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

    public function down()
    {
        $this->execute('SET foreign_key_checks = 0');
        /* 删除表 */
        $this->dropTable('{{%admin}}');
        $this->execute('SET foreign_key_checks = 1;');
    }
}

