mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
refactor(core): Move migrations to @n8n/db (#15362)
This commit is contained in:
@@ -45,3 +45,51 @@ export const UNLIMITED_LICENSE_QUOTA = -1;
|
||||
|
||||
export type BooleanLicenseFeature = (typeof LICENSE_FEATURES)[keyof typeof LICENSE_FEATURES];
|
||||
export type NumericLicenseFeature = (typeof LICENSE_QUOTAS)[keyof typeof LICENSE_QUOTAS];
|
||||
|
||||
export const LDAP_FEATURE_NAME = 'features.ldap';
|
||||
|
||||
export type ConnectionSecurity = 'none' | 'tls' | 'startTls';
|
||||
|
||||
export interface LdapConfig {
|
||||
loginEnabled: boolean;
|
||||
loginLabel: string;
|
||||
connectionUrl: string;
|
||||
allowUnauthorizedCerts: boolean;
|
||||
connectionSecurity: ConnectionSecurity;
|
||||
connectionPort: number;
|
||||
baseDn: string;
|
||||
bindingAdminDn: string;
|
||||
bindingAdminPassword: string;
|
||||
firstNameAttribute: string;
|
||||
lastNameAttribute: string;
|
||||
emailAttribute: string;
|
||||
loginIdAttribute: string;
|
||||
ldapIdAttribute: string;
|
||||
userFilter: string;
|
||||
synchronizationEnabled: boolean;
|
||||
synchronizationInterval: number; // minutes
|
||||
searchPageSize: number;
|
||||
searchTimeout: number;
|
||||
}
|
||||
|
||||
export const LDAP_DEFAULT_CONFIGURATION: LdapConfig = {
|
||||
loginEnabled: false,
|
||||
loginLabel: '',
|
||||
connectionUrl: '',
|
||||
allowUnauthorizedCerts: false,
|
||||
connectionSecurity: 'none',
|
||||
connectionPort: 389,
|
||||
baseDn: '',
|
||||
bindingAdminDn: '',
|
||||
bindingAdminPassword: '',
|
||||
firstNameAttribute: '',
|
||||
lastNameAttribute: '',
|
||||
emailAttribute: '',
|
||||
loginIdAttribute: '',
|
||||
ldapIdAttribute: '',
|
||||
userFilter: '',
|
||||
synchronizationEnabled: false,
|
||||
synchronizationInterval: 60,
|
||||
searchPageSize: 0,
|
||||
searchTimeout: 60,
|
||||
};
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"@n8n/config": "workspace:^",
|
||||
"@n8n/constants": "workspace:^",
|
||||
"@n8n/di": "workspace:^",
|
||||
"@n8n/permissions": "workspace:^",
|
||||
"@n8n/typeorm": "catalog:",
|
||||
@@ -31,7 +32,9 @@
|
||||
"n8n-core": "workspace:^",
|
||||
"n8n-workflow": "workspace:^",
|
||||
"nanoid": "catalog:",
|
||||
"p-lazy": "3.1.0",
|
||||
"reflect-metadata": "catalog:",
|
||||
"uuid": "catalog:",
|
||||
"xss": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -21,3 +21,10 @@ export { NoUrl } from './utils/validators/no-url.validator';
|
||||
|
||||
export * from './repositories';
|
||||
export * from './subscribers';
|
||||
|
||||
export { sqliteMigrations } from './migrations/sqlite';
|
||||
export { mysqlMigrations } from './migrations/mysqldb';
|
||||
export { postgresMigrations } from './migrations/postgresdb';
|
||||
|
||||
export { wrapMigration } from './migrations/migration-helpers';
|
||||
export * from './migrations/migration-types';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { IrreversibleMigration, ReversibleMigration } from '@/databases/types';
|
||||
import { wrapMigration } from '@/databases/utils/migration-helpers';
|
||||
import { wrapMigration } from '../migration-helpers';
|
||||
import type { IrreversibleMigration, ReversibleMigration } from '../migration-types';
|
||||
|
||||
describe('migrationHelpers.wrapMigration', () => {
|
||||
test('throws if passed a migration without up method', async () => {
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { WorkflowEntity } from '@n8n/db';
|
||||
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { WorkflowEntity } from '../../entities';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class UniqueWorkflowNames1620821879465 implements ReversibleMigration {
|
||||
protected indexSuffix = '943d8f922be094eb507cb9a7f9';
|
||||
@@ -1,7 +1,8 @@
|
||||
import type { CredentialsEntity, WorkflowEntity } from '@n8n/db';
|
||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
||||
import type { IWorkflowBase } from 'n8n-workflow';
|
||||
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { CredentialsEntity, WorkflowEntity } from '../../entities';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
type Credential = Pick<CredentialsEntity, 'id' | 'name' | 'type'>;
|
||||
type ExecutionWithData = { id: string; workflowData: string | IWorkflowBase };
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { WorkflowEntity } from '@n8n/db';
|
||||
import type { INode } from 'n8n-workflow';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { WorkflowEntity } from '../../entities';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
type Workflow = Pick<WorkflowEntity, 'id'> & { nodes: string | INode[] };
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { isObjectLiteral } from 'n8n-core';
|
||||
import type { IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import type { MigrationContext, IrreversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, IrreversibleMigration } from '../migration-types';
|
||||
|
||||
type OldPinnedData = { [nodeName: string]: IDataObject[] };
|
||||
type NewPinnedData = { [nodeName: string]: INodeExecutionData[] };
|
||||
@@ -1,6 +1,6 @@
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
type Workflow = { id: number };
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { StatisticsNames } from '@n8n/db';
|
||||
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import { StatisticsNames } from '../../entities/types-db';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class RemoveWorkflowDataLoadedFlag1671726148419 implements ReversibleMigration {
|
||||
async up({ escape, dbType, runQuery }: MigrationContext) {
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import { LDAP_DEFAULT_CONFIGURATION, LDAP_FEATURE_NAME } from '@/ldap.ee/constants';
|
||||
import { LDAP_FEATURE_NAME, LDAP_DEFAULT_CONFIGURATION } from '@n8n/constants';
|
||||
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class CreateLdapEntities1674509946020 implements ReversibleMigration {
|
||||
async up({ escape, dbType, isMysql, runQuery }: MigrationContext) {
|
||||
@@ -1,7 +1,7 @@
|
||||
import { WorkflowEntity } from '@n8n/db';
|
||||
import { UserError } from 'n8n-workflow';
|
||||
|
||||
import type { IrreversibleMigration, MigrationContext } from '@/databases/types';
|
||||
import { WorkflowEntity } from '../../entities';
|
||||
import type { IrreversibleMigration, MigrationContext } from '../migration-types';
|
||||
|
||||
export class PurgeInvalidWorkflowConnections1675940580449 implements IrreversibleMigration {
|
||||
async up({ queryRunner }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class RemoveResetPasswordColumns1690000000030 implements ReversibleMigration {
|
||||
async up({ schemaBuilder: { dropColumns } }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class AddMfaColumns1690000000030 implements ReversibleMigration {
|
||||
async up({ schemaBuilder: { addColumns, column } }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class CreateWorkflowNameIndex1691088862123 implements ReversibleMigration {
|
||||
async up({ schemaBuilder: { createIndex } }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
const tableName = 'workflow_history';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
/**
|
||||
* Add an indexed column `deletedAt` to track soft-deleted executions.
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class DisallowOrphanExecutions1693554410387 implements ReversibleMigration {
|
||||
/**
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class AddWorkflowMetadata1695128658538 implements ReversibleMigration {
|
||||
async up({ schemaBuilder: { addColumns, column } }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
const tableName = 'workflow_history';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { UnexpectedError } from 'n8n-workflow';
|
||||
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class AddGlobalAdminRole1700571993961 implements ReversibleMigration {
|
||||
async up({ escape, runQuery }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
type Table = 'user' | 'shared_workflow' | 'shared_credentials';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { IrreversibleMigration, MigrationContext } from '@/databases/types';
|
||||
import type { IrreversibleMigration, MigrationContext } from '../migration-types';
|
||||
|
||||
export class RemoveFailedExecutionStatus1711018413374 implements IrreversibleMigration {
|
||||
async up({ escape, runQuery }: MigrationContext) {
|
||||
@@ -4,7 +4,7 @@ import { jsonParse } from 'n8n-workflow';
|
||||
import { readFile, writeFile, rm } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
/**
|
||||
* Move SSH key pair from file system to database, to enable SSH connections
|
||||
@@ -71,6 +71,7 @@ export class MoveSshKeysToDatabase1711390882123 implements ReversibleMigration {
|
||||
try {
|
||||
await Promise.all([rm(this.privateKeyPath), rm(this.publicKeyPath)]);
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||
const error = e instanceof Error ? e : new Error(`${e}`);
|
||||
logger.error(
|
||||
`[${migrationName}] Failed to remove SSH keys from filesystem: ${error.message}`,
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { IrreversibleMigration, MigrationContext } from '@/databases/types';
|
||||
import type { IrreversibleMigration, MigrationContext } from '../migration-types';
|
||||
|
||||
export class RemoveNodesAccess1712044305787 implements IrreversibleMigration {
|
||||
async up({ schemaBuilder: { dropColumns } }: MigrationContext) {
|
||||
@@ -1,10 +1,10 @@
|
||||
import { generateNanoId } from '@n8n/db';
|
||||
import type { User } from '@n8n/db';
|
||||
import type { ProjectRole } from '@n8n/permissions';
|
||||
import { UserError } from 'n8n-workflow';
|
||||
import { nanoid } from 'nanoid';
|
||||
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { User } from '../../entities';
|
||||
import { generateNanoId } from '../../utils/generators';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
const projectAdminRole: ProjectRole = 'project:personalOwner';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { IrreversibleMigration, MigrationContext } from '@/databases/types';
|
||||
import type { IrreversibleMigration, MigrationContext } from '../migration-types';
|
||||
|
||||
export class MakeExecutionStatusNonNullable1714133768521 implements IrreversibleMigration {
|
||||
async up({ escape, runQuery, schemaBuilder }: MigrationContext) {
|
||||
@@ -1,6 +1,6 @@
|
||||
import { nanoid } from 'nanoid';
|
||||
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class AddConstraintToExecutionMetadata1720101653148 implements ReversibleMigration {
|
||||
async up(context: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
const tableName = 'invalid_auth_token';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
/**
|
||||
* Add new indices:
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
const annotationsTableName = 'execution_annotations';
|
||||
const annotationTagsTableName = 'annotation_tag_entity';
|
||||
@@ -1,7 +1,6 @@
|
||||
import { generateNanoId } from '@n8n/db';
|
||||
import type { ApiKey } from '@n8n/db';
|
||||
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { ApiKey } from '../../entities';
|
||||
import { generateNanoId } from '../../utils/generators';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class AddApiKeysTable1724951148974 implements ReversibleMigration {
|
||||
async up({
|
||||
@@ -40,6 +39,7 @@ export class AddApiKeysTable1724951148974 implements ReversibleMigration {
|
||||
// Move the apiKey from the users table to the new table
|
||||
await Promise.all(
|
||||
usersWithApiKeys.map(
|
||||
// @ts-expect-error Tech debt
|
||||
async (user: { id: string; apiKey: string }) =>
|
||||
await runQuery(
|
||||
`INSERT INTO ${userApiKeysTable} (${idColumn}, ${userIdColumn}, ${apiKeyColumn}, ${labelColumn}) VALUES (:id, :userId, :apiKey, :label)`,
|
||||
@@ -97,6 +97,7 @@ export class AddApiKeysTable1724951148974 implements ReversibleMigration {
|
||||
|
||||
await Promise.all(
|
||||
oldestApiKeysPerUser.map(
|
||||
// @ts-expect-error Tech debt
|
||||
async (user: { userId: string; apiKey: string }) =>
|
||||
await runQuery(
|
||||
`UPDATE ${userTable} SET ${apiKeyColumn} = :apiKey WHERE ${idColumn} = :userId`,
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
const processedDataTableName = 'processed_data';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class SeparateExecutionCreationFromStart1727427440136 implements ReversibleMigration {
|
||||
async up({
|
||||
@@ -1,6 +1,6 @@
|
||||
import assert from 'node:assert';
|
||||
|
||||
import type { IrreversibleMigration, MigrationContext } from '@/databases/types';
|
||||
import type { IrreversibleMigration, MigrationContext } from '../migration-types';
|
||||
|
||||
export class AddMissingPrimaryKeyOnAnnotationTagMapping1728659839644
|
||||
implements IrreversibleMigration
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
const processedDataTableName = 'processed_data';
|
||||
export class UpdateProcessedDataValueColumnToText1729607673464 implements ReversibleMigration {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
export class AddProjectIcons1729607673469 implements ReversibleMigration {
|
||||
async up({ schemaBuilder: { addColumns, column } }: MigrationContext) {
|
||||
await addColumns('project', [column('icon').json]);
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
const testEntityTableName = 'test_definition';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class AddDescriptionToTestDefinition1731404028106 implements ReversibleMigration {
|
||||
async up({ schemaBuilder: { addColumns, column } }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
const testMetricEntityTableName = 'test_metric';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
const testRunTableName = 'test_run';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
// We have to use raw query migration instead of schemaBuilder helpers,
|
||||
// because the typeorm schema builder implements addColumns by a table recreate for sqlite
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class AddManagedColumnToCredentialsTable1734479635324 implements ReversibleMigration {
|
||||
async up({ escape, runQuery, isSqlite }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
const columns = ['totalCases', 'passedCases', 'failedCases'] as const;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
const testCaseExecutionTableName = 'test_case_execution';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
// We have to use raw query migration instead of schemaBuilder helpers,
|
||||
// because the typeorm schema builder implements addColumns by a table recreate for sqlite
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class CreateFolderTable1738709609940 implements ReversibleMigration {
|
||||
async up({ runQuery, escape, schemaBuilder: { createTable, column } }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
const names = {
|
||||
// table names
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { IrreversibleMigration, MigrationContext } from '@/databases/types';
|
||||
import type { IrreversibleMigration, MigrationContext } from '../migration-types';
|
||||
|
||||
const names = {
|
||||
// table names
|
||||
@@ -1,8 +1,8 @@
|
||||
import { ApiKey } from '@n8n/db';
|
||||
import type { GlobalRole } from '@n8n/permissions';
|
||||
import { getApiKeyScopesForRole } from '@n8n/permissions';
|
||||
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import { getApiKeyScopesForRole } from '@/public-api/permissions.ee';
|
||||
import { ApiKey } from '../../entities';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
type ApiKeyWithRole = { id: string; role: GlobalRole };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ReversibleMigration, MigrationContext } from '@/databases/types';
|
||||
import type { ReversibleMigration, MigrationContext } from '../migration-types';
|
||||
|
||||
const columnName = 'rootCount';
|
||||
const tableName = 'workflow_statistics';
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
const columnName = 'isArchived';
|
||||
const tableName = 'workflow_entity';
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { IrreversibleMigration, MigrationContext } from '@/databases/types';
|
||||
import type { IrreversibleMigration, MigrationContext } from '../migration-types';
|
||||
|
||||
/**
|
||||
* Drop the `role` table introduced by `CreateUserManagement1646992772331` and later
|
||||
@@ -1,4 +1,3 @@
|
||||
import { inTest } from '@n8n/backend-common';
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import { Container } from '@n8n/di';
|
||||
import type { ObjectLiteral } from '@n8n/typeorm';
|
||||
@@ -7,8 +6,8 @@ import { readFileSync, rmSync } from 'fs';
|
||||
import { InstanceSettings, Logger } from 'n8n-core';
|
||||
import { jsonParse, UnexpectedError } from 'n8n-workflow';
|
||||
|
||||
import { createSchemaBuilder } from '@/databases/dsl';
|
||||
import type { BaseMigration, Migration, MigrationContext, MigrationFn } from '@/databases/types';
|
||||
import { createSchemaBuilder } from './dsl';
|
||||
import type { BaseMigration, Migration, MigrationContext, MigrationFn } from './migration-types';
|
||||
|
||||
const PERSONALIZATION_SURVEY_FILENAME = 'personalizationSurvey.json';
|
||||
|
||||
@@ -35,7 +34,7 @@ function loadSurveyFromDisk(): string | null {
|
||||
}
|
||||
}
|
||||
return surveyFile;
|
||||
} catch (error) {
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -43,7 +42,7 @@ function loadSurveyFromDisk(): string | null {
|
||||
let runningMigrations = false;
|
||||
|
||||
function logMigrationStart(migrationName: string): void {
|
||||
if (inTest) return;
|
||||
if (process.env.NODE_ENV === 'test') return;
|
||||
|
||||
const logger = Container.get(Logger);
|
||||
if (!runningMigrations) {
|
||||
@@ -55,7 +54,7 @@ function logMigrationStart(migrationName: string): void {
|
||||
}
|
||||
|
||||
function logMigrationEnd(migrationName: string): void {
|
||||
if (inTest) return;
|
||||
if (process.env.NODE_ENV === 'test') return;
|
||||
|
||||
const logger = Container.get(Logger);
|
||||
logger.info(`Finished migration ${migrationName}`);
|
||||
@@ -43,6 +43,7 @@ export type MigrationFn = (ctx: MigrationContext) => Promise<void>;
|
||||
|
||||
export interface BaseMigration {
|
||||
up: MigrationFn;
|
||||
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
||||
down?: MigrationFn | never;
|
||||
transaction?: false;
|
||||
}
|
||||
@@ -55,6 +56,7 @@ export interface IrreversibleMigration extends BaseMigration {
|
||||
down?: never;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
export interface Migration extends Function {
|
||||
prototype: ReversibleMigration | IrreversibleMigration;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class InitialMigration1588157391238 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class WebhookModel1592447867632 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class CreateIndexStoppedAt1594902918301 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class MakeStoppedAtNullable1607431743767 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class AddWebhookId1611149998770 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class ChangeDataSize1615306975123 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class CreateTagEntity1617268711084 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class ChangeCredentialDataSize1620729500000 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, IrreversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, IrreversibleMigration } from '../migration-types';
|
||||
|
||||
export class CertifyCorrectCollation1623936588000 implements IrreversibleMigration {
|
||||
async up({ queryRunner, tablePrefix, dbType, dbName }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class AddWaitColumnId1626183952959 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class AddExecutionEntityIndexes1644424784709 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,6 +1,6 @@
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
import type { InsertResult, MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { InsertResult, MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class CreateUserManagement1646992772331 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix, loadSurveyFromDisk }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, IrreversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, IrreversibleMigration } from '../migration-types';
|
||||
|
||||
export class LowerCaseUserEmail1648740597343 implements IrreversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class CommunityNodes1652254514003 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class AddUserSettings1652367743993 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class AddAPIKeyColumn1652905585850 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class IntroducePinData1654090101303 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class CreateCredentialsUserRole1660062385367 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class CreateWorkflowsEditorRole1663755770894 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class WorkflowStatistics1664196174002 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class CreateCredentialUsageTable1665484192213 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class RemoveCredentialUsageTable1665754637026 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class AddTriggerCountColumn1669823906994 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class MessageEventBusDestinations1671535397530 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class DeleteExecutionsWithWorkflows1673268682475 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class AddStatusToExecutions1674138566000 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, IrreversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, IrreversibleMigration } from '../migration-types';
|
||||
|
||||
export class MigrateExecutionStatus1676996103000 implements IrreversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, IrreversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, IrreversibleMigration } from '../migration-types';
|
||||
|
||||
export class UpdateRunningExecutionStatus1677236788851 implements IrreversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class CreateVariables1677501636753 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class CreateExecutionMetadataTable1679416281779 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { UserSettings } from '@n8n/db';
|
||||
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { UserSettings } from '../../entities/types-db';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class AddUserActivatedProperty1681134145996 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { IrreversibleMigration, MigrationContext } from '@/databases/types';
|
||||
import type { IrreversibleMigration, MigrationContext } from '../migration-types';
|
||||
|
||||
export class RemoveSkipOwnerSetup1681134145997 implements IrreversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, IrreversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, IrreversibleMigration } from '../migration-types';
|
||||
|
||||
const COLLATION_57 = 'utf8mb4_general_ci';
|
||||
const COLLATION_80 = 'utf8mb4_0900_ai_ci';
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, ReversibleMigration } from '../migration-types';
|
||||
|
||||
export class SeparateExecutionData1690000000030 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MigrationContext, IrreversibleMigration } from '@/databases/types';
|
||||
import type { MigrationContext, IrreversibleMigration } from '../migration-types';
|
||||
|
||||
export class FixExecutionDataType1690000000031 implements IrreversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user