<?php

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

/**
 * PRC-1143 — konsolide şema: `dns_records` tablosunun TAM tanımı (tek dosya).
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::create('dns_records', function (Blueprint $t) {
            $t->id();
            $t->unsignedBigInteger('zone_id');
            $t->string('provider_record_id', 255)->nullable();
            $t->string('type', 10);
            $t->string('name', 255);
            $t->text('content');
            $t->unsignedInteger('ttl')->default(3600);
            $t->unsignedSmallInteger('priority')->nullable();
            $t->boolean('proxied')->default(0);
            $t->timestamp('created_at')->nullable();
            $t->timestamp('updated_at')->nullable();
            $t->index(['zone_id', 'type', 'name'], 'dns_records_zone_id_type_name_index');
            $t->foreign('zone_id', 'dns_records_zone_id_foreign')->references('id')->on('dns_zones')->onDelete('cascade');
        });
    }

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