<?php

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

class CreateOwnerContractsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('owner_contracts', function (Blueprint $table) {
            $table->id();
            $table->string("contract_number",30)->index()->comment("合同号");
            $table->string("salesman",20)->comment("销售名称");
            $table->string("remark")->comment("备注");
            $table->bigInteger("owner_id")->comment("外键货主");
            $table->timestamps();
        });
        Schema::table("owners",function (Blueprint $table){
            $table->dropColumn("contract_number");
            $table->dropColumn("salesman");
        });
        Schema::table("upload_files",function (Blueprint $table){
            $table->string("file_name")->nullable();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('owner_contracts');
        Schema::table("owners",function (Blueprint $table){
            $table->string('contract_number')->nullable()->comment('合同号');
            $table->string('salesman')->nullable()->comment('销售名称');
        });
        Schema::table("upload_files",function (Blueprint $table){
            $table->dropColumn("file_name");
        });
    }
}
