Conversation
… migration
Two pairs of migration files shared the same revision ID ('031' and '032').
Alembic fails with a duplicate-revision error when it loads the versions
directory, causing `alembic upgrade heads` to exit early. The entrypoint's
`|| echo WARNING` catch silently swallowed this failure, so migration 035
(which adds the `users.oidc_subject` column) never ran — producing the
`UndefinedColumn: users.oidc_subject` crash in production.
Fixes:
- 031_add_direct_download_settings: revision '031' → '031b'
- 032_add_library_mapping_to_booklore_servers: revision '032' → '032b'
- 032_add_flaresolverr_url: down_revision '031' → '031b'
- 034_merge_heads: down_revision includes all four branch heads
('031', '031b', '032b', '033')
- 035_add_oidc_fields: made idempotent (checks column/index existence)
- entrypoint.sh: detect legacy untracked databases and stamp at the
correct revision; fail loudly on migration errors instead of masking them
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
Two pairs of migration files had duplicate
revisionIDs:031_add_direct_download_settings.py031031b032_add_library_mapping_to_booklore_servers.py032032bWhen Alembic loads the
versions/directory it errors on duplicate revision IDs. Theentrypoint.shcaught this with|| echo "WARNING: Alembic migrations had issues"and continued, so migration 035 (which addsusers.oidc_subject) never ran, producing:Changes
031_add_direct_download_settings.py— revision031→031b032_add_flaresolverr_url.py—down_revision031→031b(keeps the direct-download chain intact)032_add_library_mapping_to_booklore_servers.py— revision032→032b034_merge_heads.py— updateddown_revisionto('031', '031b', '032b', '033')so all four branch heads are merged035_add_oidc_fields.py— made idempotent (skipsadd_column/create_indexif they already exist), defensive against databases bootstrapped withcreate_allentrypoint.sh— two improvements:alembic_versiontable and stamps them at the correct revision (034ifoidc_subjectis missing,headsif fully current) before runningupgrade headsexit 1) on migration errors instead of masking themTest plan
034(missingoidc_subject) — migration 035 runs and adds the columnalembic_versionand nooidc_subject— entrypoint stamps at034, then 035+036 run