<?php

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

/**
 * PRC-1143 — konsolide şema: `product_config_options` tablosunun TAM tanımı (tek dosya).
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::create('product_config_options', function (Blueprint $t) {
            $t->id();
            $t->unsignedInteger('group_id');
            $t->string('name', 255);
            $t->text('description')->nullable();
            $t->enum('type', ['number','select','checkboxgroup','checkbox','text','ip_address'])->default('select');
            $t->integer('minimum')->nullable();
            $t->integer('maximum')->nullable();
            $t->json('values');
            $t->unsignedBigInteger('ip_pool_override_id')->nullable();
            $t->integer('order')->default(1);
            $t->boolean('hidden')->default(0);
            $t->boolean('is_required')->default(0);
            $t->boolean('adaptive_term_pricing')->default(0);
            $t->timestamp('archived_at')->nullable();
            $t->timestamp('created_at')->nullable();
            $t->timestamp('updated_at')->nullable();
            $t->index('archived_at', 'idx_pco_archived_at');
            $t->index('ip_pool_override_id', 'product_config_options_ip_pool_override_id_foreign');
            $t->foreign('ip_pool_override_id', 'product_config_options_ip_pool_override_id_foreign')->references('id')->on('ip_pools')->onDelete('set null');
        });
    }

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