Apply-migrations: retry

This commit is contained in:
Rory&
2026-01-22 08:31:06 +01:00
parent d8e2870e54
commit b3a595f25d
+19 -5
View File
@@ -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"));