<?php

use yii\db\Migration;

class m170523_070338_migration extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%migration}}', [
            'version' => 'varchar(180) NOT NULL',
            'apply_time' => 'int(11) NULL',
            'PRIMARY KEY (`version`)'
        ], "ENGINE=MyISAM DEFAULT CHARSET=utf8");
        
        /* 索引设置 */
        
        
        /* 表数据 */
        $this->insert('{{%migration}}',['version'=>'m000000_000000_base','apply_time'=>'1490598083']);
        $this->insert('{{%migration}}',['version'=>'m140602_111327_create_menu_table','apply_time'=>'1490598087']);
        $this->insert('{{%migration}}',['version'=>'m160312_050000_create_user','apply_time'=>'1490598088']);
        $this->insert('{{%migration}}',['version'=>'m140506_102106_rbac_init','apply_time'=>'1490598126']);
        
        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

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

