From a4a9aae373bbf8456a3886b962b220f106b484da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Mon, 3 Jun 2024 15:14:45 +0200 Subject: [PATCH] refactor(core): Remove dead code that disabled auto-generated ids during import (no-changelog) This code was added in https://github.com/n8n-io/n8n/pull/5231 before we switched workflow/credential IDs from numbers to strings in https://github.com/n8n-io/n8n/pull/6345 --- packages/cli/src/commands/import/credentials.ts | 6 ------ packages/cli/src/commands/import/workflow.ts | 8 +------- packages/cli/src/databases/utils/commandHelpers.ts | 11 ----------- 3 files changed, 1 insertion(+), 24 deletions(-) delete mode 100644 packages/cli/src/databases/utils/commandHelpers.ts diff --git a/packages/cli/src/commands/import/credentials.ts b/packages/cli/src/commands/import/credentials.ts index 6c47a25d96d13..9fe908ff2d3c1 100644 --- a/packages/cli/src/commands/import/credentials.ts +++ b/packages/cli/src/commands/import/credentials.ts @@ -8,7 +8,6 @@ import type { EntityManager } from '@n8n/typeorm'; import * as Db from '@/Db'; import { SharedCredentials } from '@db/entities/SharedCredentials'; import { CredentialsEntity } from '@db/entities/CredentialsEntity'; -import { disableAutoGeneratedIds } from '@db/utils/commandHelpers'; import { BaseCommand } from '../BaseCommand'; import type { ICredentialsEncrypted } from 'n8n-workflow'; import { ApplicationError, jsonParse } from 'n8n-workflow'; @@ -47,11 +46,6 @@ export class ImportCredentialsCommand extends BaseCommand { private transactionManager: EntityManager; - async init() { - disableAutoGeneratedIds(CredentialsEntity); - await super.init(); - } - async run(): Promise { const { flags } = await this.parse(ImportCredentialsCommand); diff --git a/packages/cli/src/commands/import/workflow.ts b/packages/cli/src/commands/import/workflow.ts index 87bb590d6b09c..dcf72a9c9a0d9 100644 --- a/packages/cli/src/commands/import/workflow.ts +++ b/packages/cli/src/commands/import/workflow.ts @@ -5,8 +5,7 @@ import fs from 'fs'; import glob from 'fast-glob'; import { UM_FIX_INSTRUCTION } from '@/constants'; -import { WorkflowEntity } from '@db/entities/WorkflowEntity'; -import { disableAutoGeneratedIds } from '@db/utils/commandHelpers'; +import type { WorkflowEntity } from '@db/entities/WorkflowEntity'; import { generateNanoId } from '@db/utils/generators'; import { UserRepository } from '@db/repositories/user.repository'; import { WorkflowRepository } from '@db/repositories/workflow.repository'; @@ -62,11 +61,6 @@ export class ImportWorkflowsCommand extends BaseCommand { }), }; - async init() { - disableAutoGeneratedIds(WorkflowEntity); - await super.init(); - } - async run(): Promise { const { flags } = await this.parse(ImportWorkflowsCommand); diff --git a/packages/cli/src/databases/utils/commandHelpers.ts b/packages/cli/src/databases/utils/commandHelpers.ts deleted file mode 100644 index f522da354e1a7..0000000000000 --- a/packages/cli/src/databases/utils/commandHelpers.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { WorkflowEntity } from '@db/entities/WorkflowEntity'; -import type { CredentialsEntity } from '@db/entities/CredentialsEntity'; -import { getMetadataArgsStorage } from '@n8n/typeorm'; - -export const disableAutoGeneratedIds = ( - entityClass: typeof WorkflowEntity | typeof CredentialsEntity, -): void => { - const decoratorMetadata = getMetadataArgsStorage().generations; - const index = decoratorMetadata.findIndex((metadata) => metadata.target === entityClass); - decoratorMetadata.splice(index, 1); -};