<?php

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

return new class extends Migration {
    public function up(): void {
        Schema::create('wills_case_comments', function (Blueprint $table) {
            $table->id();
            $table->foreignId('wills_case_id')->constrained()->cascadeOnDelete();
            $table->foreignId('comment_created_by')->nullable()->constrained('users')->nullOnDelete();
            $table->timestamp('comment_created_at')->nullable();
            $table->text('comment_text');
            $table->timestamps();

            $table->index('wills_case_id');
        });
    }

    public function down(): void {
        Schema::dropIfExists('wills_case_comments');
    }
};
