<?php

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

class AddGoodsSkuNumToBusinessOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasColumns('business_orders', ['goods_sku_num', 'print_status'])) {
            return;
        }
        Schema::table('business_orders', function (Blueprint $table) {
            $table->integer('goods_sku_num')->default(0)->comment('订单内不同商品种类数量');
            $table->tinyInteger('print_status')->default(0)->comment('订单内不同商品种类数量');
            $table->index('goods_sku_num');
            $table->index('print_status');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('business_orders', function (Blueprint $table) {
            $table->dropColumn(['goods_sku_num', 'print_status']);
            $table->dropIndex('goods_sku_num');
            $table->dropIndex('print_status');
        });
    }
}
