summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-01-22 08:31:06 +0100
committerRory& <root@rory.gay>2026-01-22 08:31:06 +0100
commitb3a595f25d0a99fcd440e3a7c2013abaf1a07074 (patch)
tree9620973a1b438ef87cb52bdb056ba5b55dcdde00
parentNix: dont set after/requires at all (diff)
downloadserver-ts-b3a595f25d0a99fcd440e3a7c2013abaf1a07074.tar.xz
Apply-migrations: retry
-rw-r--r--src/apply-migrations.ts24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/apply-migrations.ts b/src/apply-migrations.ts

index 94f86320..d43f67bf 100644 --- a/src/apply-migrations.ts +++ b/src/apply-migrations.ts
@@ -10,8 +10,22 @@ process.env.DB_LOGGING = "true"; import { closeDatabase, initDatabase } from "@spacebar/util"; -initDatabase().then(() => { - closeDatabase().then((r) => { - console.log("Successfully applied migrations!"); - }); -}); +async function main() { + let success = false; + while (!success) { + try { + await initDatabase().then(async () => { + await closeDatabase().then(async () => { + console.log("Successfully applied migrations!"); + success = true; + }); + }); + } catch (e) { + console.error("Failed to apply migrations, retrying in 2s...", e); + await new Promise((res) => setTimeout(res, 2000)); + await main(); + } + } +} + +main().then((r) => console.log("meow"));