<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('dns_zone_nameserver', function (Blueprint $table) {
            $table->id();
            $table->foreignId('dns_zone_id')->constrained()->onDelete('cascade');
            $table->foreignId('name_server_id')->constrained()->onDelete('cascade');
            $table->string('powerdns_zone_id')->nullable(); // ID-ul zonei pe acest nameserver specific
            $table->boolean('is_synced')->default(false);
            $table->timestamp('last_synced_at')->nullable();
            $table->timestamps();
            
            // Un nameserver poate avea o singură instanță a unei zone
            $table->unique(['dns_zone_id', 'name_server_id']);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('dns_zone_nameserver');
    }
};
