<?php

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

class UpdatePaymentsColumnsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('payments', function (Blueprint $table) {
            $table->string('type')->nullable()->change();
            $table->string('failure_message')->nullable()->after('provider');
            $table->string('failure_code')->nullable()->after('provider');
            $table->string('exp_year')->nullable()->after('provider');
            $table->string('exp_month')->nullable()->after('provider');
            $table->string('last4')->nullable()->after('provider');
            $table->string('country')->nullable()->after('provider');
            $table->string('network')->nullable()->after('provider');
            $table->string('brand')->nullable()->after('provider');
            $table->string('funding')->nullable()->after('provider');
            $table->string('customer')->nullable()->after('provider');
            $table->string('payment_method')->nullable()->after('provider');
            $table->string('currency')->nullable()->after('total');
            $table->double('application_fee_amount', 15, 3)->nullable()->after('total');
            $table->double('application_fee', 15, 3)->nullable()->after('total');
            $table->double('amount_refunded', 15, 3)->nullable()->after('total');
            $table->double('amount_captured', 15, 3)->nullable()->after('total');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('payments', function (Blueprint $table) {
            $table->string('type')->nullable()->change();
            $table->dropColumn('failure_message');
            $table->dropColumn('failure_code');
            $table->dropColumn('exp_year');
            $table->dropColumn('exp_month');
            $table->dropColumn('last4');
            $table->dropColumn('country');
            $table->dropColumn('network');
            $table->dropColumn('brand');
            $table->dropColumn('funding');
            $table->dropColumn('customer');
            $table->dropColumn('payment_method');
            $table->dropColumn('currency');
            $table->dropColumn('application_fee_amount');
            $table->dropColumn('application_fee');
            $table->dropColumn('amount_refunded');
            $table->dropColumn('amount_captured');
        });
    }
}
