<?php

use yii\db\Migration;

class m170523_070338_pagecache extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%pagecache}}', [
            'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
            'name' => 'varchar(30) NOT NULL',
            'alias' => 'varchar(30) NOT NULL',
            'status' => 'tinyint(1) unsigned NOT NULL',
            'time' => 'int(10) unsigned NOT NULL',
            'PRIMARY KEY (`id`)'
        ], "ENGINE=MyISAM  DEFAULT CHARSET=utf8");
        
        /* 索引设置 */
        
        
        /* 表数据 */
        $this->insert('{{%pagecache}}',['id'=>'2','name'=>'新闻中心频道页','alias'=>'news','status'=>'0','time'=>'0']);
        $this->insert('{{%pagecache}}',['id'=>'3','name'=>'新闻详情页','alias'=>'news_detail','status'=>'0','time'=>'0']);
        $this->insert('{{%pagecache}}',['id'=>'1','name'=>'首页','alias'=>'index','status'=>'0','time'=>'0']);
        $this->insert('{{%pagecache}}',['id'=>'5','name'=>'新闻列表页','alias'=>'news_list','status'=>'0','time'=>'60']);
        $this->insert('{{%pagecache}}',['id'=>'6','name'=>'关于我们','alias'=>'about','status'=>'0','time'=>'0']);
        $this->insert('{{%pagecache}}',['id'=>'7','name'=>'产品频道页','alias'=>'product','status'=>'0','time'=>'0']);
        $this->insert('{{%pagecache}}',['id'=>'8','name'=>'产品列表页','alias'=>'product_list','status'=>'0','time'=>'0']);
        $this->insert('{{%pagecache}}',['id'=>'9','name'=>'产品详情页','alias'=>'product_detail','status'=>'0','time'=>'0']);
        $this->insert('{{%pagecache}}',['id'=>'10','name'=>'招贤纳士','alias'=>'job','status'=>'0','time'=>'0']);
        $this->insert('{{%pagecache}}',['id'=>'11','name'=>'招贤纳士详情页','alias'=>'job_detail','status'=>'0','time'=>'0']);
        
        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

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

