From b3a595f25d0a99fcd440e3a7c2013abaf1a07074 Mon Sep 17 00:00:00 2001 From: Rory& Date: Thu, 22 Jan 2026 08:31:06 +0100 Subject: [PATCH] Apply-migrations: retry --- src/apply-migrations.ts | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/apply-migrations.ts b/src/apply-migrations.ts index 94f86320e..d43f67bf4 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"));