Fix migration transaction poisoning: ADD COLUMN IF NOT EXISTS

Migrations used try/except around ADD COLUMN inside a single engine.begin()
block. When a 'column already exists' error was caught, asyncpg left the
transaction in aborted state, causing all subsequent DDL in the block to fail
with InFailedSQLTransactionError. Replace with IF NOT EXISTS to prevent the
error entirely.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-12 19:53:26 +00:00
parent e7e1fda9f6
commit bc874ac9ff
25 changed files with 302 additions and 302 deletions

View file

@ -27,8 +27,8 @@ async def run_migration():
logger.info("Running Resos manual breakfast configuration migration...")
migrations = [
"ALTER TABLE kitchen_settings ADD COLUMN resos_enable_manual_breakfast BOOLEAN DEFAULT FALSE",
"ALTER TABLE kitchen_settings ADD COLUMN resos_manual_breakfast_periods JSONB"
"ALTER TABLE kitchen_settings ADD COLUMN IF NOT EXISTS resos_enable_manual_breakfast BOOLEAN DEFAULT FALSE",
"ALTER TABLE kitchen_settings ADD COLUMN IF NOT EXISTS resos_manual_breakfast_periods JSONB"
]
async with engine.begin() as conn: