From c328dd5cd43f41872981d619960811bb67db46c2 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 10 Jun 2024 18:32:06 +0100 Subject: [PATCH] Making sure any error that occurs in the app migration system gets logged. --- .../src/appMigrations/migrationsProcessor.ts | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/server/src/appMigrations/migrationsProcessor.ts b/packages/server/src/appMigrations/migrationsProcessor.ts index badd50f53c..d4f474cd30 100644 --- a/packages/server/src/appMigrations/migrationsProcessor.ts +++ b/packages/server/src/appMigrations/migrationsProcessor.ts @@ -12,16 +12,16 @@ export async function processMigrations( migrations: AppMigration[] ) { console.log(`Processing app migration for "${appId}"`) - // have to wrap in context, this gets the tenant from the app ID - await context.doInAppContext(appId, async () => { - await locks.doWithLock( - { - name: LockName.APP_MIGRATION, - type: LockType.AUTO_EXTEND, - resource: appId, - }, - async () => { - try { + try { + // have to wrap in context, this gets the tenant from the app ID + await context.doInAppContext(appId, async () => { + await locks.doWithLock( + { + name: LockName.APP_MIGRATION, + type: LockType.AUTO_EXTEND, + resource: appId, + }, + async () => { await context.doInAppMigrationContext(appId, async () => { let currentVersion = await getAppMigrationVersion(appId) @@ -55,13 +55,13 @@ export async function processMigrations( currentVersion = id } }) - } catch (err) { - logging.logAlert("Failed to run app migration", err) - throw err } - } - ) + ) - console.log(`App migration for "${appId}" processed`) - }) + console.log(`App migration for "${appId}" processed`) + }) + } catch (err) { + logging.logAlert("Failed to run app migration", err) + throw err + } }