<?php

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

class UpdateOrderColumn extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $tableName = 'order';
        Schema::table($tableName, function (Blueprint $table) use ($tableName) {
            if (!Schema::hasColumn($tableName, 'resource_id')) {
                $table->string("resource_id", 255)->nullable();
            }
            if (!Schema::hasColumn($tableName, 'cost')) {
                $table->double('cost')->unsigned()->nullable();
            }
            if (!Schema::hasColumn($tableName, 'shipping_cost')) {
                $table->double('shipping_cost')->unsigned()->nullable();
            }
            if (!Schema::hasColumn($tableName, 'tax_cost')) {
                $table->double('tax_cost')->unsigned()->nullable();
            }
        });

        $tableName = 'order_item';
        Schema::table($tableName, function (Blueprint $table) use ($tableName) {
            if (!Schema::hasColumn($tableName, 'resource_id')) {
                $table->string("resource_id", 255)->nullable();
            }
            if (!Schema::hasColumn($tableName, 'resource_item_id')) {
                $table->string("resource_item_id", 255)->nullable();
            }
            if (!Schema::hasColumn($tableName, 'printing_code')) {
                $table->string("printing_code", 255)->nullable();
            }
            if (!Schema::hasColumn($tableName, 'cost')) {
                $table->double('cost')->unsigned()->nullable();
            }
            if (!Schema::hasColumn($tableName, 'shipping_cost')) {
                $table->double('shipping_cost')->unsigned()->nullable();
            }
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        
    }
}
