-- Tabla de organizaciones
CREATE TABLE IF NOT EXISTS llm_orgs (
    id          TEXT PRIMARY KEY,
    name        TEXT NOT NULL,
    doc         TEXT,
    updated_at  INTEGER NOT NULL DEFAULT (strftime('%s','now'))
);

-- Tabla de modelos
CREATE TABLE IF NOT EXISTS llm_models (
    id                  TEXT NOT NULL,
    org_id              TEXT NOT NULL,
    name                TEXT NOT NULL,
    description         TEXT,
    cost_in             REAL NOT NULL DEFAULT 0,
    cost_out            REAL NOT NULL DEFAULT 0,
    release_date        INTEGER,
    last_update_date    INTEGER,
    flags               INTEGER NOT NULL DEFAULT 0,
    in_modals           INTEGER NOT NULL DEFAULT 0,
    out_modals          INTEGER NOT NULL DEFAULT 0,
    context_window      INTEGER,
    context_output      INTEGER,
    context_input       INTEGER,
    updated_at          INTEGER NOT NULL DEFAULT (strftime('%s','now')),
    PRIMARY KEY (id, org_id), 
    FOREIGN KEY (org_id) REFERENCES llm_orgs(id) ON DELETE CASCADE
);

-- Tabla de modelos
CREATE TABLE IF NOT EXISTS charts_id (
  chart_id  INTEGER PRIMARY KEY
);



-- Índices útiles
CREATE INDEX IF NOT EXISTS idx_llm_models_org ON llm_models(org_id);
CREATE INDEX IF NOT EXISTS idx_llm_models_updated ON llm_models(updated_at);
CREATE INDEX IF NOT EXISTS idx_llm_orgs_updated ON llm_orgs(updated_at);