<?php

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

class AddExtraOrderColumns extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('orders', function (Blueprint $table) {
            $table->string('order_number', 20)->nullable();
            $table->string('customer_type', 1)->nullable();
            $table->string('tax_id', 50)->nullable();
            $table->decimal('shipping_total', 15, 2);
            $table->decimal('shipping_discount', 15, 2)->nullable();
        });

        Schema::table('order_items', function (Blueprint $table) {
            $table->decimal('discount', 15, 2)->nullable();
            $table->date('expected_date')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('order_items', function (Blueprint $table) {
            $table->dropColumn('discount');
            $table->dropColumn('expected_date');
        });

        Schema::table('orders', function (Blueprint $table) {
            $table->dropColumn('order_number');
            $table->dropColumn('customer_type');
            $table->dropColumn('tax_id');
            $table->dropColumn('shipping_total');
            $table->dropColumn('shipping_discount');
        });
    }
}
