fix: pr comment

This commit is contained in:
pablo 2025-08-18 16:40:58 +03:00
parent faadd4f68c
commit faefaa7966
No known key found for this signature in database
GPG Key ID: 78F35FCC60FDC63A

View File

@ -32,10 +32,15 @@ proc runMigrations*(db: DbConn, dir = "migrations") =
else:
info "Applying migration", file
let sqlContent = readFile(file)
# Split by semicolon and execute each statement separately
let statements = sqlContent.split(';')
for stmt in statements:
let trimmedStmt = stmt.strip()
if trimmedStmt.len > 0:
db.exec(sql(trimmedStmt))
markMigrationRun(db, file)
db.exec(sql"BEGIN TRANSACTION")
try:
# Split by semicolon and execute each statement separately
for stmt in sqlContent.split(';'):
let trimmedStmt = stmt.strip()
if trimmedStmt.len > 0:
db.exec(sql(trimmedStmt))
markMigrationRun(db, file)
db.exec(sql"COMMIT")
except:
db.exec(sql"ROLLBACK")
raise newException(ValueError, "Migration failed: " & file & " - " & getCurrentExceptionMsg())