Bug: Migration 037 fails on fresh deploy — enum ADD VALUE in same transaction as INSERT #384
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#384
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
Lineage
Regression from PR #370 which added migration 037. Discovered during CRM incident response 2026-04-07.
Repo
forgejo_admin/basketball-api— file is onmainbranch (remote). Local checkouts may needgit pullto see migrations 031-037 which were merged recently.What Broke
Migration
037_add_monthly_category_and_first_payment_email.pycrashes on fresh deploy with:The migration adds
monthlytoproductcategoryenum AND inserts a row using that value in the same transaction. PostgreSQL requires new enum values to be committed before they can be referenced in DML.Repro Steps
alembic upgrade headALTER TYPE productcategory ADD VALUE 'monthly'thenINSERT ... 'monthly'Expected Behavior
Migration 037 completes successfully on any database state.
Environment
basketball-api-6868cf458d-zc74s(CrashLoopBackOff, 5 restarts before workaround)ALTER TYPE ... ADD VALUEvia psql, pod recoveredAcceptance Criteria
alembic upgrade headsucceeds on a fresh database (no prior migrations)alembic upgrade headsucceeds on existing prod database (workaround already applied —IF NOT EXISTShandles this)Fix (verified pattern)
Standard Alembic pattern for
ADD VALUE— same approach used in migrations 011, 012, 018, 027:File Targets
alembic/versions/037_add_monthly_category_and_first_payment_email.py(on remotemain— agent mustgit pullfirst)Related
westside-basketball— blocked deploy of CRM fixes (#372, #374)Scope Review: NEEDS_REFINEMENT
Review note:
review-889-2026-04-07Well-scoped bug with a known fix pattern, but three items need attention before dispatch:
arch-basketball-apidoes not exist in pal-e-docs. Needs creation for traceability.mainbranch (latest is 030). Clarify which branch contains migrations 031-037, or confirm the agent shouldgit pulllatest main before starting.template-issue-bug(fresh DB upgrade, existing DB upgrade with workaround applied, CI passes).Blast radius is low -- 5 existing enum ADD VALUE migrations all use the isolated pattern. Fix restores established convention. Single file, under 5 minutes.
Scope refinement (post review-889-2026-04-07):
Scope Review: READY (re-review)
Review note:
review-889-2026-04-07All three recommendations from the initial NEEDS_REFINEMENT review have been resolved:
Remaining non-blocking [SCOPE] item: Create architecture note
arch-basketball-apiin pal-e-docs (broad organizational gap, not ticket-specific).Ticket is ready for dispatch.