<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
use Maestro\Core\Models\NavigationNode;

/**
 * Legacy nav pointed "Installatiecontrole" at /superadmin/setup which redirected to Modules.
 */
return new class extends Migration
{
    public function up(): void
    {
        if (! Schema::hasTable('maestro_navigation_nodes')) {
            return;
        }

        NavigationNode::query()
            ->where('key', 'superadmin-installation-health')
            ->where('route', '/superadmin/setup')
            ->update(['route' => '/superadmin/installation-health']);
    }

    public function down(): void
    {
        if (! Schema::hasTable('maestro_navigation_nodes')) {
            return;
        }

        NavigationNode::query()
            ->where('key', 'superadmin-installation-health')
            ->where('route', '/superadmin/installation-health')
            ->update(['route' => '/superadmin/setup']);
    }
};
