<?php

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

/**
 * PRC-1143 — konsolide şema: `tlds` tablosunun TAM tanımı (tek dosya).
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::create('tlds', function (Blueprint $t) {
            $t->id();
            $t->string('tld', 255);
            $t->enum('status', ['active','inactive'])->default('active');
            $t->string('registrar', 255)->nullable()->default('email');
            $t->boolean('dns_management')->default(0);
            $t->boolean('email_forwarding')->default(0);
            $t->boolean('id_protection')->default(0);
            $t->boolean('epp_code')->default(1);
            $t->integer('min_chars')->nullable();
            $t->integer('max_chars')->nullable();
            $t->integer('grace_period')->nullable();
            $t->decimal('grace_period_fee', 10, 2)->nullable();
            $t->integer('redemption_period')->nullable();
            $t->decimal('redemption_period_fee', 10, 2)->nullable();
            $t->unsignedInteger('currency_id')->nullable();
            $t->integer('min_years')->default(1);
            $t->integer('max_years')->default(10);
            $t->boolean('instant_registration')->default(0);
            $t->text('description')->nullable();
            $t->json('labels')->nullable();
            $t->integer('order')->default(1);
            $t->boolean('adaptive_pricing')->default(1);
            $t->boolean('premium')->default(0);
            $t->string('whois_provider', 255)->nullable()->default('public');
            $t->string('lookup_provider', 255)->nullable()->default('public');
            $t->timestamp('created_at')->nullable();
            $t->timestamp('updated_at')->nullable();
            $t->unique('tld', 'tlds_tld_unique');
        });
    }

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