<?php

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

class CreateOrderFreezesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('order_freezes', function (Blueprint $table) {
            $table->id();
            $table->tinyInteger("status")->default(0)->comment("状态");
            $table->bigInteger("logistic_id")->comment("承运商");
            $table->bigInteger("province_id")->nullable()->comment("省");
            $table->bigInteger("city_id")->nullable()->comment("市");
            $table->bigInteger("location_id")->nullable()->comment("区");
            $table->index(["status","logistic_id","province_id","city_id","location_id"],"freeze_s_l_p_c_l_index");
            $table->timestamps();
        });
        \App\Authority::query()->firstOrCreate(["name"=>"订单管理-自动冻结","alias_name"=>"订单管理-自动冻结"]);
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('order_freezes');
        \App\Authority::query()->where("name","订单管理-自动冻结")->delete();
    }
}
