Deusxx1234 commited on
Commit
149bfeb
·
1 Parent(s): 76728fa

fix: run each migration in its own transaction to survive statement timeouts

Browse files
Files changed (1) hide show
  1. src/utils/migrate.py +13 -12
src/utils/migrate.py CHANGED
@@ -161,21 +161,22 @@ _MUSIC_SEED = [
161
  async def run_migrations():
162
  from src.utils.database import engine
163
  from sqlalchemy import text
164
- try:
165
- async with engine.begin() as conn:
166
- for stmt in _VECTOR_MIGRATIONS:
 
167
  await conn.execute(text(stmt))
168
- logger.info("[Migrate] Vector extension and columns applied")
169
- except Exception as e:
170
- logger.warning(f"[Migrate] Vector migrations skipped (pgvector may not be available): {e}")
171
 
172
- try:
173
- async with engine.begin() as conn:
174
- for stmt in _MIGRATIONS:
175
  await conn.execute(text(stmt))
176
- logger.info("[Migrate] Column migrations applied")
177
- except Exception as e:
178
- logger.warning(f"[Migrate] Column migrations skipped (non-fatal): {e}")
179
 
180
  # ivfflat indexes require at least 1 row — best-effort
181
  try:
 
161
  async def run_migrations():
162
  from src.utils.database import engine
163
  from sqlalchemy import text
164
+
165
+ for stmt in _VECTOR_MIGRATIONS:
166
+ try:
167
+ async with engine.begin() as conn:
168
  await conn.execute(text(stmt))
169
+ except Exception as e:
170
+ logger.warning(f"[Migrate] Vector stmt skipped: {e!s:.120}")
171
+ logger.info("[Migrate] Vector extension and columns applied")
172
 
173
+ for stmt in _MIGRATIONS:
174
+ try:
175
+ async with engine.begin() as conn:
176
  await conn.execute(text(stmt))
177
+ except Exception as e:
178
+ logger.warning(f"[Migrate] Stmt skipped (non-fatal): {e!s:.120}")
179
+ logger.info("[Migrate] Column migrations applied")
180
 
181
  # ivfflat indexes require at least 1 row — best-effort
182
  try: