<?php

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

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

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