import type { Logger } from '@n8n/backend-common'; import type { QueryRunner, ObjectLiteral } from '@n8n/typeorm'; import type { createSchemaBuilder } from './dsl'; export type DatabaseType = 'postgresdb' | 'sqlite'; export interface MigrationContext { logger: Logger; queryRunner: QueryRunner; tablePrefix: string; dbType: DatabaseType; isSqlite: boolean; isPostgres: boolean; dbName: string; migrationName: string; schemaBuilder: ReturnType; loadSurveyFromDisk(): string | null; parseJson(data: string | T): T; escape: { columnName(name: string): string; tableName(name: string): string; indexName(name: string): string; triggerName(name: string): string; functionName(name: string): string; }; runQuery(sql: string, namedParameters?: ObjectLiteral): Promise; runInBatches(query: string, operation: (results: T[]) => Promise, limit?: number): Promise; copyTable(fromTable: string, toTable: string): Promise; copyTable(fromTable: string, toTable: string, fromFields?: string[], toFields?: string[], batchSize?: number): Promise; } export type MigrationFn = (ctx: MigrationContext) => Promise; export interface BaseMigration { up: MigrationFn; down?: MigrationFn | never; withFKsDisabled?: true; } export interface ReversibleMigration extends BaseMigration { down: MigrationFn; } export interface IrreversibleMigration extends BaseMigration { down?: never; } export interface Migration extends Function { prototype: ReversibleMigration | IrreversibleMigration; } export type InsertResult = Array<{ insertId: number; }>; export { QueryFailedError } from '@n8n/typeorm/error/QueryFailedError';