<?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('c4_stakeholder_engagements', function (Blueprint $table) {
            $table->id();
            $table->string('serial_no', 50)->nullable()->unique()->comment('S/N from register');
            $table->string('name');
            $table->string('organization')->nullable();
            $table->string('designation')->nullable();
            $table->enum('gender', ['male', 'female', 'other'])->nullable();
            $table->string('state_province')->nullable();
            $table->date('date_of_engagement');
            $table->string('component_of_engagement')->nullable()->comment('e.g. Component 1, 2, 3, 4 or "Cross-cutting"');

            // Engagement Categories (boolean flags – exactly as in your Excel)
            $table->boolean('project_launch')->default(false);
            $table->boolean('learning_event')->default(false);
            $table->boolean('partners_forum')->default(false);
            $table->boolean('orientation')->default(false);
            $table->boolean('validation_meetings')->default(false);
            $table->boolean('consultations')->default(false);
            $table->boolean('others')->default(false);

            $table->text('comment_remark')->nullable();

            $table->timestamps();

            // Indexes for fast filtering (same style as C4Participant)
            $table->index('state_province');
            $table->index('gender');
            $table->index('date_of_engagement');
            $table->index('component_of_engagement');
        });
    }

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