<?php

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

/**
 * Carry the selection's per-item customization (kept items, variant swaps and
 * buffet-content substitutions) onto the booking hall, so a confirmed booking,
 * its contract and documents reflect exactly what the client chose — not only
 * the rolled-up price.
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('bms_booking_halls', function (Blueprint $table) {
            if (! Schema::hasColumn('bms_booking_halls', 'package_items')) {
                $table->json('package_items')->nullable()->after('addons');
            }
        });
    }

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