<?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('ai_configs', function (Blueprint $table) {
            $table->id();
            $table->string('name', 50)->comment('설정 이름 (Gemini, Claude 등)');
            $table->string('provider', 30)->comment('제공자 (gemini, claude, openai)');
            $table->string('api_key', 255)->comment('API 키');
            $table->string('model', 100)->comment('모델명 (gemini-2.0-flash 등)');
            $table->string('base_url', 255)->nullable()->comment('API Base URL');
            $table->text('description')->nullable()->comment('설명');
            $table->boolean('is_active')->default(false)->comment('활성화 여부 (provider당 1개만 활성화)');
            $table->json('options')->nullable()->comment('추가 옵션 (JSON)');
            $table->timestamps();
            $table->softDeletes();

            $table->index('provider');
            $table->index(['provider', 'is_active']);
        });
    }

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