import type { Dialect, LoggingOptions, Migration, MigrationDefinition, MigrationResult, MigrationStorage, MigratorOptions, MongoQuerier, NamingStrategy, Querier, QuerierPool, SchemaDiff, SchemaGenerator, SchemaIntrospector, Type } from '../type/index.js'; import { LoggerWrapper } from '../util/index.js'; import type { IMigrationBuilder } from './builder/types.js'; /** * Main class for managing database migrations */ export declare class Migrator { private readonly pool; readonly storage: MigrationStorage; readonly migrationsPath: string; private _logger; get logger(): LoggerWrapper; set logger(value: LoggingOptions); private readonly _entities?; get entities(): Type[]; readonly dialect: Dialect; schemaGenerator?: SchemaGenerator; schemaIntrospector?: SchemaIntrospector; constructor(pool: QuerierPool, options?: MigratorOptions); /** * Set the schema generator for DDL operations */ setSchemaGenerator(generator: SchemaGenerator): void; protected createIntrospector(): SchemaIntrospector | undefined; protected createGenerator(namingStrategy?: NamingStrategy): SchemaGenerator | undefined; /** * Get the SQL dialect */ getDialect(): Dialect; /** * Get all discovered migrations from the migrations directory */ getMigrations(): Promise; /** * Get list of pending migrations (not yet executed) */ pending(): Promise; /** * Get list of executed migrations */ executed(): Promise; /** * Run all pending migrations */ up(options?: { to?: string; step?: number; }): Promise; /** * Rollback migrations */ down(options?: { to?: string; step?: number; }): Promise; /** * Run a single migration within a transaction */ runMigration(migration: Migration, direction: 'up' | 'down'): Promise; /** * Generate a new migration file */ generate(name: string): Promise; /** * Generate a migration based on entity schema differences */ generateFromEntities(name: string): Promise; /** * Get all schema differences between entities and database */ getDiffs(): Promise; findEntityForTable(tableName: string): Type | undefined; /** * Sync schema directly (for development only - not for production!) */ sync(options?: { force?: boolean; }): Promise; /** * Drops and recreates all tables (Development only!) */ syncForce(): Promise; /** * Safely synchronizes the schema by only adding missing tables and columns. */ autoSync(options?: { safe?: boolean; drop?: boolean; logging?: boolean; }): Promise; protected filterDiff(diff: SchemaDiff, options: { safe?: boolean; drop?: boolean; }): SchemaDiff; executeSyncStatements(statements: string[], options: { logging?: boolean; }): Promise; executeMongoSyncStatements(statements: string[], options: { logging?: boolean; }, querier: MongoQuerier): Promise; executeSqlSyncStatements(statements: string[], options: { logging?: boolean; }, querier: Querier): Promise; /** * Get migration status */ status(): Promise<{ pending: string[]; executed: string[]; }>; /** * Get migration files from the migrations directory */ getMigrationFiles(): Promise; /** * Load a migration from a file */ loadMigration(fileName: string): Promise; /** * Check if an object is a valid migration */ isMigration(obj: unknown): obj is MigrationDefinition; /** * Extract migration name from filename */ getMigrationName(fileName: string): string; /** * Generate timestamp string for migration names */ protected getTimestamp(): string; /** * Convert a string to a slug for filenames */ protected slugify(text: string): string; /** * Generate migration file content */ protected generateMigrationContent(name: string): string; /** * Generate migration file content with SQL statements */ protected generateMigrationContentWithStatements(name: string, upStatements: string[], downStatements: string[]): string; } /** * Helper function to define a migration with proper typing */ export declare function defineMigration(migration: MigrationDefinition): MigrationDefinition; /** * Migration definition that uses the type-safe builder API. */ export interface BuilderMigrationDefinition { readonly name?: string; readonly up: (builder: IMigrationBuilder) => Promise; readonly down: (builder: IMigrationBuilder) => Promise; } /** * Define a migration using the type-safe builder API. * * @example * ```ts * export default defineBuilderMigration({ * async up(m) { * await m.createTable('users', (table) => { * table.id(); * table.string('email', 255).unique(); * table.timestamps(); * }); * }, * async down(m) { * await m.dropTable('users'); * } * }); * ``` */ export declare function defineBuilderMigration(migration: BuilderMigrationDefinition): BuilderMigrationDefinition; //# sourceMappingURL=migrator.d.ts.map