fix: commit enum ADD VALUE before INSERT in migration 037 #386
No reviewers
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!386
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "384-fix-migration-037-enum-transaction"
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?
Summary
Migration 037 fails on fresh deploy because PostgreSQL cannot use newly added enum values within the same transaction that added them. This fix uses the established COMMIT/BEGIN pattern to commit enum additions before referencing them in the INSERT.
Changes
alembic/versions/037_add_monthly_category_and_first_payment_email.py— Addedimport sqlalchemy as sa, replaced bareop.executefor ALTER TYPE withconn.execute(sa.text(...))wrapped in explicit COMMIT/BEGIN to flush enum values before use.Test Plan
ast.parseverified)IF NOT EXISTSmakes it idempotent (safe for prod where workaround already applied)Review Checklist
IF NOT EXISTSRelated Notes
None.
Related
QA Review
Scope: 1 file, 7 additions, 3 deletions. Migration 037 fix for enum ADD VALUE + INSERT in same transaction.
Findings:
sa.text()wrapping is correct forconn.execute()(SQLAlchemy 2.x requires text objects).IF NOT EXISTSensures idempotency -- safe to run on prod where the workaround was already applied manually.import sqlalchemy as saadded correctly.No issues found.
VERDICT: APPROVED