<?php

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

/**
 * Arabic descriptions so the client renders package/hall copy in the selected
 * language (descriptions previously shipped EN-only). See [[bms-client-i18n]].
 */
return new class extends Migration {
    public function up(): void
    {
        foreach (['bms_packages', 'bms_halls'] as $table) {
            if (Schema::hasTable($table) && ! Schema::hasColumn($table, 'description_ar')) {
                Schema::table($table, function (Blueprint $t) {
                    $t->text('description_ar')->nullable()->after('description');
                });
            }
        }
    }

    public function down(): void
    {
        foreach (['bms_packages', 'bms_halls'] as $table) {
            if (Schema::hasTable($table) && Schema::hasColumn($table, 'description_ar')) {
                Schema::table($table, fn (Blueprint $t) => $t->dropColumn('description_ar'));
            }
        }
    }
};
