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
|
|
@ -112,7 +112,7 @@ async def migrate():
|
|||
# Add cost_distribution_max_days to kitchen_settings
|
||||
try:
|
||||
await conn.execute(text(
|
||||
"ALTER TABLE kitchen_settings ADD COLUMN cost_distribution_max_days INTEGER DEFAULT 90"
|
||||
"ALTER TABLE kitchen_settings ADD COLUMN IF NOT EXISTS cost_distribution_max_days INTEGER DEFAULT 90"
|
||||
))
|
||||
print("+ Added cost_distribution_max_days to kitchen_settings")
|
||||
except Exception as e:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue