<?php

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

return new class extends Migration
{
    /**
     * The panel domain moved from a dashboard Setting to the install-time APP_DOMAIN
     * (kept consistent with APP_URL, the Reverb endpoint, cookie security and Caddy's
     * auto-TLS — none safely re-derivable at runtime, since Caddy's site address and the
     * browser's Reverb host are fixed at install/build and .env is never rewritten).
     *
     * We remove ONLY the inert empty rows that the old write-path left behind — any
     * non-empty value an operator actually configured is preserved as a historical
     * record (it is no longer read). To run such a domain under the new model, set it via
     * install.sh (re-run); see CHANGELOG.
     */
    public function up(): void
    {
        DB::table('settings')
            ->whereIn('key', ['dashboard_domain', 'dashboard_email'])
            ->where(function ($q) {
                $q->whereNull('value')->orWhere('value', '');
            })
            ->delete();
    }

    public function down(): void
    {
        // No-op: these settings are obsolete and intentionally not recreated.
    }
};
