<?php

use yii\db\Migration;

class m170523_070338_ad_category extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%ad_category}}', [
            'id' => 'int(10) NOT NULL AUTO_INCREMENT',
            'alias' => 'varchar(100) NOT NULL',
            'type' => 'int(10) unsigned NOT NULL',
            'name' => 'varchar(100) NOT NULL',
            'width' => 'int(10) NOT NULL',
            'height' => 'int(10) NOT NULL',
            'max' => 'int(10) NOT NULL',
            'PRIMARY KEY (`id`)'
        ], "ENGINE=InnoDB  DEFAULT CHARSET=utf8");
        
        /* 索引设置 */
        
        
        /* 表数据 */
        $this->insert('{{%ad_category}}',['id'=>'2','alias'=>'yunduo_index_focus','type'=>'1','name'=>'首页轮播幻灯片','width'=>'1800','height'=>'693','max'=>'4']);
        
        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

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

