fix: move SET LOCAL inside transaction in quotation/media/comms migration scripts

This commit is contained in:
2026-04-17 15:15:43 +03:00
parent 4c2400b596
commit a7b73b0564
4 changed files with 5 additions and 10 deletions

View File

@@ -63,13 +63,12 @@ async def run() -> None:
})
async with AsyncPgSession() as session:
await session.execute(text("SET session_replication_role = replica"))
async with session.begin():
await session.execute(text("SET LOCAL session_replication_role = replica"))
stmt = pg_insert(CrmQuotationItem).values(records)
stmt = stmt.on_conflict_do_nothing(index_elements=["id"])
await session.execute(stmt)
dest_count = await pg_count(session, "crm_quotation_items")
await session.execute(text("SET session_replication_role = DEFAULT"))
if dest_count < source_count:
msg = f"Count mismatch: source={source_count} postgres={dest_count}"