<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('bank_accounts', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('tenant_id')->comment('테넌트 ID');
            $table->string('bank_code', 10)->comment('은행 코드');
            $table->string('bank_name', 50)->comment('은행명');
            $table->string('account_number', 30)->comment('계좌번호');
            $table->string('account_holder', 50)->comment('예금주');
            $table->string('account_name', 100)->comment('계좌 별칭');
            $table->string('status', 20)->default('active')->comment('상태: active/inactive');
            $table->unsignedBigInteger('assigned_user_id')->nullable()->comment('담당자 ID');
            $table->boolean('is_primary')->default(false)->comment('대표계좌 여부');
            $table->unsignedBigInteger('created_by')->nullable()->comment('생성자 ID');
            $table->unsignedBigInteger('updated_by')->nullable()->comment('수정자 ID');
            $table->unsignedBigInteger('deleted_by')->nullable()->comment('삭제자 ID');
            $table->softDeletes();
            $table->timestamps();

            $table->index('tenant_id', 'idx_bank_accounts_tenant');
            $table->index('status', 'idx_bank_accounts_status');
        });
    }

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