<?php

use yii\db\Migration;
use yii\db\Schema;

/**
 * Handles the creation of table `{{%goods}}`.
 */
class m181106_091332_create_goods_table extends Migration
{
    public $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB';
    /**
     * @inheritdoc
     */
    public function up()
    {
        $this->createTable('{{%goods}}', [
            'id' => Schema::TYPE_PK,
            'category_id' => Schema::TYPE_INTEGER . "(11) NOT NULL COMMENT '分类ID'",
            'store_id' => Schema::TYPE_INTEGER . "(11) NOT NULL COMMENT '供应商ID'",
            'name' => Schema::TYPE_STRING . "(50) NOT NULL COMMENT '名称'",
            'desc' => Schema::TYPE_STRING . "(200) NOT NULL COMMENT '描述'",
            'actual_sales' => Schema::TYPE_STRING . "(200) NOT NULL COMMENT '实际销量'",
            'virtual_sales' => Schema::TYPE_STRING . "(200) NOT NULL COMMENT '虚拟销量'",
            'created_at' => Schema::TYPE_INTEGER . "(11) NOT NULL",
            'updated_at' => Schema::TYPE_INTEGER . "(11) NOT NULL",
            'status' => Schema::TYPE_SMALLINT . "(1) NOT NULL DEFAULT '1' COMMENT '状态'",
        ]);
    }

    /**
     * @inheritdoc
     */
    public function down()
    {
        $this->dropTable('{{%goods}}');
    }
}
