<?php

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

/**
 * Tag hall media with the event type it depicts (Wedding, Engagement,
 * Corporate, Birthday, Other) so the client shows relevant imagery per the
 * guest's chosen occasion (2.4 / 2.5.1). Null = generic / all occasions.
 */
return new class extends Migration {
    public function up(): void
    {
        Schema::table('bms_hall_media', function (Blueprint $t) {
            if (! Schema::hasColumn('bms_hall_media', 'event_type')) {
                $t->string('event_type', 50)->nullable()->after('title')->index();
            }
        });
    }

    public function down(): void
    {
        Schema::table('bms_hall_media', function (Blueprint $t) {
            if (Schema::hasColumn('bms_hall_media', 'event_type')) {
                $t->dropColumn('event_type');
            }
        });
    }
};
