<?php

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

/**
 * Drops the `locales` table. Locale metadata (code, name, direction, default
 * font stack) moved to `config/locales.php` + `App\Support\Locales` — code is
 * the source of truth now. Admin doesn't manage locales; the catalog ships
 * with the release.
 *
 * Project-side state stays in the `projects` table (`default_locale` +
 * `active_locales` JSON column) — those reference catalog codes by string,
 * resolver reads metadata from the config at runtime.
 *
 * This migration also drops the now-orphaned migration log rows so a future
 * `migrate:rollback` doesn't trip looking for the deleted source files for
 * `2026_04_21_190002_create_locales_table` and
 * `2026_05_21_120001_seed_common_locales`.
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::dropIfExists('locales');

        DB::table('migrations')
            ->whereIn('migration', [
                '2026_04_21_190002_create_locales_table',
                '2026_05_21_120001_seed_common_locales',
            ])
            ->delete();
    }

    public function down(): void
    {
        // Non-reversible — the original create + seed migration files no
        // longer exist on disk, so we can't rebuild the table from this
        // migration's down(). If you need the admin-managed locales surface
        // back, restore the old migration files from git history and run
        // `migrate:fresh`.
    }
};
