<?php

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

class AddColumnCarrierTableLogistic extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('logistics', function (Blueprint $table) {
            $table->enum("type",["logistic","express"])->default("express")->comment("类型");
            $table->string("mobile")->nullable()->comment("手机号");
            $table->string("remark")->nullable()->comment("备注");
            $table->decimal("delivery_fee")->nullable()->comment("送货费");
        });
        Schema::table('waybills', function (Blueprint $table) {
            $table->renameColumn("carrier_id","logistic_id");
        });
        Schema::table('waybill_price_models', function (Blueprint $table) {
            $table->renameColumn("carrier_id","logistic_id");
        });
        Schema::table('carrier_user', function (Blueprint $table) {
            $table->rename("logistic_user");
        });
        Schema::table('logistic_user', function (Blueprint $table) {
            $table->renameColumn("carrier_id","logistic_id");
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('logistics', function (Blueprint $table) {
            $table->dropColumn("type");
            $table->dropColumn("mobile");
            $table->dropColumn("remark");
            $table->dropColumn("delivery_fee");
        });
        Schema::table('waybills', function (Blueprint $table) {
            $table->renameColumn("logistic_id","carrier_id");
        });
        Schema::table('waybill_price_models', function (Blueprint $table) {
            $table->renameColumn("logistic_id","carrier_id");
        });
        Schema::table('logistic_user', function (Blueprint $table) {
            $table->rename("carrier_user");
        });
        Schema::table('carrier_user', function (Blueprint $table) {
            $table->renameColumn("logistic_id","carrier_id");
        });
    }
}
