fix: revert created migration if create-and-run fails to run

This commit is contained in:
Diego Imbert
2026-06-17 19:27:17 +02:00
parent 2f15f39f41
commit 84078f33ce
@@ -63,11 +63,26 @@
}
})
if (run) {
await WorkspaceService.runDatatableMigrations({
workspace,
datatableName: datatable,
upTo: created.timestamp
})
try {
await WorkspaceService.runDatatableMigrations({
workspace,
datatableName: datatable,
only: created.timestamp
})
} catch (runErr: any) {
// The migration was created but failed to run; undo the insertion so
// the user can fix the SQL and retry from a clean state.
await WorkspaceService.deleteDatatableMigration({
workspace,
datatableName: datatable,
timestamp: created.timestamp
}).catch(() => {})
sendUserToast(
`Migration failed to run and was reverted: ${runErr?.body ?? runErr?.message ?? runErr}`,
true
)
return
}
}
isOpen = false
sendUserToast(run ? 'Migration created and run' : 'Migration created')