<?php

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

class ChangePackageColumn extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::dropIfExists('packages');
        Schema::create('packages', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('owner_id')->nullable()->index()->comment('外键货主');
            $table->string('logistic_number')->unique()->comment('快递单号');
            $table->string('delivery_number')->nullable()->unique()->comment('发货单号');
            $table->string('batch_number')->nullable()->index()->comment('波次号');
            $table->string('batch_rule')->nullable()->comment('波次规则');
            $table->string('recipient')->nullable()->comment('收件人');
            $table->string('recipient_mobile')->nullable()->comment('收件人电话');
            $table->bigInteger('logistic_id')->nullable()->index()->comment('外键物流公司');
            $table->bigInteger('measuring_machine_id')->nullable()->index()->comment('外键设备');
            $table->decimal('weight')->nullable()->comment('重KG');
            $table->decimal('length')->nullable()->comment('长(cm)');
            $table->decimal('width')->nullable()->comment('宽(cm)');
            $table->decimal('height')->nullable()->comment('高(cm)');
            $table->decimal('bulk')->nullable()->comment('体积(cm³)');
            $table->bigInteger('paper_box_id')->nullable()->index()->comment('外键纸箱');
            $table->dateTime('weighed_at')->nullable()->comment('称重时间');
            $table->enum('status',['无','未上传','已上传','未测量','未下发','上传异常','下发异常','记录异常','已上传异常','测量异常'])->default('无')->comment('包裹信息状态');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('packages');
    }
}
