<?php

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

return new class extends Migration
{
    public function up(): void
    {
        // One physical server = one host record: prevents two onboarding runs
        // from fighting over the same machine's SSH/WireGuard/token config.
        Schema::table('hosts', function (Blueprint $table) {
            $table->unique('public_ip');
        });
    }

    public function down(): void
    {
        Schema::table('hosts', function (Blueprint $table) {
            $table->dropUnique(['public_ip']);
        });
    }
};
