Browse Source

fix: handle old project migration

Signed-off-by: Pranav C <61551451+pranavxc@users.noreply.github.com>
pull/341/head
Pranav C 3 years ago
parent
commit
152572b166
  1. 11
      packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts

11
packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts

@ -688,9 +688,10 @@ export default abstract class BaseApiBuilder<T extends Noco> implements XcDynami
// update version in meta after each upgrade // update version in meta after each upgrade
config.version = version.name; config.version = version.name;
await this.xcMeta.metaInsert(this.projectId, this.dbAlias, 'nc_store', { await this.xcMeta.metaUpdate(this.projectId, this.dbAlias, 'nc_store', {
key: 'NC_CONFIG',
value: JSON.stringify(config) value: JSON.stringify(config)
}, {
key: 'NC_CONFIG',
}); });
// todo: backup data // todo: backup data
@ -710,11 +711,15 @@ export default abstract class BaseApiBuilder<T extends Noco> implements XcDynami
this.baseLog(`xcUpgrade : Inserting config to meta database`,) this.baseLog(`xcUpgrade : Inserting config to meta database`,)
const configObj: NcConfig = JSON.parse(JSON.stringify(this.config)); const configObj: NcConfig = JSON.parse(JSON.stringify(this.config));
delete configObj.envs; delete configObj.envs;
configObj.version = process.env.NC_VERSION; const isOld = (await this.xcMeta.metaList(this.projectId, this.dbAlias, 'nc_models'))?.length;
configObj.version = isOld ? '0009000' : process.env.NC_VERSION;
await this.xcMeta.metaInsert(this.projectId, this.dbAlias, 'nc_store', { await this.xcMeta.metaInsert(this.projectId, this.dbAlias, 'nc_store', {
key: 'NC_CONFIG', key: 'NC_CONFIG',
value: JSON.stringify(configObj) value: JSON.stringify(configObj)
}); });
if (isOld) {
await this.xcUpgrade();
}
} }
} }

Loading…
Cancel
Save