<?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('bad_debt_documents', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('bad_debt_id')->comment('악성채권 ID');
            $table->string('document_type', 50)->comment('서류 유형: business_license(사업자등록증), tax_invoice(세금계산서), additional(추가서류)');
            $table->unsignedBigInteger('file_id')->comment('파일 ID');
            $table->timestamps();

            $table->index('bad_debt_id');
            $table->index('document_type');

            $table->foreign('bad_debt_id')
                ->references('id')
                ->on('bad_debts')
                ->onDelete('cascade');
        });
    }

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