<?php

use yii\db\Migration;

/**
 * Class m191111_102925_create_table_cart
 */
class m191111_102925_create_table_cart extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function up()
    {
        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="购物车表"';
        $this->createTable('ats_cart', [
            'id' => $this->primaryKey(),
            'user_id'=>$this->integer(11)->notNull()->comment('用户id'),
            'goods_id'=>$this->integer(11)->notNull()->comment('商品id'),
            'goods_name'=>$this->string(120)->notNull()->comment('商品名称'),
            'goods_img'=>$this->integer(11)->defaultValue(null)->comment('商品图片'),
            'goods_price'=>$this->integer(20)->defaultValue(null)->comment('商品售价'),
            'sku_id'=>$this->integer(11)->notNull()->comment('商品sku的id'),
            'goods_count'=>$this->integer(11)->defaultValue(null)->comment('商品数量'),
            'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'),
            'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'),
        ],$tableOptions);
    }

    /**
     * {@inheritdoc}
     */
    public function down()
    {
        $this->dropTable('ats_cart');
        return true;
    }
}