<?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('settings_catalog_definitions', function (Blueprint $table) {
            $table->id();
            $table->string('definition_id', 500)->unique();
            $table->string('display_name');
            $table->text('description')->nullable();
            $table->text('help_text')->nullable();
            $table->string('category_id')->nullable();
            $table->string('ux_behavior', 100)->nullable();
            $table->jsonb('raw');
            $table->timestamps();

            // Indexes
            $table->index('definition_id');
            $table->index('category_id');
            // GIN index for JSONB (PostgreSQL)
            $table->rawIndex('raw', 'idx_settings_catalog_definitions_raw_gin', 'gin');
        });
    }

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