import type { Constructor, IMigrationGenerator, IMigrationRunner, IMigrator, IMigratorStorage, MaybePromise, Migration, MigrationInfo, MigrationResult, MigrationRow, MigratorEvent } from '../typings.js'; import type { Transaction } from '../connections/Connection.js'; import type { Configuration, MigrationsOptions } from './Configuration.js'; import type { EntityManagerType, IDatabaseDriver } from '../drivers/IDatabaseDriver.js'; interface RunnableMigration { name: string; path?: string; up: (afterRun?: (tx?: Transaction) => Promise) => MaybePromise; down: (afterRun?: (tx?: Transaction) => Promise) => MaybePromise; } type MigrateOptions = { from?: string | number; to?: string | number; migrations?: string[]; transaction?: Transaction; schema?: string; }; export declare abstract class AbstractMigrator implements IMigrator { #private; protected readonly em: D[typeof EntityManagerType]; protected runner: IMigrationRunner; protected storage: IMigratorStorage; protected generator: IMigrationGenerator; protected readonly driver: D; protected readonly config: Configuration; protected readonly options: MigrationsOptions; protected absolutePath: string; protected initialized: boolean; constructor(em: D[typeof EntityManagerType]); protected abstract createRunner(): IMigrationRunner; protected abstract createStorage(): IMigratorStorage; protected abstract getDefaultGenerator(): IMigrationGenerator; abstract create(path?: string, blank?: boolean, initial?: boolean, name?: string): Promise<{ fileName: string; code: string; diff: { up: string[]; down: string[]; }; }>; abstract checkSchema(): Promise; abstract createInitial(path?: string, name?: string, blank?: boolean): Promise<{ fileName: string; code: string; diff: { up: string[]; down: string[]; }; }>; /** * @inheritDoc */ on(eventName: MigratorEvent, listener: (event: MigrationInfo) => MaybePromise): this; /** * @inheritDoc */ off(eventName: MigratorEvent, listener: (event: MigrationInfo) => MaybePromise): this; /** * @inheritDoc */ getExecuted(options?: { schema?: string; }): Promise; /** * @inheritDoc */ getPending(options?: { schema?: string; }): Promise; /** * @inheritDoc */ up(options?: string | string[] | MigrateOptions): Promise; /** * @inheritDoc */ down(options?: string | string[] | Omit): Promise; /** * @inheritDoc */ rollup(migrations?: string[]): Promise; /** * Extracts the body of a method from migration source code using brace counting. * Returns the raw lines between the opening and closing braces, or empty string if not found. * @internal */ private extractMethodBody; abstract getStorage(): IMigratorStorage; /** * @inheritDoc */ logMigration(name: string): Promise; /** * @inheritDoc */ unlogMigration(name: string): Promise; protected init(): Promise; /** Resolves the migrations path (including source folder auto-detection) without touching the filesystem. */ protected resolvePaths(): Promise; protected initPaths(): Promise; protected initServices(): void; protected resolve(params: { name: string; path: string; }): RunnableMigration; protected initialize(MigrationClass: Constructor, name?: string): RunnableMigration; /** * Checks if `src` folder exists, it so, tries to adjust the migrations and seeders paths automatically to use it. * If there is a `dist` or `build` folder, it will be used for the JS variant (`path` option), while the `src` folder will be * used for the TS variant (`pathTs` option). * * If the default folder exists (e.g. `/migrations`), the config will respect that, so this auto-detection should not * break existing projects, only help with the new ones. */ private detectSourceFolder; private registerDefaultListeners; private emit; protected discoverMigrations(): Promise; private executeMigrations; private filterUp; private filterDown; private getMigrationFilename; private prefix; protected runMigrations(method: 'up' | 'down', options?: string | string[] | MigrateOptions): Promise; private runInTransaction; } export {};