<?php

use App\Enums\UserBankType;
use App\Enums\OriginStatusType;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

return new class extends Migration {
  /**
   * Run the migrations.
   */
  public function up(): void
  {
    Schema::create('user_banks', function (Blueprint $table) {
      $table->id();
      $table->foreignId('user_id')->nullable()->constrained('users');
      $table->foreignId('company_id')->nullable()->constrained('companies');
      $table->foreignId('bank_id')->constrained('banks');
      $table->string('type')->default(UserBankType::Personal)->index();
      $table->bigInteger('account_number');
      $table->string('account_name');
      $table->string('branch')->nullable();
      $table->string('status')->default(OriginStatusType::Active)->index();
      $table->timestamps();
    });
  }

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