<?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('barobill_bank_transaction_overrides', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('tenant_id')->comment('테넌트 ID');
            $table->string('unique_key', 100)->comment('거래 고유키 (계좌번호|거래일시|입금|출금|잔액)');
            $table->string('modified_summary', 200)->nullable()->comment('수정된 적요');
            $table->string('modified_cast', 200)->nullable()->comment('수정된 내용');
            $table->timestamps();

            // 복합 유니크 인덱스 (테넌트별 거래 고유키)
            $table->unique(['tenant_id', 'unique_key'], 'bb_trans_override_unique');

            // 조회용 인덱스
            $table->index('tenant_id', 'bb_trans_override_tenant_idx');
        });
    }

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