<?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('membership_application_reviews', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->foreignUuid('membership_application_id')
                ->constrained('membership_applications')
                ->cascadeOnDelete();

            $table->string('stage')->comment('MANAGEMENT, BOARD');
            $table->string('decision')->comment('MANAGEMENT: APPROVED, REJECTED | BOARD: PASS, FAIL');
            $table->text('remarks')->nullable();

            $table->foreignUuid('reviewer_id')->constrained('users')->restrictOnDelete();
            $table->timestamp('reviewed_at');

            $table->timestamps();

            $table->unique(['membership_application_id', 'stage']);
        });
    }

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