-- V001: ai_llm_providers
-- LLM 프로바이더 테이블 (anthropic/openai/google/deepseek/ollama)

CREATE TABLE ai_llm_providers (
    id                   BIGSERIAL PRIMARY KEY,
    name                 VARCHAR(50) NOT NULL UNIQUE,
    display_name         VARCHAR(200) NOT NULL,
    api_key_encrypted    TEXT NOT NULL,
    model_name           VARCHAR(100) NOT NULL,
    endpoint             VARCHAR(500),
    priority             INTEGER NOT NULL DEFAULT 1,
    max_tokens           INTEGER NOT NULL DEFAULT 4096,
    temperature          NUMERIC(3,2) NOT NULL DEFAULT 0.70,
    cost_per_1k_input    NUMERIC(10,6) NOT NULL DEFAULT 0,
    cost_per_1k_output   NUMERIC(10,6) NOT NULL DEFAULT 0,
    is_active            BOOLEAN NOT NULL DEFAULT TRUE,
    config               JSONB NOT NULL DEFAULT '{}'::jsonb,
    created_at           TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    updated_at           TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE INDEX idx_providers_priority ON ai_llm_providers (priority);
CREATE INDEX idx_providers_active   ON ai_llm_providers (is_active);
