<?php

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

class CreateInventoryMissionsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('inventory_missions', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('inventory_id')->index();
            $table->string('location')->index()->comment('库位');
            $table->integer('commodity_id')->index()->comment('商品id');
            $table->timestamp('produced_at')->nullable()->comment('生产日期');
            $table->timestamp('valid_at')->nullable()->comment('失效日期');
            $table->timestamp('stored_at')->nullable()->comment('入库日期');
            $table->string('batch_number')->nullable()->comment('批号');
            $table->string('erp_type_position')->nullable()->comment('erp属性仓');
            $table->string('quality')->nullable()->comment('质量状态');
            $table->integer('stored_amount')->nullable()->comment('库存数量');
            $table->integer('valid_amount')->default(0)->comment('可用数量');
            $table->integer('verified_amount')->nullable()->comment('盘点数量');
            $table->integer('re_checked_amount')->nullable()->comment('复盘数量');
            $table->integer('difference_amount')->nullable()->comment('盘点差异');
            $table->integer('occupied_amount')->nullable()->comment('分配数量');
            $table->enum('checked',['是','否'])->default('否')->comment('已盘点');
            $table->enum('returned',['是','否','无'])->default('无')->comment('已归位');
            $table->timestamps();
        });
    }

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