-- Admin-curated list of LLM providers and their available models.
-- The admin configures which providers/models are available for users to select.
-- User API keys are stored separately (see Phase 4).

CREATE TABLE admin_providers (
    id              UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    provider_name   VARCHAR(50)  NOT NULL UNIQUE,
    display_name    VARCHAR(100) NOT NULL,
    models          JSONB        NOT NULL DEFAULT '[]'::jsonb,
    is_enabled      BOOLEAN      NOT NULL DEFAULT true,
    created_at      TIMESTAMPTZ  NOT NULL DEFAULT now(),
    updated_at      TIMESTAMPTZ  NOT NULL DEFAULT now()
);

-- Index for public config endpoint: only return enabled providers
CREATE INDEX idx_admin_providers_enabled ON admin_providers(is_enabled) WHERE is_enabled = true;

-- Seed the three supported providers with their default models
INSERT INTO admin_providers (provider_name, display_name, models) VALUES
    ('gemini', 'Google Gemini', '[
        {"model_id": "gemini-2.5-pro", "display_name": "Gemini 2.5 Pro", "is_default": true},
        {"model_id": "gemini-2.5-flash", "display_name": "Gemini 2.5 Flash", "is_default": false}
    ]'::jsonb),
    ('openai', 'OpenAI', '[
        {"model_id": "gpt-4o", "display_name": "GPT-4o", "is_default": true},
        {"model_id": "gpt-4o-mini", "display_name": "GPT-4o Mini", "is_default": false}
    ]'::jsonb),
    ('anthropic', 'Anthropic', '[
        {"model_id": "claude-sonnet-4-20250514", "display_name": "Claude Sonnet 4", "is_default": true},
        {"model_id": "claude-haiku-3-5-20241022", "display_name": "Claude Haiku 3.5", "is_default": false}
    ]'::jsonb);
