<?php

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

class CreateOrderMatchingTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable('order_matching')) {
            Schema::create('order_matching', function (Blueprint $table) {
                $table->bigIncrements('id');
                $table->string('order_code', 15)->nullable()->collation('utf8mb4_unicode_ci');
                $table->string('printing_code', 50)->nullable()->collation('utf8mb4_unicode_ci');
                $table->decimal('cost', 10, 2)->nullable()->default(0.00);
                $table->decimal('shipping_cost', 10, 2)->nullable()->default(0.00);
                $table->decimal('tax_cost', 10, 2)->nullable()->default(0.00);
                $table->dateTime('created_at')->nullable();
                $table->dateTime('updated_at')->nullable();
                $table->unique(['order_code', 'printing_code'], 'uni');
                $table->charset = 'utf8mb4';
                $table->collation = 'utf8mb4_unicode_ci';
            });
        }
    }

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