Move prod's primary datastore from SQLite to PostgreSQL
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:
Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
Showing
| ... | ... | @@ -14,6 +14,8 @@ websockets>=13.0 # uvicorn's WebSocket protocol implementation - without this, |
| # silently has no WebSocket support at all (no error, connections just | ||
| # fail); needed for the Pass-the-Aux room websocket routes | ||
| sqlalchemy>=2.0.0 | ||
| psycopg[binary]>=3.1 # Postgres driver - prod runs Postgres, the test suite stays on SQLite's | ||
| # stdlib sqlite3 (needs nothing added) so this is additive, not a swap. | ||
| httpx>=0.27.0 | ||
| python-multipart>=0.0.9 | ||
| pytest>=8.0.0 | ||
| ... | ... |
Please
register
or
sign in
to comment