<?php

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

class CreateStationTaskCommoditiesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('station_task_commodities', function (Blueprint $table) {
            $table->id();
            $table->integer('station_id');  //联合索引
            $table->integer('material_box_id');  //联合索引
            $table->integer('commodity_id')->index();
            $table->integer('amount')->default(0);
            $table->integer('order_id')->index();
            $table->enum('status',['待处理','挂起','处理中','完成','异常','取消'])->index();  //有联合索引
            $table->index(['station_id','material_box_id','status'],'station_task_commodities_s_m_s_index');
            $table->timestamps();
        });
    }

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