Fix Alembic multiple heads — migration branch conflict #337
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/basketball-api#337
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Type
Bug
User Story
story:WS-S1As superadmin, I want to deploy platform changes via IaC so that infrastructure is reproducible and auditable.What Broke
basketball-api pod is in CrashLoopBackOff. On startup, Alembic runs
upgrade headand fails because multiple head revisions exist. The numbered migration scheme (023-030) has a branch conflict with a hash-named migration (e09c9e678004_add_division_column_to_players.py).Repro Steps
alembic upgrade headExpected Behavior
alembic upgrade headsucceeds with exactly 1 head. Pod starts normally.Environment
alembic/versions/e09c9e678004Lineage
story:WS-S1arch:basketball-apiRepo
forgejo_admin/basketball-apiContext
The crash pre-existed but was masked by the previous pod staying alive. PR #334 merge triggered a new deployment which restarted the pod and exposed it.
File Targets
alembic/versions/— identify the two head revisions, runalembic merge headsalembic/versions/e09c9e678004_add_division_column_to_players.py— likely branch pointAcceptance Criteria
alembic headsreturns exactly 1 headalembic upgrade headsucceedsTest Expectations
alembic checkpassesConstraints
Checklist
alembic merge headsRelated
Scope Review: READY
Review note:
review-819-2026-04-04Ticket is fully scoped with verified file targets, complete traceability, and concrete acceptance criteria. Root cause confirmed: migration
e09c9e678004forks from revision005, creating two heads (030ande09c9e678004). Single-repo fix, estimated 2-3 min agent time. Ready for dispatch.Resolution: Already fixed by PR #338
Investigation confirms this issue was already resolved by PR #338 (
fix: resolve alembic migration chain conflict (031 → 031/032/033)), which was merged as commit9e81e6d.Root cause (corrected)
The scope review identified
e09c9e678004forking from revision005as the root cause, but that was incorrect. Migration007has always haddown_revision = "e09c9e678004"since its creation (commit8ed1380), making the chain005 → e09c9e678004 → 007linear with no fork.The actual root cause was two separate migrations both claiming revision ID
031withdown_revision = "030":031_add_contract_overrides_to_players.py031_add_contract_email_type_enum_values.pyThese were introduced by PRs #335 and #336 merging independently, each branching from
030.Verification
Current
origin/main(commit8d0eac3):alembic headsreturns exactly 1 head:035001 → ... → 005 → e09c9e678004 → 007 → ... → 030 → 031 → 032 → 033 → 034 → 035001Timeline
031revisions → multiple heads032and033No further code changes needed. Closing as resolved.
Validation: PASS
Tiers executed: Tier 1 (local), Tier 3 (prod)
Validation note:
validation-337-2026-04-05b5 checks: 5 PASS, 0 FAIL
alembic headsreturns exactly 1 head035, chain linearizedalembic upgrade headsucceeds/healthzreturns{"status":"ok"}Regression check:
/docs,/public/schedule,/metricsall 200. Keycloak JWKS fetch OK. No error logs.