<?php

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

/**
 * Item swap/variants (#2): a package item can offer alternatives (e.g. Kosha #1
 * → Kosha #2) each carrying a price delta vs the base, so the client can swap
 * and the total adjusts by the difference. Stored as a JSON array of
 * {label, label_ar, price_delta}.
 */
return new class extends Migration {
    public function up(): void
    {
        Schema::table('bms_package_items', function (Blueprint $t) {
            if (! Schema::hasColumn('bms_package_items', 'options')) {
                $t->json('options')->nullable()->after('media');
            }
        });
    }

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