Skip to content

fix(db): DATABASE_URL fallback and alembic baseline squash - #20

Merged
SrStamm merged 1 commit into
mainfrom
fix/db-bootstrap
Oct 20, 2026
Merged

SrStamm merged 1 commit into
mainfrom
fix/db-bootstrap

Conversation

@SrStamm

@SrStamm SrStamm commented Oct 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • db/database.py: build the engine URL from POSTGRES_* vars when DATABASE_URL is unset (precedence already documented in the README); raise a clear RuntimeError naming the missing vars when neither source is available
  • Replace the shared sessionlocal instance with the SessionLocal factory in tasks.py and core/socket_manager.py — per-call sessions, Celery-worker-safe; drop the eager module-level Session(engine)
  • Alembic: the 17 existing migrations were unusable on a fresh DB (two disconnected root chains, no migration ever created the base tables, one add_column on a non-existent table). Squashed into a single baseline (1045577547bf) matching the current models; legacy migrations preserved in alembic/legacy/versions/ for reference

Testing

  • alembic upgrade head on a fresh Postgres container: OK
  • App boots and the front (WS + notifications) works against the rebuilt DB
  • Full suite: 169 passed (Redis up)

- Build engine URL from POSTGRES_* vars when DATABASE_URL is unset,
  with a clear RuntimeError when neither source is available
- Replace shared sessionlocal instance with SessionLocal factory in
  tasks.py and socket_manager.py (per-call sessions, worker-safe)
- Squash 17 broken migration chains (two disconnected roots, no base
  tables) into a single 0001-style baseline matching current models;
  legacy migrations moved to alembic/legacy/versions/ for reference
@SrStamm
SrStamm merged commit ad76148 into main Oct 20, 2026
1 check passed
@SrStamm
SrStamm deleted the fix/db-bootstrap branch October 20, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant