<?php

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

class ChangeDeliveryAppointmentsTableAddLogisticNumberColumn extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table("delivery_appointments",function (Blueprint $table){
            $table->bigInteger("logistic_id")->index()->nullable()->comment("快递公司");
            $table->string("logistic_number",50)->nullable()->comment("快递单号");
            $table->tinyInteger("type_mark")->nullable()->comment("类型标记");
            $table->text("remark")->nullable()->comment("备注");
        });
        \App\Authority::query()->firstOrCreate(["name"=>"入库管理-入库预约-质检"],[
            "name" => "入库管理-入库预约-质检",
            "alias_name" => "入库管理-入库预约-质检",
        ]);
        Schema::table("owner_fee_details",function (Blueprint $table){
            $table->string("province")->nullable()->comment("省");
        });
        Schema::table("owner_price_systems",function (Blueprint $table){
            $table->bigInteger("time_unit_id")->nullable()->comment("计时单位");
        });
        \App\Unit::query()->firstOrCreate(["name"=>"年"]);
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table("delivery_appointments",function (Blueprint $table){
            $table->dropColumn("logistic_id");
            $table->dropColumn("logistic_number");
            $table->dropColumn("type_mark");
            $table->dropColumn("remark");
        });
        Schema::table("owner_fee_details",function (Blueprint $table){
            $table->dropColumn("province");
        });
        Schema::table("owner_price_systems",function (Blueprint $table){
            $table->dropColumn("time_unit_id");
        });
        \App\Authority::query()->where("alias_name","入库管理-入库预约-质检")->delete();
    }
}
