Browse Source

fix: external source with project create (#9166)

Co-authored-by: Pranav C <pranavxc@gmail.com>
pull/9170/head
Raju Udava 5 months ago committed by GitHub
parent
commit
45df00149c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 22
      packages/nocodb/src/services/bases.service.ts

22
packages/nocodb/src/services/bases.service.ts

@ -5,6 +5,7 @@ import { customAlphabet } from 'nanoid';
import {
AppEvents,
extractRolesObj,
IntegrationsType,
OrgUserRoles,
SqlUiFactory,
} from 'nocodb-sdk';
@ -20,7 +21,7 @@ import { populateMeta, validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError';
import { extractPropsAndSanitize } from '~/helpers/extractProps';
import syncMigration from '~/helpers/syncMigration';
import { Base, BaseUser } from '~/models';
import { Base, BaseUser, Integration } from '~/models';
import Noco from '~/Noco';
import { getToolDir } from '~/utils/nc-config';
import { MetaService } from '~/meta/meta.service';
@ -210,6 +211,25 @@ export class BasesService {
if (process.env.NC_CONNECT_TO_EXTERNAL_DB_DISABLED) {
NcError.badRequest('Connecting to external db is disabled');
}
for (const source of baseBody.sources || []) {
if (!source.fk_integration_id) {
const integration = await Integration.createIntegration({
title: source.alias || baseBody.title,
type: IntegrationsType.Database,
sub_type: source.config?.client,
is_private: !!param.req.user?.id,
config: source.config,
workspaceId: param.req?.ncWorkspaceId,
created_by: param.req.user?.id,
});
source.fk_integration_id = integration.id;
source.config = {
client: baseBody.config?.client,
};
}
}
baseBody.is_meta = false;
}

Loading…
Cancel
Save