<?php

use yii\db\Migration;

class m170523_070338_about extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%about}}', [
            'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
            'uid' => 'int(10) unsigned NOT NULL',
            'author' => 'varchar(30) NOT NULL',
            'title' => 'varchar(30) NOT NULL',
            'content' => 'text NOT NULL',
            'display' => 'tinyint(1) unsigned NOT NULL',
            'addtime' => 'int(10) unsigned NOT NULL',
            'updatetime' => 'int(10) unsigned NOT NULL',
            'ordid' => 'int(10) unsigned NOT NULL',
            'seo_title' => 'varchar(255) NOT NULL',
            'seo_keywords' => 'varchar(255) NOT NULL',
            'seo_description' => 'varchar(255) NOT NULL',
            'PRIMARY KEY (`id`)'
        ], "ENGINE=MyISAM  DEFAULT CHARSET=utf8");
        
        /* 索引设置 */
        
        
        /* 表数据 */
        $this->insert('{{%about}}',['id'=>'1','uid'=>'1','author'=>'admin','title'=>'公司简介','content'=>'','display'=>'1','addtime'=>'1493191259','updatetime'=>'1493782991','ordid'=>'0','seo_title'=>'','seo_keywords'=>'','seo_description'=>'']);
        $this->insert('{{%about}}',['id'=>'3','uid'=>'1','author'=>'admin','title'=>'联系我们','content'=>'','display'=>'1','addtime'=>'1493191259','updatetime'=>'1493191259','ordid'=>'0','seo_title'=>'','seo_keywords'=>'','seo_description'=>'']);
        $this->insert('{{%about}}',['id'=>'2','uid'=>'1','author'=>'admin','title'=>'发展历程','content'=>'','display'=>'1','addtime'=>'1493191300','updatetime'=>'1493201992','ordid'=>'0','seo_title'=>'','seo_keywords'=>'','seo_description'=>'']);
        
        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

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

