<?php

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

/**
 * Handles the creation of table `{{%store}}`.
 */
class m181105_023343_create_store_table extends Migration
{
    public $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB';

    /**
     * @inheritdoc
     */
    public function up()
    {
        /**
         * 商品分类
         */
        $this->createTable('{{%store}}', [
            'id' => Schema::TYPE_PK,
            'user_id' => Schema::TYPE_INTEGER . "(11) NOT NULL COMMENT '店家账户'",
            'proxy_user_id' => Schema::TYPE_INTEGER . "(11) NOT NULL COMMENT '代理人'",
            'name' => Schema::TYPE_STRING . "(20) NOT NULL  COMMENT '名称'",
            'contacts' => Schema::TYPE_STRING . "(20) NOT NULL DEFAULT '' COMMENT '联系人'",
            'tel' => Schema::TYPE_STRING . "(11) NOT NULL  DEFAULT '' COMMENT '联系电话'",
            'address' => Schema::TYPE_STRING . "(200) NOT NULL DEFAULT ''  COMMENT '地址'",
            'address_name' => Schema::TYPE_STRING . "(200) NOT NULL DEFAULT ''  COMMENT '地址'",
            'city' => Schema::TYPE_STRING . "(100)  NOT NULL DEFAULT ''  COMMENT '城市'",
            'longitude' => Schema::TYPE_DECIMAL . "(10,7)  NOT NULL  DEFAULT '0' COMMENT '经度'",
            'latitude' => Schema::TYPE_DECIMAL . "(10,7)  NOT NULL  DEFAULT ''  COMMENT '纬度'",
            'desc' => Schema::TYPE_STRING . "(300) NOT NULL  DEFAULT ''  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 '状态'",
        ], $this->tableOptions);

    }

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