<?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('domain_costs', function (Blueprint $table) {
            $table->id();
            // TLD foreign key
            $table->unsignedBigInteger('tld_id');
            // Registrar adı (metinsel)
            $table->string('registrar')->nullable();
            // Aktif/Pasif
            $table->boolean('is_active')->default(true);
            // Ek bilgiler (örn: registrar API bilgileri)
            $table->json('metadata')->nullable();
            $table->timestamps();
            $table->softDeletes();

            // Indexes
            $table->index(['tld_id', 'is_active']);
            $table->index(['registrar', 'is_active']);

            // Benzersiz: aynı TLD + registrar için tek kayıt (currency artık pricing'de)
            $table->unique(['tld_id', 'registrar'], 'unique_domain_cost');
        });
    }

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