<?php

use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\BankAccountType;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateBanksTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('bank_accounts', function (Blueprint $table) {
            $table->id();
            $table->morphs('owner');
            $table->foreignId('country_id');
            $table->string('bank_name',45);
            $table->string('bank_branch',45)->nullable();
            $table->string('account_name',45);
            $table->string('account_number',45);
            $table->integer('type')->default(BankAccountType::EXTERNAL);
            $table->integer('default')->default(false);
            $table->integer('status')->default(ApprovalStatus::APPROVED);

            $table->softDeletes();
            $table->timestamps();

        });

        Schema::table('bank_accounts', function (Blueprint $table) {
            $table->string('owner_type', 191)->change();
        });
    }

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