<?php

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

class AddSaleStockAndQualityPeriodToGoodsSkusTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasColumns('goods_skus', ['sale_stock', 'quality_period'])) {
            return;
        }
        Schema::table('goods_skus', function (Blueprint $table) {
            //
            $table->integer('sale_stock')->default(0)->comment("在售库存数");
            $table->integer('quality_period')->nullable()->comment("保质期时间,单位天");

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('goods_skus', function (Blueprint $table) {
            //
            $table->dropColumn('sale_stock');
            $table->dropColumn('quality_period');
        });
    }
}
