From 699b7dda71ab1d2aa5461592bf0879f7f93b6919 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sun, 6 Oct 2024 07:21:34 +0000 Subject: [PATCH] refactor: migration name --- .../src/meta/migrations/XcMigrationSourcev2.ts | 8 ++++---- ...c_063_encrypt_flag.ts => nc_064_encrypt_flag.ts} | 0 .../upgraders/0225002_ncDatasourceDecrypt.ts | 13 ++++++++++++- 3 files changed, 16 insertions(+), 5 deletions(-) rename packages/nocodb/src/meta/migrations/v2/{nc_063_encrypt_flag.ts => nc_064_encrypt_flag.ts} (100%) diff --git a/packages/nocodb/src/meta/migrations/XcMigrationSourcev2.ts b/packages/nocodb/src/meta/migrations/XcMigrationSourcev2.ts index 5cf13ffeab..007721df12 100644 --- a/packages/nocodb/src/meta/migrations/XcMigrationSourcev2.ts +++ b/packages/nocodb/src/meta/migrations/XcMigrationSourcev2.ts @@ -51,7 +51,7 @@ import * as nc_061_integration_is_default from '~/meta/migrations/v2/nc_061_inte import * as nc_062_integration_store from '~/meta/migrations/v2/nc_062_integration_store'; import * as nc_063_form_field_filter from '~/meta/migrations/v2/nc_063_form_field_filter'; import * as nc_064_pg_minimal_dbs from '~/meta/migrations/v2/nc_064_pg_minimal_dbs'; -import * as nc_063_encrypt_flag from '~/meta/migrations/v2/nc_061_encrypt_flag'; +import * as nc_064_encrypt_flag from '~/meta/migrations/v2/nc_064_encrypt_flag'; // Create a custom migration source class export default class XcMigrationSourcev2 { @@ -114,7 +114,7 @@ export default class XcMigrationSourcev2 { 'nc_062_integration_store', 'nc_063_form_field_filter', 'nc_064_pg_minimal_dbs', - 'nc_063_encrypt_flag', + 'nc_064_encrypt_flag', ]); } @@ -230,8 +230,8 @@ export default class XcMigrationSourcev2 { return nc_063_form_field_filter; case 'nc_064_pg_minimal_dbs': return nc_064_pg_minimal_dbs; - case 'nc_063_encrypt_flag': - return nc_063_encrypt_flag; + case 'nc_064_encrypt_flag': + return nc_064_encrypt_flag; } } } diff --git a/packages/nocodb/src/meta/migrations/v2/nc_063_encrypt_flag.ts b/packages/nocodb/src/meta/migrations/v2/nc_064_encrypt_flag.ts similarity index 100% rename from packages/nocodb/src/meta/migrations/v2/nc_063_encrypt_flag.ts rename to packages/nocodb/src/meta/migrations/v2/nc_064_encrypt_flag.ts diff --git a/packages/nocodb/src/version-upgrader/upgraders/0225002_ncDatasourceDecrypt.ts b/packages/nocodb/src/version-upgrader/upgraders/0225002_ncDatasourceDecrypt.ts index 50c8f067ce..6d1fcff819 100644 --- a/packages/nocodb/src/version-upgrader/upgraders/0225002_ncDatasourceDecrypt.ts +++ b/packages/nocodb/src/version-upgrader/upgraders/0225002_ncDatasourceDecrypt.ts @@ -1,3 +1,4 @@ +import process from 'process'; import CryptoJS from 'crypto-js'; import type { NcUpgraderCtx } from '~/version-upgrader/NcUpgrader'; import Noco from '~/Noco'; @@ -30,6 +31,14 @@ export default async function ({ ncMeta }: NcUpgraderCtx) { )?.value; } + // if encryption key is same as previous, return + if ( + process.env.NC_KEY_CREDENTIAL_ENCRYPT && + process.env.NC_KEY_CREDENTIAL_ENCRYPT === encryptionKey + ) { + return; + } + // if encryption key is not present, return if (!encryptionKey) { return; @@ -86,7 +95,9 @@ export default async function ({ ncMeta }: NcUpgraderCtx) { // if all failed, log and exit if (passed.length > 0 && passed.every((v) => !v)) { - logger.error(`Failed to decrypt all source or integration. Please configure correct encryption key. `); + logger.error( + `Failed to decrypt all source or integration. Please configure correct encryption key. `, + ); return; }