gabriel / musehub public
fix patch fix/schema-gate-asyncpg #1 / 1
AI Agent gabriel · 22 hours ago · Oct 21, 2026 · Diff

fix: deploy-time schema gate used a sync driver not guaranteed to exist

schema_gate.py (run during every deploy, see deploy/deploy.sh step 2) built its own sync create_engine() against a '+asyncpg'-stripped DATABASE_URL, relying on SQLAlchemy's default postgresql dialect resolution to land on psycopg2. On the current runtime image that resolution instead picked the psycopg (v3) dialect, whose package isn't installed (requirements.txt only has psycopg2-binary) -- ModuleNotFoundError: No module named 'psycopg', hard-blocking every deploy. This had been latent for a month: the last staging deploy predates this file by enough that it was never actually exercised until today.

alembic/env.py already solved exactly this problem for actual migrations: create_async_engine() against the full asyncpg URL, then connection.run_sync() to bridge into Alembic's sync-style API. schema_gate needed the identical bridge for compare_metadata -- it was just missing.

Verified locally against the running musehub_postgres container: passes clean (73 tables in sync) and correctly fails when a real drift column is added, confirming the gate still catches genuine ORM/migration drift, not just a driver import that no longer throws.

sha256:1a5904eb08c0aa4a4e633dc07272300d69dd2502f45a2534e1028d960e24783c sha
+2 ~1 symbols
1 changed · 1084 in snapshot files
sha256:d91083ec8d09faeb4949c41aa91cc2f058d7617a75c10a5ba67139c8f374eb3c snapshot
+2
symbols added
~1
symbol modified
1
file changed
1084
files in snapshot
0
dead code introduced
Semantic Changes 3 symbols
~ musehub/db/schema_gate.py .py 2 symbols added, 1 symbol modified
+ _compare_metadata_sync function function _compare_metadata_sync L48–53
+ _run_gate function async_function _run_gate L56–86
~ main
Files Changed
~1
1084 in snapshot
← Older Oldest on fix/schema-gate-asyncpg
All commits
Newer → Latest on fix/schema-gate-asyncpg

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:1a5904eb08c0aa4a4e633dc07272300d69dd2502f45a2534e1028d960e24783c --body "your comment"