<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('meetup_participants', function (Blueprint $table) {
            $table->boolean('is_committee')->default(false)->after('role');
        });

        DB::table('meetup_participants')
            ->whereRaw('UPPER(role) in (?, ?)', ['COMMITTEE', 'ORGANISER'])
            ->update(['is_committee' => true]);
    }

    public function down(): void
    {
        Schema::table('meetup_participants', function (Blueprint $table) {
            $table->dropColumn('is_committee');
        });
    }
};
