Making sure any error that occurs in the app migration system gets logged.

This commit is contained in:
mike12345567 2024-06-10 18:32:06 +01:00
parent 8ef4d5cc8b
commit c328dd5cd4
1 changed files with 17 additions and 17 deletions

View File

@ -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
}
}