From 67c6c156e388e58a23376e4a65f978b091307b03 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 7 Jun 2024 18:31:40 +0100 Subject: [PATCH] Updating logging for app migration. --- .../src/appMigrations/migrationsProcessor.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/server/src/appMigrations/migrationsProcessor.ts b/packages/server/src/appMigrations/migrationsProcessor.ts index 9945ce4f66..0ca923230f 100644 --- a/packages/server/src/appMigrations/migrationsProcessor.ts +++ b/packages/server/src/appMigrations/migrationsProcessor.ts @@ -20,8 +20,8 @@ export async function processMigrations( resource: appId, }, async () => { - try { - await context.doInAppMigrationContext(appId, async () => { + await context.doInAppMigrationContext(appId, async () => { + try { let currentVersion = await getAppMigrationVersion(appId) const pendingMigrations = migrations @@ -36,7 +36,9 @@ export async function processMigrations( migrationIds[migrationIds.indexOf(currentVersion) + 1] if (expectedMigration !== id) { - throw `Migration ${id} could not run, update for "${id}" is running but ${expectedMigration} is expected` + throw new Error( + `Migration ${id} could not run, update for "${id}" is running but ${expectedMigration} is expected` + ) } const counter = `(${++index}/${pendingMigrations.length})` @@ -51,11 +53,11 @@ export async function processMigrations( }) currentVersion = id } - }) - } catch (err) { - logging.logAlert("Failed to run app migration", err) - throw err - } + } catch (err) { + logging.logAlert("Failed to run app migration", err) + throw err + } + }) } )