<?php

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

class AddStatusAndSentAndAtAndReceivedAtAndExecptionAndTarnsferStatusAndRemarkToOrderPackage extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('order_packages', function (Blueprint $table) {
            //
            $table->enum('status', ['无', '已称重', '已揽收', '在途', '在途异常', '派送中', '派送异常', '返回中', '返回异常', '返回派件', '其他异常', '已收件'])->default('无')->comment('包裹信息状态');
            $table->dateTime('sent_at')->nullable()->comment('发出时间');
            $table->dateTime('received_at')->nullable()->comment('揽收时间');
            $table->enum('exception', ['是', '否'])->default('否')->comment('异常状态');
            $table->text('transfer_status')->nullable()->comment('更新信息');
            $table->string('remark')->nullable()->comment('备注');
            $table->index(['sent_at', 'exception']);
            $table->index(['received_at', 'exception']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('order_packages', function (Blueprint $table) {
            $table->dropColumn('status');
            $table->dropColumn('sent_at');
            $table->dropColumn('received_at');
            $table->dropColumn('exception');
            $table->dropColumn('transfer_status');
            $table->dropColumn('remark');
        });
    }
}
