<?php

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

class CreateWaybillsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable('waybills')) {
            return;
        }
        Schema::create('waybills', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('shop_id');
            $table->string('request_id')->default('');
            $table->text('encryptedData')->nullable();
            $table->string('signature')->default('');
            $table->string('templateUrl');
            $table->string('ver')->default('');
            $table->string('waybill_code')->default('');
            $table->string('object_id', 32);
            $table->integer('key')->default(0);

            $table->string('sender_country');
            $table->string('sender_province');
            $table->string('sender_city');
            $table->string('sender_district');
            $table->string('sender_detail');
            $table->string('sender_name');
            $table->integer('sender_mobile');

            $table->string('recipient_country')->default('');
            $table->string('recipient_province');
            $table->string('recipient_city');
            $table->string('recipient_district');
            $table->string('recipient_detail');
            $table->string('recipient_name');
            $table->string('recipient_mobile', 16);

            $table->string('user_id');
            $table->string('wp_code');
            $table->string('order_channels_type')->default('PDD');

            $table->string('order_sn');
            $table->integer('order_id');
            $table->integer('participate_no')->default(0);
            $table->string('note')->nullable();
            $table->text('items');
            $table->tinyInteger('cancel')->default(0);

            $table->timestamps();

            $table->index('object_id');
        });
    }

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