Browse Source

fix: disable fk checks for external bases

nc-fix/at-attachments
mertmit 10 months ago
parent
commit
eb2e791243
  1. 8
      packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts
  2. 36
      packages/nocodb/src/modules/jobs/jobs/at-import/helpers/readAndProcessData.ts

8
packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts

@ -14,7 +14,7 @@ import FetchAT from './helpers/fetchAT';
import { importData, importLTARData } from './helpers/readAndProcessData';
import EntityMap from './helpers/EntityMap';
import type { UserType } from 'nocodb-sdk';
import type { Base } from '~/models';
import { type Base, Source } from '~/models';
import { sanitizeColumnName } from '~/helpers';
import { AttachmentsService } from '~/services/attachments.service';
import { ColumnsService } from '~/services/columns.service';
@ -2457,6 +2457,9 @@ export class AtImportProcessor {
sourceId: syncDB.sourceId,
roles: { ...userRole, owner: true },
});
const source = await Source.get(syncDB.sourceId);
recordPerfStats(_perfStart, 'base.tableList');
logBasic('Reading Records...');
@ -2484,7 +2487,8 @@ export class AtImportProcessor {
table: ncTbl,
atBase,
nocoBaseDataProcessing_v2,
sDB: syncDB,
syncDB,
source,
services: {
tableService: this.tablesService,
bulkDataService: this.bulkDataAliasService,

36
packages/nocodb/src/modules/jobs/jobs/at-import/helpers/readAndProcessData.ts

@ -2,12 +2,11 @@
import { isLinksOrLTAR, RelationTypes } from 'nocodb-sdk';
import sizeof from 'object-sizeof';
import { Logger } from '@nestjs/common';
import EntityMap from './EntityMap';
import type { BulkDataAliasService } from '../../../../../services/bulk-data-alias.service';
import type { TablesService } from '../../../../../services/tables.service';
// @ts-ignore
import type { BulkDataAliasService } from '~/services/bulk-data-alias.service';
import type { TablesService } from '~/services/tables.service';
import type { AirtableBase } from 'airtable/lib/airtable_base';
import type { TableType } from 'nocodb-sdk';
import type { Source } from '~/models';
const logger = new Logger('BaseModelSqlv2');
@ -108,7 +107,8 @@ export async function importData({
table,
atBase,
nocoBaseDataProcessing_v2,
sDB,
syncDB,
source,
logBasic = (_str) => {},
logDetailed = (_str) => {},
logWarning = (_str) => {},
@ -118,6 +118,7 @@ export async function importData({
table: { title?: string; id?: string };
fields?;
atBase: AirtableBase;
source: Source;
logBasic: (string) => void;
logDetailed: (string) => void;
logWarning: (string) => void;
@ -139,6 +140,25 @@ export async function importData({
const allRecordsCount = await records.getCount();
const promises = [];
const ltarPromise = importLTARData({
table,
baseName,
insertedAssocRef,
dataStream,
atNcAliasRef,
ncLinkMappingTable,
syncDB,
source,
services,
logBasic,
logDetailed,
logWarning,
}).catch((e) => {
logWarning(
`There were errors on importing '${table.title}' LTAR data :: ${e}`,
);
});
let tempData = [];
let importedCount = 0;
let tempCount = 0;
@ -173,6 +193,7 @@ export async function importData({
body: insertArray,
cookie: {},
skip_hooks: true,
foreign_key_checks: !!source.isMeta(),
});
logBasic(
@ -218,6 +239,7 @@ export async function importData({
body: tempData,
cookie: {},
skip_hooks: true,
foreign_key_checks: !!source.isMeta(),
});
logBasic(
@ -258,6 +280,7 @@ export async function importLTARData({
atNcAliasRef,
ncLinkMappingTable,
syncDB,
source,
services,
logBasic = (_str) => {},
logDetailed = (_str) => {},
@ -276,6 +299,7 @@ export async function importLTARData({
};
ncLinkMappingTable: Record<string, Record<string, any>>[];
syncDB;
source: Source;
services: AirtableImportContext;
logBasic: (string) => void;
logDetailed: (string) => void;
@ -388,6 +412,7 @@ export async function importLTARData({
body: insertArray,
cookie: {},
skip_hooks: true,
foreign_key_checks: !!source.isMeta(),
});
importedCount += insertArray.length;
@ -426,6 +451,7 @@ export async function importLTARData({
body: assocTableData,
cookie: {},
skip_hooks: true,
foreign_key_checks: !!source.isMeta(),
});
importedCount += assocTableData.length;

Loading…
Cancel
Save