<?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_memos', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('bad_debt_id')->comment('악성채권 ID');
            $table->text('content')->comment('메모 내용');
            $table->unsignedBigInteger('created_by')->nullable()->comment('작성자 ID');
            $table->timestamps();

            $table->index('bad_debt_id');

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

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