<?php

use yii\db\Migration;

class m170523_070338_product extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%product}}', [
            'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
            'uid' => 'int(10) unsigned NOT NULL',
            'author' => 'varchar(30) NOT NULL',
            'cid' => 'int(10) unsigned NOT NULL',
            'cname' => 'varchar(30) NOT NULL',
            'name' => 'varchar(30) NOT NULL',
            'price' => 'varchar(30) NOT NULL',
            'thumb' => 'varchar(255) NOT NULL',
            'content' => 'text NOT NULL',
            'addtime' => 'int(10) unsigned NOT NULL',
            'updatetime' => 'int(10) unsigned NOT NULL',
            'display' => 'tinyint(1) unsigned NOT NULL',
            'ordid' => 'int(10) unsigned NOT NULL',
            'click' => 'int(10) unsigned NOT NULL',
            'seo_title' => 'varchar(255) NOT NULL',
            'seo_keywords' => 'varchar(255) NOT NULL',
            'seo_description' => 'varchar(255) NOT NULL',
            'url' => 'varchar(255) 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('{{%product}}');
        $this->execute('SET foreign_key_checks = 1;');
    }
}

