<?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::table('cases', function(Blueprint $t){
            $t->foreignId('resolved_by')->nullable()->index();
            $t->dateTime('resolved_at')->nullable();
        });
        Schema::create('case_comments', function(Blueprint $t){
            $t->id(); $t->foreignId('case_id')->index(); $t->foreignId('user_id')->nullable()->index();
            $t->text('comment'); $t->boolean('is_resolution')->default(false); $t->timestamps(); $t->softDeletes();
        });
    }
    public function down(): void {
        Schema::dropIfExists('case_comments');
        Schema::table('cases',fn(Blueprint $t)=>$t->dropColumn(['resolved_by','resolved_at']));
    }
};
