From 03cf1385f2a82bfd85b7ce874d74a6535dc7b29f Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 4 Feb 2023 19:29:45 +0530 Subject: [PATCH] fix(nocodb): on upgrade failure show the prev upgrader applied as from version Signed-off-by: Pranav C --- .../src/lib/version-upgrader/NcUpgrader.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/nocodb/src/lib/version-upgrader/NcUpgrader.ts b/packages/nocodb/src/lib/version-upgrader/NcUpgrader.ts index a20f0480d2..f3ec57a504 100644 --- a/packages/nocodb/src/lib/version-upgrader/NcUpgrader.ts +++ b/packages/nocodb/src/lib/version-upgrader/NcUpgrader.ts @@ -52,6 +52,7 @@ export default class NcUpgrader { const configObj: NcConfig = JSON.parse(config.value); if (configObj.version !== process.env.NC_VERSION) { oldVersion = configObj.version; + let fromVersion = configObj.version; for (const version of NC_VERSIONS) { // compare current version and old version if (version.name <= configObj.version) { @@ -87,22 +88,19 @@ export default class NcUpgrader { ); await upgrderCtx.ncMeta.commit(); - Tele.emit('evt', { - evt_type: 'appMigration:upgraded', - from: oldVersion, - to: process.env.NC_VERSION, - }); + fromVersion = version.name; } catch (e) { await upgrderCtx.ncMeta.rollback(e); Tele.emit('evt', { evt_type: 'appMigration:failed', - from: oldVersion, + current: oldVersion, + from: fromVersion, to: process.env.NC_VERSION, msg: e.message, err: e?.stack?.split?.('\n').slice(0, 2).join('\n'), }); console.log( - getUpgradeErrorLog(e, oldVersion, process.env.NC_VERSION) + getUpgradeErrorLog(e, fromVersion, process.env.NC_VERSION) ); throw e; } @@ -113,6 +111,12 @@ export default class NcUpgrader { } } config.version = process.env.NC_VERSION; + + Tele.emit('evt', { + evt_type: 'appMigration:upgraded', + from: oldVersion, + to: process.env.NC_VERSION, + }); } } else { this.log(`upgrade : Inserting config to meta database`);