mirror of
https://github.com/logos-messaging/nim-chat-sdk.git
synced 2026-01-03 22:53:12 +00:00
fix: pr comment
This commit is contained in:
parent
faadd4f68c
commit
faefaa7966
@ -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())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user