• Aryan Noshirvnai's avatar
    Move prod's primary datastore from SQLite to PostgreSQL · 4b5c72cd
    Aryan Noshirvnai authored
    SQLite was only ever meant for testing; prod now has real concurrent
    features (Rooms/DM chat, websockets) that benefit from proper
    multi-writer concurrency. Migrations were already dialect-agnostic (no
    op.batch_alter_table or sqlite_* kwargs anywhere), so this was a clean
    schema-only cutover - prod had zero real users, so nothing needed
    migrating, just a fresh `alembic upgrade head` against an empty Postgres
    database.
    
    Also fixed two real SQLite-only assumptions in database.py that the
    Postgres cutover exposed: `connect_args={"check_same_thread": False}`
    applied unconditionally (psycopg has no such option and raises on it),
    and the db-directory-creation logic ran DATABASE_URL through a
    sqlite-only string replace regardless of dialect. Both now scoped to an
    `_is_sqlite` check, matching the existing WAL-pragma guard.
    
    deploy.sh's automated .env regeneration path also had a silent
    `sqlite:///...` fallback for DATABASE_URL - removed in favor of a hard
    failure (same posture as JWT_SECRET) so a future CI deploy can never
    quietly revert prod back to SQLite by omission.
    
    Redis was considered (explicitly asked about) and deliberately not
    added: the only in-memory real-time state in Rooms/DMs is live
    WebSocket objects (can't live in Redis regardless, tied to one
    process's event loop) and small per-room ephemeral lists already
    documented as intentionally discardable - Redis's actual value only
    appears once there's more than one backend process, which isn't the
    case yet.
    Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
    4b5c72cd
database.py 29.7 KB