<?php

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

class CreateSettingActiveBankTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('setting_active_banks', function (Blueprint $table) {
            $table->increments('id');
            $table->string('x1_bank_id')->unique();
            $table->string('x2_bank_id')->unique();
            $table->string('beneficiary_id')->nullable();
            $table->foreign('x1_bank_id')
                ->references('acc_no')->on('setting_malaysia_banks')
                ->onDelete('cascade');
            $table->foreign('x2_bank_id')
                ->references('acc_no')->on('setting_malaysia_banks')
                ->onDelete('cascade');
            $table->foreign('beneficiary_id')
                ->references('acc_no')->on('setting_beneficiaries')
                ->onDelete('cascade');
            $table->timestamps();
        });
    }

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