<?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('pension_case_comments', function (Blueprint $table) {
            $table->id();
            $table->foreignId('pension_case_id')->constrained()->cascadeOnDelete();
            $table->unsignedBigInteger('comment_created_by')->nullable();
            $table->timestamp('comment_created_at')->nullable();
            $table->longText('comment_text');
            // No updated_at — comments are append-only
            $table->timestamp('created_at')->nullable();

            $table->index('pension_case_id');
            $table->index('comment_created_by');
        });
    }

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