From 189009a8b7a46c649c39a0c086b4fd4c1f7fe893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Sat, 18 Jun 2022 07:15:03 +0200 Subject: [PATCH] refactor(core): Improve DB directory setup (#3502) --- packages/cli/migrations/ormconfig.ts | 75 ------------------- packages/cli/src/Db.ts | 6 +- .../cli/src/databases/MigrationHelpers.ts | 39 ---------- .../1588157391238-InitialMigration.ts | 0 .../mysqldb}/1592447867632-WebhookModel.ts | 0 .../1594902918301-CreateIndexStoppedAt.ts | 0 .../1607431743767-MakeStoppedAtNullable.ts | 0 .../mysqldb}/1611149998770-AddWebhookId.ts | 0 .../mysqldb}/1615306975123-ChangeDataSize.ts | 0 .../mysqldb}/1617268711084-CreateTagEntity.ts | 0 .../1620729500000-ChangeCredentialDataSize.ts | 0 .../1620826335440-UniqueWorkflowNames.ts | 0 .../1623936588000-CertifyCorrectCollation.ts | 0 .../mysqldb}/1626183952959-AddWaitColumn.ts | 0 ...1630451444017-UpdateWorkflowCredentials.ts | 13 ++-- ...1644424784709-AddExecutionEntityIndexes.ts | 0 .../1646992772331-CreateUserManagement.ts | 0 .../1648740597343-LowerCaseUserEmail.ts | 0 .../mysqldb}/1652367743993-AddUserSettings.ts | 0 .../mysqldb}/1652905585850-AddAPIKeyColumn.ts | 0 .../mysqldb}/index.ts | 0 .../1587669153312-InitialMigration.ts | 0 .../postgresdb}/1589476000887-WebhookModel.ts | 0 .../1594828256133-CreateIndexStoppedAt.ts | 0 .../1607431743768-MakeStoppedAtNullable.ts | 0 .../postgresdb}/1611144599516-AddWebhookId.ts | 0 .../1617270242566-CreateTagEntity.ts | 0 .../1620824779533-UniqueWorkflowNames.ts | 0 .../postgresdb}/1626176912946-AddwaitTill.ts | 0 ...1630419189837-UpdateWorkflowCredentials.ts | 13 ++-- ...1644422880309-AddExecutionEntityIndexes.ts | 0 .../1646834195327-IncreaseTypeVarcharLimit.ts | 0 .../1646992772331-CreateUserManagement.ts | 0 .../1648740597343-LowerCaseUserEmail.ts | 0 .../1652367743993-AddUserSettings.ts | 0 .../1652905585850-AddAPIKeyColumn.ts | 0 .../postgresdb}/index.ts | 0 .../sqlite}/1588102412422-InitialMigration.ts | 0 .../sqlite}/1592445003908-WebhookModel.ts | 0 .../1594825041918-CreateIndexStoppedAt.ts | 0 .../1607431743769-MakeStoppedAtNullable.ts | 0 .../sqlite}/1611071044839-AddWebhookId.ts | 0 .../sqlite}/1617213344594-CreateTagEntity.ts | 0 .../1620821879465-UniqueWorkflowNames.ts | 0 .../sqlite}/1621707690587-AddWaitColumn.ts | 0 ...1630330987096-UpdateWorkflowCredentials.ts | 12 ++- ...1644421939510-AddExecutionEntityIndexes.ts | 0 .../1646992772331-CreateUserManagement.ts | 0 .../1648740597343-LowerCaseUserEmail.ts | 0 .../sqlite}/1652367743993-AddUserSettings.ts | 0 .../sqlite}/1652905585850-AddAPIKeyColumn.ts | 0 .../migrations => migrations/sqlite}/index.ts | 2 - packages/cli/src/databases/ormconfig.ts | 67 +++++++++++++++++ .../src/databases/utils/migrationHelpers.ts | 30 ++++++++ .../cli/test/integration/shared/testDb.ts | 6 +- 55 files changed, 120 insertions(+), 143 deletions(-) delete mode 100644 packages/cli/migrations/ormconfig.ts delete mode 100644 packages/cli/src/databases/MigrationHelpers.ts rename packages/cli/src/databases/{mysqldb/migrations => migrations/mysqldb}/1588157391238-InitialMigration.ts (100%) rename packages/cli/src/databases/{mysqldb/migrations => migrations/mysqldb}/1592447867632-WebhookModel.ts (100%) rename packages/cli/src/databases/{mysqldb/migrations => migrations/mysqldb}/1594902918301-CreateIndexStoppedAt.ts (100%) rename packages/cli/src/databases/{mysqldb/migrations => migrations/mysqldb}/1607431743767-MakeStoppedAtNullable.ts (100%) rename packages/cli/src/databases/{mysqldb/migrations => migrations/mysqldb}/1611149998770-AddWebhookId.ts (100%) rename packages/cli/src/databases/{mysqldb/migrations => migrations/mysqldb}/1615306975123-ChangeDataSize.ts (100%) rename packages/cli/src/databases/{mysqldb/migrations => migrations/mysqldb}/1617268711084-CreateTagEntity.ts (100%) rename packages/cli/src/databases/{mysqldb/migrations => migrations/mysqldb}/1620729500000-ChangeCredentialDataSize.ts (100%) rename packages/cli/src/databases/{mysqldb/migrations => migrations/mysqldb}/1620826335440-UniqueWorkflowNames.ts (100%) rename packages/cli/src/databases/{mysqldb/migrations => migrations/mysqldb}/1623936588000-CertifyCorrectCollation.ts (100%) rename packages/cli/src/databases/{mysqldb/migrations => migrations/mysqldb}/1626183952959-AddWaitColumn.ts (100%) rename packages/cli/src/databases/{mysqldb/migrations => migrations/mysqldb}/1630451444017-UpdateWorkflowCredentials.ts (95%) rename packages/cli/src/databases/{mysqldb/migrations => migrations/mysqldb}/1644424784709-AddExecutionEntityIndexes.ts (100%) rename packages/cli/src/databases/{mysqldb/migrations => migrations/mysqldb}/1646992772331-CreateUserManagement.ts (100%) rename packages/cli/src/databases/{mysqldb/migrations => migrations/mysqldb}/1648740597343-LowerCaseUserEmail.ts (100%) rename packages/cli/src/databases/{mysqldb/migrations => migrations/mysqldb}/1652367743993-AddUserSettings.ts (100%) rename packages/cli/src/databases/{mysqldb/migrations => migrations/mysqldb}/1652905585850-AddAPIKeyColumn.ts (100%) rename packages/cli/src/databases/{mysqldb/migrations => migrations/mysqldb}/index.ts (100%) rename packages/cli/src/databases/{postgresdb/migrations => migrations/postgresdb}/1587669153312-InitialMigration.ts (100%) rename packages/cli/src/databases/{postgresdb/migrations => migrations/postgresdb}/1589476000887-WebhookModel.ts (100%) rename packages/cli/src/databases/{postgresdb/migrations => migrations/postgresdb}/1594828256133-CreateIndexStoppedAt.ts (100%) rename packages/cli/src/databases/{postgresdb/migrations => migrations/postgresdb}/1607431743768-MakeStoppedAtNullable.ts (100%) rename packages/cli/src/databases/{postgresdb/migrations => migrations/postgresdb}/1611144599516-AddWebhookId.ts (100%) rename packages/cli/src/databases/{postgresdb/migrations => migrations/postgresdb}/1617270242566-CreateTagEntity.ts (100%) rename packages/cli/src/databases/{postgresdb/migrations => migrations/postgresdb}/1620824779533-UniqueWorkflowNames.ts (100%) rename packages/cli/src/databases/{postgresdb/migrations => migrations/postgresdb}/1626176912946-AddwaitTill.ts (100%) rename packages/cli/src/databases/{postgresdb/migrations => migrations/postgresdb}/1630419189837-UpdateWorkflowCredentials.ts (95%) rename packages/cli/src/databases/{postgresdb/migrations => migrations/postgresdb}/1644422880309-AddExecutionEntityIndexes.ts (100%) rename packages/cli/src/databases/{postgresdb/migrations => migrations/postgresdb}/1646834195327-IncreaseTypeVarcharLimit.ts (100%) rename packages/cli/src/databases/{postgresdb/migrations => migrations/postgresdb}/1646992772331-CreateUserManagement.ts (100%) rename packages/cli/src/databases/{postgresdb/migrations => migrations/postgresdb}/1648740597343-LowerCaseUserEmail.ts (100%) rename packages/cli/src/databases/{postgresdb/migrations => migrations/postgresdb}/1652367743993-AddUserSettings.ts (100%) rename packages/cli/src/databases/{postgresdb/migrations => migrations/postgresdb}/1652905585850-AddAPIKeyColumn.ts (100%) rename packages/cli/src/databases/{postgresdb/migrations => migrations/postgresdb}/index.ts (100%) rename packages/cli/src/databases/{sqlite/migrations => migrations/sqlite}/1588102412422-InitialMigration.ts (100%) rename packages/cli/src/databases/{sqlite/migrations => migrations/sqlite}/1592445003908-WebhookModel.ts (100%) rename packages/cli/src/databases/{sqlite/migrations => migrations/sqlite}/1594825041918-CreateIndexStoppedAt.ts (100%) rename packages/cli/src/databases/{sqlite/migrations => migrations/sqlite}/1607431743769-MakeStoppedAtNullable.ts (100%) rename packages/cli/src/databases/{sqlite/migrations => migrations/sqlite}/1611071044839-AddWebhookId.ts (100%) rename packages/cli/src/databases/{sqlite/migrations => migrations/sqlite}/1617213344594-CreateTagEntity.ts (100%) rename packages/cli/src/databases/{sqlite/migrations => migrations/sqlite}/1620821879465-UniqueWorkflowNames.ts (100%) rename packages/cli/src/databases/{sqlite/migrations => migrations/sqlite}/1621707690587-AddWaitColumn.ts (100%) rename packages/cli/src/databases/{sqlite/migrations => migrations/sqlite}/1630330987096-UpdateWorkflowCredentials.ts (95%) rename packages/cli/src/databases/{sqlite/migrations => migrations/sqlite}/1644421939510-AddExecutionEntityIndexes.ts (100%) rename packages/cli/src/databases/{sqlite/migrations => migrations/sqlite}/1646992772331-CreateUserManagement.ts (100%) rename packages/cli/src/databases/{sqlite/migrations => migrations/sqlite}/1648740597343-LowerCaseUserEmail.ts (100%) rename packages/cli/src/databases/{sqlite/migrations => migrations/sqlite}/1652367743993-AddUserSettings.ts (100%) rename packages/cli/src/databases/{sqlite/migrations => migrations/sqlite}/1652905585850-AddAPIKeyColumn.ts (100%) rename packages/cli/src/databases/{sqlite/migrations => migrations/sqlite}/index.ts (97%) create mode 100644 packages/cli/src/databases/ormconfig.ts diff --git a/packages/cli/migrations/ormconfig.ts b/packages/cli/migrations/ormconfig.ts deleted file mode 100644 index 2ca697e88e..0000000000 --- a/packages/cli/migrations/ormconfig.ts +++ /dev/null @@ -1,75 +0,0 @@ -import path from 'path'; -import { UserSettings } from 'n8n-core'; -import { entities } from '../src/databases/entities'; - -module.exports = [ - { - name: 'sqlite', - type: 'sqlite', - logging: true, - entities: Object.values(entities), - database: path.join(UserSettings.getUserN8nFolderPath(), 'database.sqlite'), - migrations: ['./src/databases/sqlite/migrations/index.ts'], - subscribers: ['./src/databases/sqlite/subscribers/*.ts'], - cli: { - entitiesDir: './src/databases/entities', - migrationsDir: './src/databases/sqlite/migrations', - subscribersDir: './src/databases/sqlite/subscribers', - }, - }, - { - name: 'postgres', - type: 'postgres', - logging: false, - host: 'localhost', - username: 'postgres', - password: '', - port: 5432, - database: 'n8n', - schema: 'public', - entities: Object.values(entities), - migrations: ['./src/databases/postgresdb/migrations/index.ts'], - subscribers: ['src/subscriber/**/*.ts'], - cli: { - entitiesDir: './src/databases/entities', - migrationsDir: './src/databases/postgresdb/migrations', - subscribersDir: './src/databases/postgresdb/subscribers', - }, - }, - { - name: 'mysql', - type: 'mysql', - database: 'n8n', - username: 'root', - password: 'password', - host: 'localhost', - port: '3306', - logging: false, - entities: Object.values(entities), - migrations: ['./src/databases/mysqldb/migrations/index.ts'], - subscribers: ['src/subscriber/**/*.ts'], - cli: { - entitiesDir: './src/databases/entities', - migrationsDir: './src/databases/mysqldb/migrations', - subscribersDir: './src/databases/mysqldb/Subscribers', - }, - }, - { - name: 'mariadb', - type: 'mariadb', - database: 'n8n', - username: 'root', - password: 'password', - host: 'localhost', - port: '3306', - logging: false, - entities: Object.values(entities), - migrations: ['./src/databases/mysqldb/migrations/*.ts'], - subscribers: ['src/subscriber/**/*.ts'], - cli: { - entitiesDir: './src/databases/entities', - migrationsDir: './src/databases/mysqldb/migrations', - subscribersDir: './src/databases/mysqldb/Subscribers', - }, - }, -]; diff --git a/packages/cli/src/Db.ts b/packages/cli/src/Db.ts index 5d9008ce75..f1e95e1815 100644 --- a/packages/cli/src/Db.ts +++ b/packages/cli/src/Db.ts @@ -25,9 +25,9 @@ import config from '../config'; // eslint-disable-next-line import/no-cycle import { entities } from './databases/entities'; -import { postgresMigrations } from './databases/postgresdb/migrations'; -import { mysqlMigrations } from './databases/mysqldb/migrations'; -import { sqliteMigrations } from './databases/sqlite/migrations'; +import { postgresMigrations } from './databases/migrations/postgresdb'; +import { mysqlMigrations } from './databases/migrations/mysqldb'; +import { sqliteMigrations } from './databases/migrations/sqlite'; export let isInitialized = false; export const collections = {} as IDatabaseCollections; diff --git a/packages/cli/src/databases/MigrationHelpers.ts b/packages/cli/src/databases/MigrationHelpers.ts deleted file mode 100644 index 7db121bd85..0000000000 --- a/packages/cli/src/databases/MigrationHelpers.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { QueryRunner } from 'typeorm'; - -export class MigrationHelpers { - queryRunner: QueryRunner; - - constructor(queryRunner: QueryRunner) { - this.queryRunner = queryRunner; - } - - // runs an operation sequential on chunks of a query that returns a potentially large Array. - /* eslint-disable no-await-in-loop */ - async runChunked( - query: string, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - operation: (results: any[]) => Promise, - limit = 100, - ): Promise { - let offset = 0; - let chunkedQuery: string; - let chunkedQueryResults: unknown[]; - - do { - chunkedQuery = this.chunkQuery(query, limit, offset); - chunkedQueryResults = (await this.queryRunner.query(chunkedQuery)) as unknown[]; - // pass a copy to prevent errors from mutation - await operation([...chunkedQueryResults]); - offset += limit; - } while (chunkedQueryResults.length === limit); - } - /* eslint-enable no-await-in-loop */ - - private chunkQuery(query: string, limit: number, offset = 0): string { - return ` - ${query} - LIMIT ${limit} - OFFSET ${offset} - `; - } -} diff --git a/packages/cli/src/databases/mysqldb/migrations/1588157391238-InitialMigration.ts b/packages/cli/src/databases/migrations/mysqldb/1588157391238-InitialMigration.ts similarity index 100% rename from packages/cli/src/databases/mysqldb/migrations/1588157391238-InitialMigration.ts rename to packages/cli/src/databases/migrations/mysqldb/1588157391238-InitialMigration.ts diff --git a/packages/cli/src/databases/mysqldb/migrations/1592447867632-WebhookModel.ts b/packages/cli/src/databases/migrations/mysqldb/1592447867632-WebhookModel.ts similarity index 100% rename from packages/cli/src/databases/mysqldb/migrations/1592447867632-WebhookModel.ts rename to packages/cli/src/databases/migrations/mysqldb/1592447867632-WebhookModel.ts diff --git a/packages/cli/src/databases/mysqldb/migrations/1594902918301-CreateIndexStoppedAt.ts b/packages/cli/src/databases/migrations/mysqldb/1594902918301-CreateIndexStoppedAt.ts similarity index 100% rename from packages/cli/src/databases/mysqldb/migrations/1594902918301-CreateIndexStoppedAt.ts rename to packages/cli/src/databases/migrations/mysqldb/1594902918301-CreateIndexStoppedAt.ts diff --git a/packages/cli/src/databases/mysqldb/migrations/1607431743767-MakeStoppedAtNullable.ts b/packages/cli/src/databases/migrations/mysqldb/1607431743767-MakeStoppedAtNullable.ts similarity index 100% rename from packages/cli/src/databases/mysqldb/migrations/1607431743767-MakeStoppedAtNullable.ts rename to packages/cli/src/databases/migrations/mysqldb/1607431743767-MakeStoppedAtNullable.ts diff --git a/packages/cli/src/databases/mysqldb/migrations/1611149998770-AddWebhookId.ts b/packages/cli/src/databases/migrations/mysqldb/1611149998770-AddWebhookId.ts similarity index 100% rename from packages/cli/src/databases/mysqldb/migrations/1611149998770-AddWebhookId.ts rename to packages/cli/src/databases/migrations/mysqldb/1611149998770-AddWebhookId.ts diff --git a/packages/cli/src/databases/mysqldb/migrations/1615306975123-ChangeDataSize.ts b/packages/cli/src/databases/migrations/mysqldb/1615306975123-ChangeDataSize.ts similarity index 100% rename from packages/cli/src/databases/mysqldb/migrations/1615306975123-ChangeDataSize.ts rename to packages/cli/src/databases/migrations/mysqldb/1615306975123-ChangeDataSize.ts diff --git a/packages/cli/src/databases/mysqldb/migrations/1617268711084-CreateTagEntity.ts b/packages/cli/src/databases/migrations/mysqldb/1617268711084-CreateTagEntity.ts similarity index 100% rename from packages/cli/src/databases/mysqldb/migrations/1617268711084-CreateTagEntity.ts rename to packages/cli/src/databases/migrations/mysqldb/1617268711084-CreateTagEntity.ts diff --git a/packages/cli/src/databases/mysqldb/migrations/1620729500000-ChangeCredentialDataSize.ts b/packages/cli/src/databases/migrations/mysqldb/1620729500000-ChangeCredentialDataSize.ts similarity index 100% rename from packages/cli/src/databases/mysqldb/migrations/1620729500000-ChangeCredentialDataSize.ts rename to packages/cli/src/databases/migrations/mysqldb/1620729500000-ChangeCredentialDataSize.ts diff --git a/packages/cli/src/databases/mysqldb/migrations/1620826335440-UniqueWorkflowNames.ts b/packages/cli/src/databases/migrations/mysqldb/1620826335440-UniqueWorkflowNames.ts similarity index 100% rename from packages/cli/src/databases/mysqldb/migrations/1620826335440-UniqueWorkflowNames.ts rename to packages/cli/src/databases/migrations/mysqldb/1620826335440-UniqueWorkflowNames.ts diff --git a/packages/cli/src/databases/mysqldb/migrations/1623936588000-CertifyCorrectCollation.ts b/packages/cli/src/databases/migrations/mysqldb/1623936588000-CertifyCorrectCollation.ts similarity index 100% rename from packages/cli/src/databases/mysqldb/migrations/1623936588000-CertifyCorrectCollation.ts rename to packages/cli/src/databases/migrations/mysqldb/1623936588000-CertifyCorrectCollation.ts diff --git a/packages/cli/src/databases/mysqldb/migrations/1626183952959-AddWaitColumn.ts b/packages/cli/src/databases/migrations/mysqldb/1626183952959-AddWaitColumn.ts similarity index 100% rename from packages/cli/src/databases/mysqldb/migrations/1626183952959-AddWaitColumn.ts rename to packages/cli/src/databases/migrations/mysqldb/1626183952959-AddWaitColumn.ts diff --git a/packages/cli/src/databases/mysqldb/migrations/1630451444017-UpdateWorkflowCredentials.ts b/packages/cli/src/databases/migrations/mysqldb/1630451444017-UpdateWorkflowCredentials.ts similarity index 95% rename from packages/cli/src/databases/mysqldb/migrations/1630451444017-UpdateWorkflowCredentials.ts rename to packages/cli/src/databases/migrations/mysqldb/1630451444017-UpdateWorkflowCredentials.ts index 15bee7fafe..a4f12cb9d8 100644 --- a/packages/cli/src/databases/mysqldb/migrations/1630451444017-UpdateWorkflowCredentials.ts +++ b/packages/cli/src/databases/migrations/mysqldb/1630451444017-UpdateWorkflowCredentials.ts @@ -1,6 +1,6 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; import * as config from '../../../../config'; -import { MigrationHelpers } from '../../MigrationHelpers'; +import { runChunked } from '../../utils/migrationHelpers'; // replacing the credentials in workflows and execution // `nodeType: name` changes to `nodeType: { id, name }` @@ -10,7 +10,6 @@ export class UpdateWorkflowCredentials1630451444017 implements MigrationInterfac public async up(queryRunner: QueryRunner): Promise { const tablePrefix = config.getEnv('database.tablePrefix'); - const helpers = new MigrationHelpers(queryRunner); const credentialsEntities = await queryRunner.query(` SELECT id, name, type @@ -21,8 +20,9 @@ export class UpdateWorkflowCredentials1630451444017 implements MigrationInterfac SELECT id, nodes FROM ${tablePrefix}workflow_entity `; + // @ts-ignore - await helpers.runChunked(workflowsQuery, (workflows) => { + await runChunked(queryRunner, workflowsQuery, (workflows) => { workflows.forEach(async (workflow) => { const nodes = workflow.nodes; let credentialsUpdated = false; @@ -65,7 +65,7 @@ export class UpdateWorkflowCredentials1630451444017 implements MigrationInterfac WHERE waitTill IS NOT NULL AND finished = 0 `; // @ts-ignore - await helpers.runChunked(waitingExecutionsQuery, (waitingExecutions) => { + await runChunked(queryRunner, waitingExecutionsQuery, (waitingExecutions) => { waitingExecutions.forEach(async (execution) => { const data = execution.workflowData; let credentialsUpdated = false; @@ -147,7 +147,6 @@ export class UpdateWorkflowCredentials1630451444017 implements MigrationInterfac public async down(queryRunner: QueryRunner): Promise { const tablePrefix = config.getEnv('database.tablePrefix'); - const helpers = new MigrationHelpers(queryRunner); const credentialsEntities = await queryRunner.query(` SELECT id, name, type @@ -159,7 +158,7 @@ export class UpdateWorkflowCredentials1630451444017 implements MigrationInterfac FROM ${tablePrefix}workflow_entity `; // @ts-ignore - await helpers.runChunked(workflowsQuery, (workflows) => { + await runChunked(queryRunner, workflowsQuery, (workflows) => { workflows.forEach(async (workflow) => { const nodes = workflow.nodes; let credentialsUpdated = false; @@ -207,7 +206,7 @@ export class UpdateWorkflowCredentials1630451444017 implements MigrationInterfac WHERE waitTill IS NOT NULL AND finished = 0 `; // @ts-ignore - await helpers.runChunked(waitingExecutionsQuery, (waitingExecutions) => { + await runChunked(queryRunner, waitingExecutionsQuery, (waitingExecutions) => { waitingExecutions.forEach(async (execution) => { const data = execution.workflowData; let credentialsUpdated = false; diff --git a/packages/cli/src/databases/mysqldb/migrations/1644424784709-AddExecutionEntityIndexes.ts b/packages/cli/src/databases/migrations/mysqldb/1644424784709-AddExecutionEntityIndexes.ts similarity index 100% rename from packages/cli/src/databases/mysqldb/migrations/1644424784709-AddExecutionEntityIndexes.ts rename to packages/cli/src/databases/migrations/mysqldb/1644424784709-AddExecutionEntityIndexes.ts diff --git a/packages/cli/src/databases/mysqldb/migrations/1646992772331-CreateUserManagement.ts b/packages/cli/src/databases/migrations/mysqldb/1646992772331-CreateUserManagement.ts similarity index 100% rename from packages/cli/src/databases/mysqldb/migrations/1646992772331-CreateUserManagement.ts rename to packages/cli/src/databases/migrations/mysqldb/1646992772331-CreateUserManagement.ts diff --git a/packages/cli/src/databases/mysqldb/migrations/1648740597343-LowerCaseUserEmail.ts b/packages/cli/src/databases/migrations/mysqldb/1648740597343-LowerCaseUserEmail.ts similarity index 100% rename from packages/cli/src/databases/mysqldb/migrations/1648740597343-LowerCaseUserEmail.ts rename to packages/cli/src/databases/migrations/mysqldb/1648740597343-LowerCaseUserEmail.ts diff --git a/packages/cli/src/databases/mysqldb/migrations/1652367743993-AddUserSettings.ts b/packages/cli/src/databases/migrations/mysqldb/1652367743993-AddUserSettings.ts similarity index 100% rename from packages/cli/src/databases/mysqldb/migrations/1652367743993-AddUserSettings.ts rename to packages/cli/src/databases/migrations/mysqldb/1652367743993-AddUserSettings.ts diff --git a/packages/cli/src/databases/mysqldb/migrations/1652905585850-AddAPIKeyColumn.ts b/packages/cli/src/databases/migrations/mysqldb/1652905585850-AddAPIKeyColumn.ts similarity index 100% rename from packages/cli/src/databases/mysqldb/migrations/1652905585850-AddAPIKeyColumn.ts rename to packages/cli/src/databases/migrations/mysqldb/1652905585850-AddAPIKeyColumn.ts diff --git a/packages/cli/src/databases/mysqldb/migrations/index.ts b/packages/cli/src/databases/migrations/mysqldb/index.ts similarity index 100% rename from packages/cli/src/databases/mysqldb/migrations/index.ts rename to packages/cli/src/databases/migrations/mysqldb/index.ts diff --git a/packages/cli/src/databases/postgresdb/migrations/1587669153312-InitialMigration.ts b/packages/cli/src/databases/migrations/postgresdb/1587669153312-InitialMigration.ts similarity index 100% rename from packages/cli/src/databases/postgresdb/migrations/1587669153312-InitialMigration.ts rename to packages/cli/src/databases/migrations/postgresdb/1587669153312-InitialMigration.ts diff --git a/packages/cli/src/databases/postgresdb/migrations/1589476000887-WebhookModel.ts b/packages/cli/src/databases/migrations/postgresdb/1589476000887-WebhookModel.ts similarity index 100% rename from packages/cli/src/databases/postgresdb/migrations/1589476000887-WebhookModel.ts rename to packages/cli/src/databases/migrations/postgresdb/1589476000887-WebhookModel.ts diff --git a/packages/cli/src/databases/postgresdb/migrations/1594828256133-CreateIndexStoppedAt.ts b/packages/cli/src/databases/migrations/postgresdb/1594828256133-CreateIndexStoppedAt.ts similarity index 100% rename from packages/cli/src/databases/postgresdb/migrations/1594828256133-CreateIndexStoppedAt.ts rename to packages/cli/src/databases/migrations/postgresdb/1594828256133-CreateIndexStoppedAt.ts diff --git a/packages/cli/src/databases/postgresdb/migrations/1607431743768-MakeStoppedAtNullable.ts b/packages/cli/src/databases/migrations/postgresdb/1607431743768-MakeStoppedAtNullable.ts similarity index 100% rename from packages/cli/src/databases/postgresdb/migrations/1607431743768-MakeStoppedAtNullable.ts rename to packages/cli/src/databases/migrations/postgresdb/1607431743768-MakeStoppedAtNullable.ts diff --git a/packages/cli/src/databases/postgresdb/migrations/1611144599516-AddWebhookId.ts b/packages/cli/src/databases/migrations/postgresdb/1611144599516-AddWebhookId.ts similarity index 100% rename from packages/cli/src/databases/postgresdb/migrations/1611144599516-AddWebhookId.ts rename to packages/cli/src/databases/migrations/postgresdb/1611144599516-AddWebhookId.ts diff --git a/packages/cli/src/databases/postgresdb/migrations/1617270242566-CreateTagEntity.ts b/packages/cli/src/databases/migrations/postgresdb/1617270242566-CreateTagEntity.ts similarity index 100% rename from packages/cli/src/databases/postgresdb/migrations/1617270242566-CreateTagEntity.ts rename to packages/cli/src/databases/migrations/postgresdb/1617270242566-CreateTagEntity.ts diff --git a/packages/cli/src/databases/postgresdb/migrations/1620824779533-UniqueWorkflowNames.ts b/packages/cli/src/databases/migrations/postgresdb/1620824779533-UniqueWorkflowNames.ts similarity index 100% rename from packages/cli/src/databases/postgresdb/migrations/1620824779533-UniqueWorkflowNames.ts rename to packages/cli/src/databases/migrations/postgresdb/1620824779533-UniqueWorkflowNames.ts diff --git a/packages/cli/src/databases/postgresdb/migrations/1626176912946-AddwaitTill.ts b/packages/cli/src/databases/migrations/postgresdb/1626176912946-AddwaitTill.ts similarity index 100% rename from packages/cli/src/databases/postgresdb/migrations/1626176912946-AddwaitTill.ts rename to packages/cli/src/databases/migrations/postgresdb/1626176912946-AddwaitTill.ts diff --git a/packages/cli/src/databases/postgresdb/migrations/1630419189837-UpdateWorkflowCredentials.ts b/packages/cli/src/databases/migrations/postgresdb/1630419189837-UpdateWorkflowCredentials.ts similarity index 95% rename from packages/cli/src/databases/postgresdb/migrations/1630419189837-UpdateWorkflowCredentials.ts rename to packages/cli/src/databases/migrations/postgresdb/1630419189837-UpdateWorkflowCredentials.ts index 9edb94cebc..14766960cc 100644 --- a/packages/cli/src/databases/postgresdb/migrations/1630419189837-UpdateWorkflowCredentials.ts +++ b/packages/cli/src/databases/migrations/postgresdb/1630419189837-UpdateWorkflowCredentials.ts @@ -1,6 +1,6 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; import * as config from '../../../../config'; -import { MigrationHelpers } from '../../MigrationHelpers'; +import { runChunked } from '../../utils/migrationHelpers'; // replacing the credentials in workflows and execution // `nodeType: name` changes to `nodeType: { id, name }` @@ -17,7 +17,6 @@ export class UpdateWorkflowCredentials1630419189837 implements MigrationInterfac await queryRunner.query(`SET search_path TO ${schema};`); - const helpers = new MigrationHelpers(queryRunner); const credentialsEntities = await queryRunner.query(` SELECT id, name, type @@ -28,8 +27,9 @@ export class UpdateWorkflowCredentials1630419189837 implements MigrationInterfac SELECT id, nodes FROM ${tablePrefix}workflow_entity `; + // @ts-ignore - await helpers.runChunked(workflowsQuery, (workflows) => { + await runChunked(queryRunner, workflowsQuery, (workflows) => { workflows.forEach(async (workflow) => { const nodes = workflow.nodes; let credentialsUpdated = false; @@ -72,7 +72,7 @@ export class UpdateWorkflowCredentials1630419189837 implements MigrationInterfac WHERE "waitTill" IS NOT NULL AND finished = FALSE `; // @ts-ignore - await helpers.runChunked(waitingExecutionsQuery, (waitingExecutions) => { + await runChunked(queryRunner, waitingExecutionsQuery, (waitingExecutions) => { waitingExecutions.forEach(async (execution) => { const data = execution.workflowData; let credentialsUpdated = false; @@ -161,7 +161,6 @@ export class UpdateWorkflowCredentials1630419189837 implements MigrationInterfac tablePrefix = schema + '.' + tablePrefix; } await queryRunner.query(`SET search_path TO ${schema};`); - const helpers = new MigrationHelpers(queryRunner); const credentialsEntities = await queryRunner.query(` SELECT id, name, type @@ -173,7 +172,7 @@ export class UpdateWorkflowCredentials1630419189837 implements MigrationInterfac FROM ${tablePrefix}workflow_entity `; // @ts-ignore - await helpers.runChunked(workflowsQuery, (workflows) => { + await runChunked(queryRunner, workflowsQuery, (workflows) => { workflows.forEach(async (workflow) => { const nodes = workflow.nodes; let credentialsUpdated = false; @@ -222,7 +221,7 @@ export class UpdateWorkflowCredentials1630419189837 implements MigrationInterfac WHERE "waitTill" IS NOT NULL AND finished = FALSE `; // @ts-ignore - await helpers.runChunked(waitingExecutionsQuery, (waitingExecutions) => { + await runChunked(queryRunner, waitingExecutionsQuery, (waitingExecutions) => { waitingExecutions.forEach(async (execution) => { const data = execution.workflowData; let credentialsUpdated = false; diff --git a/packages/cli/src/databases/postgresdb/migrations/1644422880309-AddExecutionEntityIndexes.ts b/packages/cli/src/databases/migrations/postgresdb/1644422880309-AddExecutionEntityIndexes.ts similarity index 100% rename from packages/cli/src/databases/postgresdb/migrations/1644422880309-AddExecutionEntityIndexes.ts rename to packages/cli/src/databases/migrations/postgresdb/1644422880309-AddExecutionEntityIndexes.ts diff --git a/packages/cli/src/databases/postgresdb/migrations/1646834195327-IncreaseTypeVarcharLimit.ts b/packages/cli/src/databases/migrations/postgresdb/1646834195327-IncreaseTypeVarcharLimit.ts similarity index 100% rename from packages/cli/src/databases/postgresdb/migrations/1646834195327-IncreaseTypeVarcharLimit.ts rename to packages/cli/src/databases/migrations/postgresdb/1646834195327-IncreaseTypeVarcharLimit.ts diff --git a/packages/cli/src/databases/postgresdb/migrations/1646992772331-CreateUserManagement.ts b/packages/cli/src/databases/migrations/postgresdb/1646992772331-CreateUserManagement.ts similarity index 100% rename from packages/cli/src/databases/postgresdb/migrations/1646992772331-CreateUserManagement.ts rename to packages/cli/src/databases/migrations/postgresdb/1646992772331-CreateUserManagement.ts diff --git a/packages/cli/src/databases/postgresdb/migrations/1648740597343-LowerCaseUserEmail.ts b/packages/cli/src/databases/migrations/postgresdb/1648740597343-LowerCaseUserEmail.ts similarity index 100% rename from packages/cli/src/databases/postgresdb/migrations/1648740597343-LowerCaseUserEmail.ts rename to packages/cli/src/databases/migrations/postgresdb/1648740597343-LowerCaseUserEmail.ts diff --git a/packages/cli/src/databases/postgresdb/migrations/1652367743993-AddUserSettings.ts b/packages/cli/src/databases/migrations/postgresdb/1652367743993-AddUserSettings.ts similarity index 100% rename from packages/cli/src/databases/postgresdb/migrations/1652367743993-AddUserSettings.ts rename to packages/cli/src/databases/migrations/postgresdb/1652367743993-AddUserSettings.ts diff --git a/packages/cli/src/databases/postgresdb/migrations/1652905585850-AddAPIKeyColumn.ts b/packages/cli/src/databases/migrations/postgresdb/1652905585850-AddAPIKeyColumn.ts similarity index 100% rename from packages/cli/src/databases/postgresdb/migrations/1652905585850-AddAPIKeyColumn.ts rename to packages/cli/src/databases/migrations/postgresdb/1652905585850-AddAPIKeyColumn.ts diff --git a/packages/cli/src/databases/postgresdb/migrations/index.ts b/packages/cli/src/databases/migrations/postgresdb/index.ts similarity index 100% rename from packages/cli/src/databases/postgresdb/migrations/index.ts rename to packages/cli/src/databases/migrations/postgresdb/index.ts diff --git a/packages/cli/src/databases/sqlite/migrations/1588102412422-InitialMigration.ts b/packages/cli/src/databases/migrations/sqlite/1588102412422-InitialMigration.ts similarity index 100% rename from packages/cli/src/databases/sqlite/migrations/1588102412422-InitialMigration.ts rename to packages/cli/src/databases/migrations/sqlite/1588102412422-InitialMigration.ts diff --git a/packages/cli/src/databases/sqlite/migrations/1592445003908-WebhookModel.ts b/packages/cli/src/databases/migrations/sqlite/1592445003908-WebhookModel.ts similarity index 100% rename from packages/cli/src/databases/sqlite/migrations/1592445003908-WebhookModel.ts rename to packages/cli/src/databases/migrations/sqlite/1592445003908-WebhookModel.ts diff --git a/packages/cli/src/databases/sqlite/migrations/1594825041918-CreateIndexStoppedAt.ts b/packages/cli/src/databases/migrations/sqlite/1594825041918-CreateIndexStoppedAt.ts similarity index 100% rename from packages/cli/src/databases/sqlite/migrations/1594825041918-CreateIndexStoppedAt.ts rename to packages/cli/src/databases/migrations/sqlite/1594825041918-CreateIndexStoppedAt.ts diff --git a/packages/cli/src/databases/sqlite/migrations/1607431743769-MakeStoppedAtNullable.ts b/packages/cli/src/databases/migrations/sqlite/1607431743769-MakeStoppedAtNullable.ts similarity index 100% rename from packages/cli/src/databases/sqlite/migrations/1607431743769-MakeStoppedAtNullable.ts rename to packages/cli/src/databases/migrations/sqlite/1607431743769-MakeStoppedAtNullable.ts diff --git a/packages/cli/src/databases/sqlite/migrations/1611071044839-AddWebhookId.ts b/packages/cli/src/databases/migrations/sqlite/1611071044839-AddWebhookId.ts similarity index 100% rename from packages/cli/src/databases/sqlite/migrations/1611071044839-AddWebhookId.ts rename to packages/cli/src/databases/migrations/sqlite/1611071044839-AddWebhookId.ts diff --git a/packages/cli/src/databases/sqlite/migrations/1617213344594-CreateTagEntity.ts b/packages/cli/src/databases/migrations/sqlite/1617213344594-CreateTagEntity.ts similarity index 100% rename from packages/cli/src/databases/sqlite/migrations/1617213344594-CreateTagEntity.ts rename to packages/cli/src/databases/migrations/sqlite/1617213344594-CreateTagEntity.ts diff --git a/packages/cli/src/databases/sqlite/migrations/1620821879465-UniqueWorkflowNames.ts b/packages/cli/src/databases/migrations/sqlite/1620821879465-UniqueWorkflowNames.ts similarity index 100% rename from packages/cli/src/databases/sqlite/migrations/1620821879465-UniqueWorkflowNames.ts rename to packages/cli/src/databases/migrations/sqlite/1620821879465-UniqueWorkflowNames.ts diff --git a/packages/cli/src/databases/sqlite/migrations/1621707690587-AddWaitColumn.ts b/packages/cli/src/databases/migrations/sqlite/1621707690587-AddWaitColumn.ts similarity index 100% rename from packages/cli/src/databases/sqlite/migrations/1621707690587-AddWaitColumn.ts rename to packages/cli/src/databases/migrations/sqlite/1621707690587-AddWaitColumn.ts diff --git a/packages/cli/src/databases/sqlite/migrations/1630330987096-UpdateWorkflowCredentials.ts b/packages/cli/src/databases/migrations/sqlite/1630330987096-UpdateWorkflowCredentials.ts similarity index 95% rename from packages/cli/src/databases/sqlite/migrations/1630330987096-UpdateWorkflowCredentials.ts rename to packages/cli/src/databases/migrations/sqlite/1630330987096-UpdateWorkflowCredentials.ts index 4b60c12f7f..8bb8d8efd4 100644 --- a/packages/cli/src/databases/sqlite/migrations/1630330987096-UpdateWorkflowCredentials.ts +++ b/packages/cli/src/databases/migrations/sqlite/1630330987096-UpdateWorkflowCredentials.ts @@ -1,7 +1,7 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; import * as config from '../../../../config'; -import { MigrationHelpers } from '../../MigrationHelpers'; import { logMigrationEnd, logMigrationStart } from '../../utils/migrationHelpers'; +import { runChunked } from '../../utils/migrationHelpers'; // replacing the credentials in workflows and execution // `nodeType: name` changes to `nodeType: { id, name }` @@ -13,7 +13,6 @@ export class UpdateWorkflowCredentials1630330987096 implements MigrationInterfac logMigrationStart(this.name); const tablePrefix = config.getEnv('database.tablePrefix'); - const helpers = new MigrationHelpers(queryRunner); const credentialsEntities = await queryRunner.query(` SELECT id, name, type @@ -26,7 +25,7 @@ export class UpdateWorkflowCredentials1630330987096 implements MigrationInterfac `; // @ts-ignore - await helpers.runChunked(workflowsQuery, (workflows) => { + await runChunked(queryRunner, workflowsQuery, (workflows) => { workflows.forEach(async (workflow) => { const nodes = JSON.parse(workflow.nodes); let credentialsUpdated = false; @@ -69,7 +68,7 @@ export class UpdateWorkflowCredentials1630330987096 implements MigrationInterfac WHERE "waitTill" IS NOT NULL AND finished = 0 `; // @ts-ignore - await helpers.runChunked(waitingExecutionsQuery, (waitingExecutions) => { + await runChunked(queryRunner, waitingExecutionsQuery, (waitingExecutions) => { waitingExecutions.forEach(async (execution) => { const data = JSON.parse(execution.workflowData); let credentialsUpdated = false; @@ -153,7 +152,6 @@ export class UpdateWorkflowCredentials1630330987096 implements MigrationInterfac public async down(queryRunner: QueryRunner): Promise { const tablePrefix = config.getEnv('database.tablePrefix'); - const helpers = new MigrationHelpers(queryRunner); const credentialsEntities = await queryRunner.query(` SELECT id, name, type @@ -166,7 +164,7 @@ export class UpdateWorkflowCredentials1630330987096 implements MigrationInterfac `; // @ts-ignore - await helpers.runChunked(workflowsQuery, (workflows) => { + await runChunked(queryRunner, workflowsQuery, (workflows) => { // @ts-ignore workflows.forEach(async (workflow) => { const nodes = JSON.parse(workflow.nodes); @@ -216,7 +214,7 @@ export class UpdateWorkflowCredentials1630330987096 implements MigrationInterfac `; // @ts-ignore - await helpers.runChunked(waitingExecutionsQuery, (waitingExecutions) => { + await runChunked(queryRunner, waitingExecutionsQuery, (waitingExecutions) => { // @ts-ignore waitingExecutions.forEach(async (execution) => { const data = JSON.parse(execution.workflowData); diff --git a/packages/cli/src/databases/sqlite/migrations/1644421939510-AddExecutionEntityIndexes.ts b/packages/cli/src/databases/migrations/sqlite/1644421939510-AddExecutionEntityIndexes.ts similarity index 100% rename from packages/cli/src/databases/sqlite/migrations/1644421939510-AddExecutionEntityIndexes.ts rename to packages/cli/src/databases/migrations/sqlite/1644421939510-AddExecutionEntityIndexes.ts diff --git a/packages/cli/src/databases/sqlite/migrations/1646992772331-CreateUserManagement.ts b/packages/cli/src/databases/migrations/sqlite/1646992772331-CreateUserManagement.ts similarity index 100% rename from packages/cli/src/databases/sqlite/migrations/1646992772331-CreateUserManagement.ts rename to packages/cli/src/databases/migrations/sqlite/1646992772331-CreateUserManagement.ts diff --git a/packages/cli/src/databases/sqlite/migrations/1648740597343-LowerCaseUserEmail.ts b/packages/cli/src/databases/migrations/sqlite/1648740597343-LowerCaseUserEmail.ts similarity index 100% rename from packages/cli/src/databases/sqlite/migrations/1648740597343-LowerCaseUserEmail.ts rename to packages/cli/src/databases/migrations/sqlite/1648740597343-LowerCaseUserEmail.ts diff --git a/packages/cli/src/databases/sqlite/migrations/1652367743993-AddUserSettings.ts b/packages/cli/src/databases/migrations/sqlite/1652367743993-AddUserSettings.ts similarity index 100% rename from packages/cli/src/databases/sqlite/migrations/1652367743993-AddUserSettings.ts rename to packages/cli/src/databases/migrations/sqlite/1652367743993-AddUserSettings.ts diff --git a/packages/cli/src/databases/sqlite/migrations/1652905585850-AddAPIKeyColumn.ts b/packages/cli/src/databases/migrations/sqlite/1652905585850-AddAPIKeyColumn.ts similarity index 100% rename from packages/cli/src/databases/sqlite/migrations/1652905585850-AddAPIKeyColumn.ts rename to packages/cli/src/databases/migrations/sqlite/1652905585850-AddAPIKeyColumn.ts diff --git a/packages/cli/src/databases/sqlite/migrations/index.ts b/packages/cli/src/databases/migrations/sqlite/index.ts similarity index 97% rename from packages/cli/src/databases/sqlite/migrations/index.ts rename to packages/cli/src/databases/migrations/sqlite/index.ts index 56a18d98c4..1d51552e91 100644 --- a/packages/cli/src/databases/sqlite/migrations/index.ts +++ b/packages/cli/src/databases/migrations/sqlite/index.ts @@ -1,5 +1,3 @@ -import config from '../../../../config'; - import { InitialMigration1588102412422 } from './1588102412422-InitialMigration'; import { WebhookModel1592445003908 } from './1592445003908-WebhookModel'; import { CreateIndexStoppedAt1594825041918 } from './1594825041918-CreateIndexStoppedAt'; diff --git a/packages/cli/src/databases/ormconfig.ts b/packages/cli/src/databases/ormconfig.ts new file mode 100644 index 0000000000..f0e91d2ff1 --- /dev/null +++ b/packages/cli/src/databases/ormconfig.ts @@ -0,0 +1,67 @@ +import path from 'path'; +import { UserSettings } from 'n8n-core'; +import { entities } from './entities'; + +export default [ + { + name: 'sqlite', + type: 'sqlite', + logging: true, + entities: Object.values(entities), + database: path.resolve(UserSettings.getUserN8nFolderPath(), 'database.sqlite'), + migrations: [path.resolve('migrations', 'sqlite', 'index.ts')], + cli: { + entitiesDir: path.resolve('entities'), + migrationsDir: path.resolve('migrations', 'sqlite'), + }, + }, + { + name: 'postgres', + type: 'postgres', + database: 'n8n', + schema: 'public', + username: 'postgres', + password: '', + host: 'localhost', + port: 5432, + logging: false, + entities: Object.values(entities), + migrations: [path.resolve('migrations', 'postgresdb', 'index.ts')], + cli: { + entitiesDir: path.resolve('entities'), + migrationsDir: path.resolve('migrations', 'postgresdb'), + }, + }, + { + name: 'mysql', + type: 'mysql', + database: 'n8n', + username: 'root', + password: 'password', + host: 'localhost', + port: 3306, + logging: false, + entities: Object.values(entities), + migrations: [path.resolve('migrations', 'mysqldb', 'index.ts')], + cli: { + entitiesDir: path.resolve('entities'), + migrationsDir: path.resolve('migrations', 'mysqldb'), + }, + }, + { + name: 'mariadb', + type: 'mariadb', + database: 'n8n', + username: 'root', + password: 'password', + host: 'localhost', + port: 3306, + logging: false, + entities: Object.values(entities), + migrations: [path.resolve('migrations', 'mysqldb', 'index.ts')], + cli: { + entitiesDir: path.resolve('entities'), + migrationsDir: path.resolve('migrations', 'mysqldb'), + }, + }, +]; diff --git a/packages/cli/src/databases/utils/migrationHelpers.ts b/packages/cli/src/databases/utils/migrationHelpers.ts index 9acb0676f5..821c95ef88 100644 --- a/packages/cli/src/databases/utils/migrationHelpers.ts +++ b/packages/cli/src/databases/utils/migrationHelpers.ts @@ -1,5 +1,7 @@ +/* eslint-disable no-await-in-loop */ import { readFileSync, rmSync } from 'fs'; import { UserSettings } from 'n8n-core'; +import { QueryRunner } from 'typeorm/query-runner/QueryRunner'; import { getLogger } from '../../Logger'; const PERSONALIZATION_SURVEY_FILENAME = 'personalizationSurvey.json'; @@ -53,3 +55,31 @@ export function logMigrationEnd(migrationName: string): void { logger.warn('Migrations finished.'); }, 100); } + +export function chunkQuery(query: string, limit: number, offset = 0): string { + return ` + ${query} + LIMIT ${limit} + OFFSET ${offset} + `; +} + +export async function runChunked( + queryRunner: QueryRunner, + query: string, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + operation: (results: any[]) => Promise, + limit = 100, +): Promise { + let offset = 0; + let chunkedQuery: string; + let chunkedQueryResults: unknown[]; + + do { + chunkedQuery = chunkQuery(query, limit, offset); + chunkedQueryResults = (await queryRunner.query(chunkedQuery)) as unknown[]; + // pass a copy to prevent errors from mutation + await operation([...chunkedQueryResults]); + offset += limit; + } while (chunkedQueryResults.length === limit); +} diff --git a/packages/cli/test/integration/shared/testDb.ts b/packages/cli/test/integration/shared/testDb.ts index 49552bd141..e344961235 100644 --- a/packages/cli/test/integration/shared/testDb.ts +++ b/packages/cli/test/integration/shared/testDb.ts @@ -11,9 +11,9 @@ import { randomApiKey, randomEmail, randomName, randomString, randomValidPasswor import { CredentialsEntity } from '../../../src/databases/entities/CredentialsEntity'; import { hashPassword } from '../../../src/UserManagement/UserManagementHelper'; import { entities } from '../../../src/databases/entities'; -import { mysqlMigrations } from '../../../src/databases/mysqldb/migrations'; -import { postgresMigrations } from '../../../src/databases/postgresdb/migrations'; -import { sqliteMigrations } from '../../../src/databases/sqlite/migrations'; +import { mysqlMigrations } from '../../../src/databases/migrations/mysqldb'; +import { postgresMigrations } from '../../../src/databases/migrations/postgresdb'; +import { sqliteMigrations } from '../../../src/databases/migrations/sqlite'; import { categorize, getPostgresSchemaSection } from './utils'; import { createCredentiasFromCredentialsEntity } from '../../../src/CredentialsHelper';