Browse Source

refactor: rename enum alias

pull/9499/head
Pranav C 3 months ago
parent
commit
37bd38a4c9
  1. 4
      packages/nocodb/src/helpers/initDataSourceEncryption.ts
  2. 2
      packages/nocodb/src/meta/meta.service.ts
  3. 8
      packages/nocodb/src/meta/migrations/v2/nc_037_rename_project_and_base.ts
  4. 4
      packages/nocodb/src/meta/migrations/v2/nc_042_integrations.ts
  5. 4
      packages/nocodb/src/meta/migrations/v2/nc_050_tenant_isolation.ts
  6. 4
      packages/nocodb/src/meta/migrations/v2/nc_051_source_readonly_columns.ts
  7. 4
      packages/nocodb/src/meta/migrations/v2/nc_054_id_length.ts
  8. 18
      packages/nocodb/src/meta/migrations/v2/nc_056_integration.ts
  9. 4
      packages/nocodb/src/meta/migrations/v2/nc_063_encrypt_flag.ts
  10. 4
      packages/nocodb/src/models/Integration.spec.ts
  11. 22
      packages/nocodb/src/models/Integration.ts
  12. 64
      packages/nocodb/src/models/Source.ts
  13. 6
      packages/nocodb/src/services/integrations.service.ts
  14. 6
      packages/nocodb/src/utils/globals.ts
  15. 2
      packages/nocodb/src/version-upgrader/upgraders/0101002_ncAttachmentUpgrader.ts
  16. 2
      packages/nocodb/src/version-upgrader/upgraders/0104002_ncAttachmentUpgrader.ts
  17. 2
      packages/nocodb/src/version-upgrader/upgraders/0107004_ncProjectConfigUpgrader.ts
  18. 2
      packages/nocodb/src/version-upgrader/upgraders/0108002_ncXcdbLTARUpgrader.ts
  19. 2
      packages/nocodb/src/version-upgrader/upgraders/0111002_ncXcdbLTARIndexUpgrader.ts
  20. 2
      packages/nocodb/src/version-upgrader/upgraders/0111005_ncXcdbCreatedAndUpdatedSystemFieldsUpgrader.ts
  21. 4
      packages/nocodb/src/version-upgrader/upgraders/0225002_ncDatasourceDecrypt.ts

4
packages/nocodb/src/helpers/initDataSourceEncryption.ts

@ -16,7 +16,7 @@ export default async function initDataSourceEncryption(_ncMeta = Noco.ncMeta) {
try { try {
// if configured, check for any non-encrypted data source by checking is_encrypted flag // if configured, check for any non-encrypted data source by checking is_encrypted flag
const sources = await ncMeta const sources = await ncMeta
.knex(MetaTable.BASES) .knex(MetaTable.SOURCES)
.where((qb) => { .where((qb) => {
qb.where('is_encrypted', false).orWhereNull('is_encrypted'); qb.where('is_encrypted', false).orWhereNull('is_encrypted');
}) })
@ -33,7 +33,7 @@ export default async function initDataSourceEncryption(_ncMeta = Noco.ncMeta) {
await ncMeta.metaUpdate( await ncMeta.metaUpdate(
source.fk_workspace_id, source.fk_workspace_id,
source.id, source.id,
MetaTable.BASES, MetaTable.SOURCES,
{ {
config: encryptPropIfRequired({ config: encryptPropIfRequired({
data: source, data: source,

2
packages/nocodb/src/meta/meta.service.ts

@ -292,7 +292,7 @@ export class MetaService {
public async genNanoid(target: string) { public async genNanoid(target: string) {
const prefixMap: { [key: string]: string } = { const prefixMap: { [key: string]: string } = {
[MetaTable.PROJECT]: 'p', [MetaTable.PROJECT]: 'p',
[MetaTable.BASES]: 'b', [MetaTable.SOURCES]: 'b',
[MetaTable.MODELS]: 'm', [MetaTable.MODELS]: 'm',
[MetaTable.COLUMNS]: 'c', [MetaTable.COLUMNS]: 'c',
[MetaTable.COL_RELATIONS]: 'l', [MetaTable.COL_RELATIONS]: 'l',

8
packages/nocodb/src/meta/migrations/v2/nc_037_rename_project_and_base.ts

@ -7,7 +7,7 @@ const logger = new Logger('nc_036_rename_project_and_base');
const up = async (knex: Knex) => { const up = async (knex: Knex) => {
logger.log('Renaming base table'); logger.log('Renaming base table');
if (await knex.schema.hasTable(MetaTableOldV2.BASES)) if (await knex.schema.hasTable(MetaTableOldV2.BASES))
await knex.schema.renameTable(MetaTableOldV2.BASES, MetaTable.BASES); await knex.schema.renameTable(MetaTableOldV2.BASES, MetaTable.SOURCES);
logger.log('Renaming `base_id` column to `source_id`'); logger.log('Renaming `base_id` column to `source_id`');
if (await knex.schema.hasColumn(MetaTable.MODELS, 'base_id')) if (await knex.schema.hasColumn(MetaTable.MODELS, 'base_id'))
@ -349,10 +349,10 @@ const up = async (knex: Knex) => {
}); });
logger.log( logger.log(
`Renaming 'project_id' column to 'base_id' in '${MetaTable.BASES}' table`, `Renaming 'project_id' column to 'base_id' in '${MetaTable.SOURCES}' table`,
); );
if (await knex.schema.hasColumn(MetaTable.BASES, 'project_id')) if (await knex.schema.hasColumn(MetaTable.SOURCES, 'project_id'))
await knex.schema.alterTable(MetaTable.BASES, (table) => { await knex.schema.alterTable(MetaTable.SOURCES, (table) => {
table.renameColumn('project_id', 'base_id'); table.renameColumn('project_id', 'base_id');
}); });

4
packages/nocodb/src/meta/migrations/v2/nc_042_integrations.ts

@ -24,7 +24,7 @@ const up = async (knex: Knex) => {
table.timestamps(true, true); table.timestamps(true, true);
}); });
await knex.schema.alterTable(MetaTable.BASES, (table) => { await knex.schema.alterTable(MetaTable.SOURCES, (table) => {
table.string('fk_integration_id', 20); table.string('fk_integration_id', 20);
}); });
@ -36,7 +36,7 @@ const up = async (knex: Knex) => {
const down = async (knex: Knex) => { const down = async (knex: Knex) => {
await knex.schema.dropTable(MetaTable.INTEGRATIONS); await knex.schema.dropTable(MetaTable.INTEGRATIONS);
await knex.schema.alterTable(MetaTable.BASES, (table) => { await knex.schema.alterTable(MetaTable.SOURCES, (table) => {
table.dropColumn('fk_integration_id'); table.dropColumn('fk_integration_id');
}); });
}; };

4
packages/nocodb/src/meta/migrations/v2/nc_050_tenant_isolation.ts

@ -269,7 +269,7 @@ const up = async (knex: Knex) => {
// Drop existing base_id indexes // Drop existing base_id indexes
const dropBaseIdIndexes = [ const dropBaseIdIndexes = [
MetaTable.AUDIT, MetaTable.AUDIT,
MetaTable.BASES, MetaTable.SOURCES,
MetaTable.MODELS, MetaTable.MODELS,
MetaTable.PROJECT_USERS, MetaTable.PROJECT_USERS,
MetaTable.SYNC_SOURCE, MetaTable.SYNC_SOURCE,
@ -349,7 +349,7 @@ const up = async (knex: Knex) => {
MetaTable.MAP_VIEW, MetaTable.MAP_VIEW,
MetaTable.MODELS, MetaTable.MODELS,
MetaTable.SORT, MetaTable.SORT,
MetaTable.BASES, MetaTable.SOURCES,
MetaTable.SYNC_LOGS, MetaTable.SYNC_LOGS,
MetaTable.SYNC_SOURCE, MetaTable.SYNC_SOURCE,
MetaTable.VIEWS, MetaTable.VIEWS,

4
packages/nocodb/src/meta/migrations/v2/nc_051_source_readonly_columns.ts

@ -2,14 +2,14 @@ import type { Knex } from 'knex';
import { MetaTable } from '~/utils/globals'; import { MetaTable } from '~/utils/globals';
const up = async (knex: Knex) => { const up = async (knex: Knex) => {
await knex.schema.alterTable(MetaTable.BASES, (table) => { await knex.schema.alterTable(MetaTable.SOURCES, (table) => {
table.boolean('is_schema_readonly').defaultTo(false); table.boolean('is_schema_readonly').defaultTo(false);
table.boolean('is_data_readonly').defaultTo(false); table.boolean('is_data_readonly').defaultTo(false);
}); });
}; };
const down = async (knex: Knex) => { const down = async (knex: Knex) => {
await knex.schema.alterTable(MetaTable.BASES, (table) => { await knex.schema.alterTable(MetaTable.SOURCES, (table) => {
table.dropColumn('is_schema_readonly'); table.dropColumn('is_schema_readonly');
table.dropColumn('is_data_readonly'); table.dropColumn('is_data_readonly');
}); });

4
packages/nocodb/src/meta/migrations/v2/nc_054_id_length.ts

@ -107,7 +107,7 @@ export const replaceLongBaseIds = async (knex: Knex) => {
MetaTable.MAP_VIEW, MetaTable.MAP_VIEW,
MetaTable.MODELS, MetaTable.MODELS,
MetaTable.SORT, MetaTable.SORT,
MetaTable.BASES, MetaTable.SOURCES,
MetaTable.SYNC_LOGS, MetaTable.SYNC_LOGS,
MetaTable.SYNC_SOURCE, MetaTable.SYNC_SOURCE,
MetaTable.USER_COMMENTS_NOTIFICATIONS_PREFERENCE, MetaTable.USER_COMMENTS_NOTIFICATIONS_PREFERENCE,
@ -147,7 +147,7 @@ const tablesToAlterBaseId = [
MetaTable.MAP_VIEW_COLUMNS, MetaTable.MAP_VIEW_COLUMNS,
MetaTable.MODELS, MetaTable.MODELS,
MetaTable.SORT, MetaTable.SORT,
MetaTable.BASES, MetaTable.SOURCES,
MetaTable.SYNC_LOGS, MetaTable.SYNC_LOGS,
MetaTable.SYNC_SOURCE, MetaTable.SYNC_SOURCE,
MetaTable.USER_COMMENTS_NOTIFICATIONS_PREFERENCE, MetaTable.USER_COMMENTS_NOTIFICATIONS_PREFERENCE,

18
packages/nocodb/src/meta/migrations/v2/nc_056_integration.ts

@ -36,8 +36,8 @@ const up = async (knex: Knex) => {
}); });
} }
if (!(await knex.schema.hasColumn(MetaTable.BASES, 'fk_integration_id'))) { if (!(await knex.schema.hasColumn(MetaTable.SOURCES, 'fk_integration_id'))) {
await knex.schema.alterTable(MetaTable.BASES, (table) => { await knex.schema.alterTable(MetaTable.SOURCES, (table) => {
table.string('fk_integration_id', 20).index(); table.string('fk_integration_id', 20).index();
}); });
} }
@ -45,18 +45,18 @@ const up = async (knex: Knex) => {
hrTime = process.hrtime(); hrTime = process.hrtime();
// get all external sources, add them to integrations table and map back to bases // get all external sources, add them to integrations table and map back to bases
const sources = await knex(MetaTable.BASES) const sources = await knex(MetaTable.SOURCES)
.select(`${MetaTable.BASES}.*`) .select(`${MetaTable.SOURCES}.*`)
.select(`${MetaTable.PROJECT_USERS}.fk_user_id as created_by`) .select(`${MetaTable.PROJECT_USERS}.fk_user_id as created_by`)
.innerJoin( .innerJoin(
MetaTable.PROJECT, MetaTable.PROJECT,
`${MetaTable.BASES}.base_id`, `${MetaTable.SOURCES}.base_id`,
`${MetaTable.PROJECT}.id`, `${MetaTable.PROJECT}.id`,
) )
.where((qb) => .where((qb) =>
qb qb
.where(`${MetaTable.BASES}.is_meta`, false) .where(`${MetaTable.SOURCES}.is_meta`, false)
.orWhereNull(`${MetaTable.BASES}.is_meta`), .orWhereNull(`${MetaTable.SOURCES}.is_meta`),
) )
.leftJoin(MetaTable.PROJECT_USERS, (qb) => { .leftJoin(MetaTable.PROJECT_USERS, (qb) => {
qb.on( qb.on(
@ -86,7 +86,7 @@ const up = async (knex: Knex) => {
}; };
await knex(MetaTable.INTEGRATIONS).insert(integration); await knex(MetaTable.INTEGRATIONS).insert(integration);
await knex(MetaTable.BASES).where('id', source.id).update({ await knex(MetaTable.SOURCES).where('id', source.id).update({
fk_integration_id: integrationId, fk_integration_id: integrationId,
}); });
} }
@ -97,7 +97,7 @@ const up = async (knex: Knex) => {
const down = async (knex: Knex) => { const down = async (knex: Knex) => {
await knex.schema.dropTable(MetaTable.INTEGRATIONS); await knex.schema.dropTable(MetaTable.INTEGRATIONS);
await knex.schema.alterTable(MetaTable.BASES, (table) => { await knex.schema.alterTable(MetaTable.SOURCES, (table) => {
table.dropColumn('fk_integration_id'); table.dropColumn('fk_integration_id');
}); });
}; };

4
packages/nocodb/src/meta/migrations/v2/nc_063_encrypt_flag.ts

@ -2,7 +2,7 @@ import type { Knex } from 'knex';
import { MetaTable } from '~/utils/globals'; import { MetaTable } from '~/utils/globals';
const up = async (knex: Knex) => { const up = async (knex: Knex) => {
await knex.schema.alterTable(MetaTable.BASES, (table) => { await knex.schema.alterTable(MetaTable.SOURCES, (table) => {
table.boolean('is_encrypted').defaultTo(false).index(); table.boolean('is_encrypted').defaultTo(false).index();
}); });
await knex.schema.alterTable(MetaTable.INTEGRATIONS, (table) => { await knex.schema.alterTable(MetaTable.INTEGRATIONS, (table) => {
@ -11,7 +11,7 @@ const up = async (knex: Knex) => {
}; };
const down = async (knex: Knex) => { const down = async (knex: Knex) => {
await knex.schema.alterTable(MetaTable.BASES, (table) => { await knex.schema.alterTable(MetaTable.SOURCES, (table) => {
table.dropColumn('is_encrypted'); table.dropColumn('is_encrypted');
}); });
await knex.schema.alterTable(MetaTable.INTEGRATIONS, (table) => { await knex.schema.alterTable(MetaTable.INTEGRATIONS, (table) => {

4
packages/nocodb/src/models/Integration.spec.ts

@ -117,7 +117,7 @@ describe('Integration Model', () => {
title: 'New Integration', title: 'New Integration',
workspaceId: 'workspace-1', workspaceId: 'workspace-1',
config: { config: {
client: 'pg' client: 'pg',
}, },
}; };
mockNcMeta.metaInsert2.mockResolvedValue({ mockNcMeta.metaInsert2.mockResolvedValue({
@ -168,7 +168,7 @@ describe('Integration Model', () => {
title: 'New Integration', title: 'New Integration',
workspaceId: 'workspace-1', workspaceId: 'workspace-1',
config: { config: {
client: 'pg' client: 'pg',
}, },
}; };
mockNcMeta.metaInsert2.mockResolvedValue({ mockNcMeta.metaInsert2.mockResolvedValue({

22
packages/nocodb/src/models/Integration.ts

@ -222,12 +222,12 @@ export default class Integration implements IntegrationType {
listQb listQb
.select( .select(
`${MetaTable.INTEGRATIONS}.*`, `${MetaTable.INTEGRATIONS}.*`,
ncMeta.knex.raw(`count(${MetaTable.BASES}.id) as source_count`), ncMeta.knex.raw(`count(${MetaTable.SOURCES}.id) as source_count`),
) )
.leftJoin( .leftJoin(
MetaTable.BASES, MetaTable.SOURCES,
`${MetaTable.INTEGRATIONS}.id`, `${MetaTable.INTEGRATIONS}.id`,
`${MetaTable.BASES}.fk_integration_id`, `${MetaTable.SOURCES}.fk_integration_id`,
) )
.groupBy(`${MetaTable.INTEGRATIONS}.id`); .groupBy(`${MetaTable.INTEGRATIONS}.id`);
} }
@ -367,23 +367,23 @@ export default class Integration implements IntegrationType {
} }
async getSources(ncMeta = Noco.ncMeta): Promise<any> { async getSources(ncMeta = Noco.ncMeta): Promise<any> {
const qb = ncMeta.knex(MetaTable.BASES); const qb = ncMeta.knex(MetaTable.SOURCES);
const sources = await qb const sources = await qb
.select(`${MetaTable.BASES}.id`) .select(`${MetaTable.SOURCES}.id`)
.select(`${MetaTable.BASES}.alias`) .select(`${MetaTable.SOURCES}.alias`)
.select(`${MetaTable.PROJECT}.title as project_title`) .select(`${MetaTable.PROJECT}.title as project_title`)
.select(`${MetaTable.BASES}.base_id`) .select(`${MetaTable.SOURCES}.base_id`)
.innerJoin( .innerJoin(
MetaTable.PROJECT, MetaTable.PROJECT,
`${MetaTable.BASES}.base_id`, `${MetaTable.SOURCES}.base_id`,
`${MetaTable.PROJECT}.id`, `${MetaTable.PROJECT}.id`,
) )
.where(`${MetaTable.BASES}.fk_integration_id`, this.id) .where(`${MetaTable.SOURCES}.fk_integration_id`, this.id)
.where((whereQb) => { .where((whereQb) => {
whereQb whereQb
.where(`${MetaTable.BASES}.deleted`, false) .where(`${MetaTable.SOURCES}.deleted`, false)
.orWhereNull(`${MetaTable.BASES}.deleted`); .orWhereNull(`${MetaTable.SOURCES}.deleted`);
}) })
.where((whereQb) => { .where((whereQb) => {
whereQb whereQb

64
packages/nocodb/src/models/Source.ts

@ -96,23 +96,23 @@ export default class Source implements SourceType {
insertObj.meta = stringifyMetaProp(insertObj); insertObj.meta = stringifyMetaProp(insertObj);
} }
insertObj.order = await ncMeta.metaGetNextOrder(MetaTable.BASES, { insertObj.order = await ncMeta.metaGetNextOrder(MetaTable.SOURCES, {
base_id: source.baseId, base_id: source.baseId,
}); });
const { id } = await ncMeta.metaInsert2( const { id } = await ncMeta.metaInsert2(
context.workspace_id, context.workspace_id,
context.base_id, context.base_id,
MetaTable.BASES, MetaTable.SOURCES,
insertObj, insertObj,
); );
const returnBase = await this.get(context, id, false, ncMeta); const returnBase = await this.get(context, id, false, ncMeta);
await NocoCache.appendToList( await NocoCache.appendToList(
CacheScope.BASE, CacheScope.SOURCE,
[source.baseId], [source.baseId],
`${CacheScope.BASE}:${id}`, `${CacheScope.SOURCE}:${id}`,
); );
return returnBase; return returnBase;
@ -167,7 +167,7 @@ export default class Source implements SourceType {
// if order is missing (possible in old versions), get next order // if order is missing (possible in old versions), get next order
if (!oldSource.order && !updateObj.order) { if (!oldSource.order && !updateObj.order) {
updateObj.order = await ncMeta.metaGetNextOrder(MetaTable.BASES, { updateObj.order = await ncMeta.metaGetNextOrder(MetaTable.SOURCES, {
base_id: oldSource.base_id, base_id: oldSource.base_id,
}); });
@ -189,7 +189,7 @@ export default class Source implements SourceType {
// if order is 1 for non-default source, move it to last // if order is 1 for non-default source, move it to last
if (oldSource.order <= 1 && !updateObj.order) { if (oldSource.order <= 1 && !updateObj.order) {
updateObj.order = await ncMeta.metaGetNextOrder(MetaTable.BASES, { updateObj.order = await ncMeta.metaGetNextOrder(MetaTable.SOURCES, {
base_id: oldSource.base_id, base_id: oldSource.base_id,
}); });
} }
@ -198,13 +198,13 @@ export default class Source implements SourceType {
await ncMeta.metaUpdate( await ncMeta.metaUpdate(
context.workspace_id, context.workspace_id,
context.base_id, context.base_id,
MetaTable.BASES, MetaTable.SOURCES,
prepareForDb(updateObj), prepareForDb(updateObj),
oldSource.id, oldSource.id,
); );
await NocoCache.update( await NocoCache.update(
`${CacheScope.BASE}:${sourceId}`, `${CacheScope.SOURCE}:${sourceId}`,
prepareForResponse(updateObj), prepareForResponse(updateObj),
); );
@ -226,20 +226,20 @@ export default class Source implements SourceType {
args: { baseId: string }, args: { baseId: string },
ncMeta = Noco.ncMeta, ncMeta = Noco.ncMeta,
): Promise<Source[]> { ): Promise<Source[]> {
const cachedList = await NocoCache.getList(CacheScope.BASE, [args.baseId]); const cachedList = await NocoCache.getList(CacheScope.SOURCE, [args.baseId]);
let { list: sourceDataList } = cachedList; let { list: sourceDataList } = cachedList;
const { isNoneList } = cachedList; const { isNoneList } = cachedList;
if (!isNoneList && !sourceDataList.length) { if (!isNoneList && !sourceDataList.length) {
const qb = ncMeta const qb = ncMeta
.knex(MetaTable.BASES) .knex(MetaTable.SOURCES)
.select(`${MetaTable.BASES}.*`) .select(`${MetaTable.SOURCES}.*`)
.where(`${MetaTable.BASES}.base_id`, context.base_id) .where(`${MetaTable.SOURCES}.base_id`, context.base_id)
.where((whereQb) => { .where((whereQb) => {
whereQb whereQb
.where(`${MetaTable.BASES}.deleted`, false) .where(`${MetaTable.SOURCES}.deleted`, false)
.orWhereNull(`${MetaTable.BASES}.deleted`); .orWhereNull(`${MetaTable.SOURCES}.deleted`);
}) })
.orderBy(`${MetaTable.BASES}.order`, 'asc'); .orderBy(`${MetaTable.SOURCES}.order`, 'asc');
this.extendQb(qb, context); this.extendQb(qb, context);
@ -250,7 +250,7 @@ export default class Source implements SourceType {
source.meta = parseMetaProp(source, 'meta'); source.meta = parseMetaProp(source, 'meta');
} }
await NocoCache.setList(CacheScope.BASE, [args.baseId], sourceDataList); await NocoCache.setList(CacheScope.SOURCE, [args.baseId], sourceDataList);
} }
sourceDataList.sort( sourceDataList.sort(
@ -271,23 +271,23 @@ export default class Source implements SourceType {
let sourceData = let sourceData =
id && id &&
(await NocoCache.get( (await NocoCache.get(
`${CacheScope.BASE}:${id}`, `${CacheScope.SOURCE}:${id}`,
CacheGetType.TYPE_OBJECT, CacheGetType.TYPE_OBJECT,
)); ));
if (!sourceData) { if (!sourceData) {
const qb = ncMeta const qb = ncMeta
.knex(MetaTable.BASES) .knex(MetaTable.SOURCES)
.select(`${MetaTable.BASES}.*`) .select(`${MetaTable.SOURCES}.*`)
.where(`${MetaTable.BASES}.id`, id) .where(`${MetaTable.SOURCES}.id`, id)
.where(`${MetaTable.BASES}.base_id`, context.base_id); .where(`${MetaTable.SOURCES}.base_id`, context.base_id);
this.extendQb(qb, context); this.extendQb(qb, context);
if (!force) { if (!force) {
qb.where((whereQb) => { qb.where((whereQb) => {
whereQb whereQb
.where(`${MetaTable.BASES}.deleted`, false) .where(`${MetaTable.SOURCES}.deleted`, false)
.orWhereNull(`${MetaTable.BASES}.deleted`); .orWhereNull(`${MetaTable.SOURCES}.deleted`);
}); });
} }
@ -297,7 +297,7 @@ export default class Source implements SourceType {
sourceData.meta = parseMetaProp(sourceData, 'meta'); sourceData.meta = parseMetaProp(sourceData, 'meta');
} }
await NocoCache.set(`${CacheScope.BASE}:${id}`, sourceData); await NocoCache.set(`${CacheScope.SOURCE}:${id}`, sourceData);
} }
return this.castType(sourceData); return this.castType(sourceData);
} }
@ -476,12 +476,12 @@ export default class Source implements SourceType {
const res = await ncMeta.metaDelete( const res = await ncMeta.metaDelete(
context.workspace_id, context.workspace_id,
context.base_id, context.base_id,
MetaTable.BASES, MetaTable.SOURCES,
this.id, this.id,
); );
await NocoCache.deepDel( await NocoCache.deepDel(
`${CacheScope.BASE}:${this.id}`, `${CacheScope.SOURCE}:${this.id}`,
CacheDelDirection.CHILD_TO_PARENT, CacheDelDirection.CHILD_TO_PARENT,
); );
@ -506,7 +506,7 @@ export default class Source implements SourceType {
await Source.update(context, this.id, { deleted: true }, ncMeta); await Source.update(context, this.id, { deleted: true }, ncMeta);
await NocoCache.deepDel( await NocoCache.deepDel(
`${CacheScope.BASE}:${this.id}`, `${CacheScope.SOURCE}:${this.id}`,
CacheDelDirection.CHILD_TO_PARENT, CacheDelDirection.CHILD_TO_PARENT,
); );
} }
@ -528,14 +528,14 @@ export default class Source implements SourceType {
await ncMeta.metaUpdate( await ncMeta.metaUpdate(
context.workspace_id, context.workspace_id,
context.base_id, context.base_id,
MetaTable.BASES, MetaTable.SOURCES,
{ {
erd_uuid: this.erd_uuid, erd_uuid: this.erd_uuid,
}, },
this.id, this.id,
); );
await NocoCache.update(`${CacheScope.BASE}:${this.id}`, { await NocoCache.update(`${CacheScope.SOURCE}:${this.id}`, {
erd_uuid: this.erd_uuid, erd_uuid: this.erd_uuid,
}); });
} }
@ -550,14 +550,14 @@ export default class Source implements SourceType {
await ncMeta.metaUpdate( await ncMeta.metaUpdate(
context.workspace_id, context.workspace_id,
context.base_id, context.base_id,
MetaTable.BASES, MetaTable.SOURCES,
{ {
erd_uuid: this.erd_uuid, erd_uuid: this.erd_uuid,
}, },
this.id, this.id,
); );
await NocoCache.update(`${CacheScope.BASE}:${this.id}`, { await NocoCache.update(`${CacheScope.SOURCE}:${this.id}`, {
erd_uuid: this.erd_uuid, erd_uuid: this.erd_uuid,
}); });
} }
@ -581,7 +581,7 @@ export default class Source implements SourceType {
`${MetaTable.INTEGRATIONS}.title as integration_title`, `${MetaTable.INTEGRATIONS}.title as integration_title`,
).leftJoin( ).leftJoin(
MetaTable.INTEGRATIONS, MetaTable.INTEGRATIONS,
`${MetaTable.BASES}.fk_integration_id`, `${MetaTable.SOURCES}.fk_integration_id`,
`${MetaTable.INTEGRATIONS}.id`, `${MetaTable.INTEGRATIONS}.id`,
); );
} }

6
packages/nocodb/src/services/integrations.service.ts

@ -120,7 +120,7 @@ export class IntegrationsService {
// get linked sources // get linked sources
const sourceListQb = ncMeta const sourceListQb = ncMeta
.knex(MetaTable.BASES) .knex(MetaTable.SOURCES)
.where({ .where({
fk_integration_id: integration.id, fk_integration_id: integration.id,
}) })
@ -309,7 +309,7 @@ export class IntegrationsService {
const sources = await ncMeta.metaList2( const sources = await ncMeta.metaList2(
integration.fk_workspace_id, integration.fk_workspace_id,
RootScopes.WORKSPACE, RootScopes.WORKSPACE,
MetaTable.BASES, MetaTable.SOURCES,
{ {
condition: { condition: {
fk_integration_id: integration.id, fk_integration_id: integration.id,
@ -336,7 +336,7 @@ export class IntegrationsService {
const source = new Source(sourceObj); const source = new Source(sourceObj);
// update the cache with the new config(encrypted) // update the cache with the new config(encrypted)
await NocoCache.update(`${CacheScope.BASE}:${source.id}`, { await NocoCache.update(`${CacheScope.SOURCE}:${source.id}`, {
integration_config: integration.config, integration_config: integration.config,
}); });

6
packages/nocodb/src/utils/globals.ts

@ -1,6 +1,6 @@
export enum MetaTable { export enum MetaTable {
PROJECT = 'nc_bases_v2', PROJECT = 'nc_bases_v2',
BASES = 'nc_sources_v2', SOURCES = 'nc_sources_v2',
MODELS = 'nc_models_v2', MODELS = 'nc_models_v2',
COLUMNS = 'nc_columns_v2', COLUMNS = 'nc_columns_v2',
COLUMN_VALIDATIONS = 'nc_columns_validations_v2', COLUMN_VALIDATIONS = 'nc_columns_validations_v2',
@ -100,7 +100,7 @@ export const orderedMetaTables = [
MetaTable.COLUMN_VALIDATIONS, MetaTable.COLUMN_VALIDATIONS,
MetaTable.COLUMNS, MetaTable.COLUMNS,
MetaTable.MODELS, MetaTable.MODELS,
MetaTable.BASES, MetaTable.SOURCES,
MetaTable.PROJECT, MetaTable.PROJECT,
]; ];
@ -132,7 +132,7 @@ export const sakilaTableNames = [
export enum CacheScope { export enum CacheScope {
PROJECT = 'base', PROJECT = 'base',
BASE = 'source', SOURCE = 'source',
MODEL = 'model', MODEL = 'model',
COLUMN = 'column', COLUMN = 'column',
COL_PROP = 'colProp', COL_PROP = 'colProp',

2
packages/nocodb/src/version-upgrader/upgraders/0101002_ncAttachmentUpgrader.ts

@ -46,7 +46,7 @@ function getTnPath(knex: XKnex, tb: Model) {
} }
export default async function ({ ncMeta }: NcUpgraderCtx) { export default async function ({ ncMeta }: NcUpgraderCtx) {
const sources: SourceType[] = await ncMeta.knexConnection(MetaTable.BASES); const sources: SourceType[] = await ncMeta.knexConnection(MetaTable.SOURCES);
for (const _base of sources) { for (const _base of sources) {
const source = new Source(_base); const source = new Source(_base);

2
packages/nocodb/src/version-upgrader/upgraders/0104002_ncAttachmentUpgrader.ts

@ -37,7 +37,7 @@ function getTnPath(knex: XKnex, tb: Model) {
} }
export default async function ({ ncMeta }: NcUpgraderCtx) { export default async function ({ ncMeta }: NcUpgraderCtx) {
const sources: SourceType[] = await ncMeta.knexConnection(MetaTable.BASES); const sources: SourceType[] = await ncMeta.knexConnection(MetaTable.SOURCES);
for (const _base of sources) { for (const _base of sources) {
const source = new Source(_base); const source = new Source(_base);

2
packages/nocodb/src/version-upgrader/upgraders/0107004_ncProjectConfigUpgrader.ts

@ -13,7 +13,7 @@ export default async function ({ ncMeta }: NcUpgraderCtx) {
const actions = []; const actions = [];
// Get all the base sources // Get all the base sources
const sources = await ncMeta.knexConnection(MetaTable.BASES); const sources = await ncMeta.knexConnection(MetaTable.SOURCES);
// Update the base config with the new secret key if we could decrypt the base config with the fallback secret key // Update the base config with the new secret key if we could decrypt the base config with the fallback secret key
for (const source of sources) { for (const source of sources) {

2
packages/nocodb/src/version-upgrader/upgraders/0108002_ncXcdbLTARUpgrader.ts

@ -163,7 +163,7 @@ async function upgradeBaseRelations(
// database to virtual relation and create an index for it // database to virtual relation and create an index for it
export default async function ({ ncMeta }: NcUpgraderCtx) { export default async function ({ ncMeta }: NcUpgraderCtx) {
// get all xcdb sources // get all xcdb sources
const sources = await ncMeta.knexConnection(MetaTable.BASES).where({ const sources = await ncMeta.knexConnection(MetaTable.SOURCES).where({
is_meta: 1, is_meta: 1,
}); });

2
packages/nocodb/src/version-upgrader/upgraders/0111002_ncXcdbLTARIndexUpgrader.ts

@ -151,7 +151,7 @@ export default async function ({ ncMeta }: NcUpgraderCtx) {
); );
// get all xcdb sources // get all xcdb sources
const sources = await ncMeta.knexConnection(MetaTable.BASES).where({ const sources = await ncMeta.knexConnection(MetaTable.SOURCES).where({
is_meta: 1, is_meta: 1,
}); });

2
packages/nocodb/src/version-upgrader/upgraders/0111005_ncXcdbCreatedAndUpdatedSystemFieldsUpgrader.ts

@ -370,7 +370,7 @@ async function upgradeModels({
// database to virtual relation and create an index for it // database to virtual relation and create an index for it
export default async function ({ ncMeta }: NcUpgraderCtx) { export default async function ({ ncMeta }: NcUpgraderCtx) {
// get all xcdb sources // get all xcdb sources
const sources = await ncMeta.knexConnection(MetaTable.BASES).condition({ const sources = await ncMeta.knexConnection(MetaTable.SOURCES).condition({
_or: [ _or: [
{ {
is_meta: { is_meta: {

4
packages/nocodb/src/version-upgrader/upgraders/0225002_ncDatasourceDecrypt.ts

@ -36,7 +36,7 @@ export default async function ({ ncMeta }: NcUpgraderCtx) {
} }
// get all external sources // get all external sources
const sources = await ncMeta.knexConnection(MetaTable.BASES).condition({ const sources = await ncMeta.knexConnection(MetaTable.SOURCES).condition({
_not: { _not: {
_or: [ _or: [
{ {
@ -64,7 +64,7 @@ export default async function ({ ncMeta }: NcUpgraderCtx) {
if (source?.config) { if (source?.config) {
try { try {
const decrypted = await decyptConfig(source.config, encryptionKey); const decrypted = await decyptConfig(source.config, encryptionKey);
await ncMeta.knexConnection(MetaTable.BASES).update({ await ncMeta.knexConnection(MetaTable.SOURCES).update({
config: decrypted, config: decrypted,
}); });
passed.push(true); passed.push(true);

Loading…
Cancel
Save