<?php

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

class AddFieldToPurchaseRecordsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasColumns('purchase_records', ["arrived_time", "status","check_time"])) {
            return;
        }
        Schema::table('purchase_records', function (Blueprint $table) {
            $table->dateTime('arrived_time')->nullable()->comment('到货时间');
            $table->integer('status')->default(0)->comment('采购单状态 0待审核 1已审核 2审核失败');
            $table->dateTime('check_time')->nullable()->comment('审核时间');;

        });

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('purchase_records', function (Blueprint $table) {
            //
            $table->dropColumn('arrived_time');
            $table->dropColumn('status');
            $table->dropColumn('check_time');

        });
    }
}
