@mikro-orm/migrations
Version:
TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.
44 lines (43 loc) • 2.12 kB
TypeScript
import { type IMigrationGenerator, type IMigrationRunner, type IMigratorStorage, type MigrateOptions, type MigrationInfo, type MikroORM } from '@mikro-orm/core';
import { AbstractMigrator } from '@mikro-orm/core/migrations';
import { type AbstractSqlDriver, DatabaseSchema, type EntityManager } from '@mikro-orm/sql';
import { MigrationStorage } from './MigrationStorage.js';
import type { MigrationResult } from './typings.js';
/** Manages SQL database migrations: creation, execution, and rollback of schema changes. */
export declare class Migrator extends AbstractMigrator<AbstractSqlDriver> {
#private;
constructor(em: EntityManager);
static register(orm: MikroORM): void;
protected createRunner(): IMigrationRunner;
protected createStorage(): IMigratorStorage;
protected getDefaultGenerator(): IMigrationGenerator;
private getSnapshotPath;
protected init(): Promise<void>;
/**
* @inheritDoc
*/
create(path?: string, blank?: boolean, initial?: boolean, name?: string): Promise<MigrationResult>;
getPending(options?: {
schema?: string;
}): Promise<MigrationInfo[]>;
private hasSnapshot;
checkSchema(): Promise<boolean>;
/**
* @inheritDoc
*/
createInitial(path?: string, name?: string, blank?: boolean): Promise<MigrationResult>;
protected runMigrations(method: 'up' | 'down', options?: string | string[] | MigrateOptions): Promise<MigrationInfo[]>;
getStorage(): MigrationStorage;
/**
* Initial migration can be created only if:
* 1. no previous migrations were generated or executed
* 2. existing schema do not contain any of the tables defined by metadata
*
* If existing schema contains all of the tables already, we return true, based on that we mark the migration as already executed.
* If only some of the tables are present, exception is thrown.
*/
private validateInitialMigration;
protected getSchemaFromSnapshot(): Promise<DatabaseSchema | undefined>;
protected storeCurrentSchema(schema?: DatabaseSchema): Promise<void>;
private getSchemaDiff;
}