<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateMallGoodsTable extends Migration
{

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('mall_goods', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('shop_id')->index()->comment('所属店铺');
            $table->unsignedBigInteger('category_id')->index()->comment('分类');
            $table->unsignedBigInteger('brand_id')->nullable()->index()->comment('品牌ID');
            $table->unsignedBigInteger('delivery_id')->nullable()->comment('物流模板');
            $table->unsignedTinyInteger('type')->default(1)->comment('规格类型');
            $table->unsignedTinyInteger('pay_type')->default(1)->comment('支付方式');
            $table->unsignedTinyInteger('deduct_stock_type')->default(1)->comment('库存扣减方式');
            $table->unsignedTinyInteger('channel')->default(1)->comment('商品类型');
            $table->boolean('status')->default(0);
            $table->boolean('is_post_sale')->default(1)->comment('是否可以申请售后');
            $table->unsignedInteger('clicks')->default(0)->comment('浏览量');
            $table->unsignedInteger('sales')->default(0)->comment('总销量');
            $table->decimal('original_price', 10, 2)->default(0)->comment('商品显示的原价');
            $table->string('name');
            $table->string('cover')->nullable();
            $table->json('pictures')->nullable();
            $table->string('description')->nullable();
            $table->text('content')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('mall_goods');
    }

}
