<?php

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

class CreateProcessesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * 二次加工单
     *
     * @return void
     */
    public function up()
    {
        Schema::create('processes', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('code')->unique()->comment('任务号');
            $table->bigInteger('owner_id')->index()->comment('外键货主');
            $table->enum('bill_type',['移库单','入库单','出库单'])->comment('单据类型');
            $table->string('wms_code')->index()->comment('单据号');
            $table->bigInteger('process_method_id')->comment('外键加工类型');
            $table->string('operation_code')->nullable()->comment('作业码');
            $table->decimal('unit_price')->comment('单价');
            $table->enum('status',['待接单','待加工','驳回','加工中','待验收','已完成'])->comment('状态');
            $table->bigInteger('commodity_id')->comment('外键商品');
            $table->integer('amount')->comment('数量');
            $table->integer('completed_amount')->nullable()->comment('完成数量');
            $table->string('remark')->nullable()->comment('备注');
            $table->timestamp('created_at')->index()->nullable();
            $table->timestamp('updated_at')->nullable();
        });
    }

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