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:
parent
e7e1fda9f6
commit
bc874ac9ff
25 changed files with 302 additions and 302 deletions
|
|
@ -23,7 +23,7 @@ async def migrate():
|
|||
for col_name, col_type in COLUMNS:
|
||||
try:
|
||||
await conn.execute(text(
|
||||
f"ALTER TABLE kitchen_settings ADD COLUMN {col_name} {col_type}"
|
||||
f"ALTER TABLE kitchen_settings ADD COLUMN IF NOT EXISTS {col_name} {col_type}"
|
||||
))
|
||||
print(f"+ Added {col_name} column to kitchen_settings")
|
||||
except Exception as e:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue