fix(migrations): idempotent schema helpers so drift can't crash startup #13
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/reliability-hardening"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A database whose schema had drifted from the recorded migration history
crashed the entire app at boot: several migrations issued bare or
inconsistently-guarded
ALTER TABLE ... ADD COLUMNstatements, which raiseduplicate column namewhen the column is already present (restored backup,out-of-band change, interrupted earlier run). The runner re-raises to avoid
serving a half-migrated schema, so one already-applied column took the whole
service down — surfacing only as an opaque gunicorn traceback.
add_column,create_index,table_exists, andcolumn_names.add_columnno-ops when the columnexists and defensively swallows SQLite's
duplicate column name, but stillraises loudly if the target table is missing (a real ordering bug).
009 (
ALTER TABLE user ADD COLUMN api_token_hash) and replaces theover-broad
contextlib.suppress(Exception)in 005/007 (which also hidunrelated errors) with the targeted helper.
failure (which DB, which migration, how to recover) instead of a bare trace.
re-run, and a drift case (pre-existing
notescolumn) that reproduces theexact production failure.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com