Spaces:
Running
Running
Commit ·
149bfeb
1
Parent(s): 76728fa
fix: run each migration in its own transaction to survive statement timeouts
Browse files- 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 |
-
|
| 165 |
-
|
| 166 |
-
|
|
|
|
| 167 |
await conn.execute(text(stmt))
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
await conn.execute(text(stmt))
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 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:
|