<?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
    {
        // Backstop for the WireGuard allocation lock: two hosts can never share a
        // management IP (nullable → many hosts may still be un-provisioned).
        Schema::table('hosts', function (Blueprint $table) {
            $table->unique('wg_ip');
        });
    }

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