Files
pablan/backend/alembic/versions/a71e3c92fd45_llm_settings_provenance.py
T
ProfessorNovaandClaude Opus 5 97dbff309c Pablan, as it stands
Self-hosted knowledge management for SMEs: a split-screen Markdown editor
whose sections an LLM refines while you write, and RAG question answering
over the documents that result. FastAPI + Postgres/pgvector on the back,
SvelteKit on the front, everything OpenAI-compatible and self-hostable.

Squashed into a single commit; the development history stays local.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CA43ZJda8Rbp2hKXNy8f6b
2026-09-04 08:36:17 +02:00

53 lines
1.6 KiB
Python

"""llm settings field provenance
Revision ID: a71e3c92fd45
Revises: 9f4a71c60d38
Create Date: 2026-07-20 18:07:44.902113
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "a71e3c92fd45"
down_revision: Union[str, Sequence[str], None] = "9f4a71c60d38"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
_FIELDS = ("base_url", "model", "api_key")
def upgrade() -> None:
"""Upgrade schema."""
# The table changed meaning: it used to hold sparse per-field overrides
# on top of the environment, and now holds the full configuration,
# seeded from the environment once at first start.
for field in _FIELDS:
op.add_column(
"llm_settings",
sa.Column(
f"{field}_from_env",
sa.Boolean(),
server_default=sa.false(),
nullable=False,
),
)
# The table changed meaning: it used to hold sparse per-field overrides
# on top of the environment, and now holds the full configuration,
# seeded from the environment at startup. Pre-existing rows are dev
# leftovers — nothing is in production yet, so they are dropped rather
# than translated, and `bootstrap_llm_settings()` recreates them from
# `.env` on the next start.
op.execute("DELETE FROM llm_settings")
def downgrade() -> None:
"""Downgrade schema."""
for field in _FIELDS:
op.drop_column("llm_settings", f"{field}_from_env")