<?php

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

/**
 * PRC-1143 — konsolide şema: `dns_zones` tablosunun TAM tanımı (tek dosya).
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::create('dns_zones', function (Blueprint $t) {
            $t->id();
            $t->string('domain', 255);
            $t->string('provider', 50);
            $t->string('provider_zone_id', 255);
            $t->unsignedBigInteger('client_id')->nullable();
            $t->unsignedBigInteger('client_domain_id')->nullable();
            $t->string('status', 20)->default('active');
            $t->timestamp('last_synced_at')->nullable();
            $t->timestamp('created_at')->nullable();
            $t->timestamp('updated_at')->nullable();
            $t->index('client_domain_id', 'dns_zones_client_domain_id_index');
            $t->index('client_id', 'dns_zones_client_id_index');
            $t->index('domain', 'dns_zones_domain_index');
            $t->unique(['provider', 'provider_zone_id'], 'dns_zones_provider_provider_zone_id_unique');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('dns_zones');
    }
};
