mirror of
https://github.com/spacebarchat/server.git
synced 2026-05-25 05:55:34 +00:00
Apply-migrations: retry
This commit is contained in:
+19
-5
@@ -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"));
|
||||
|
||||
Reference in New Issue
Block a user