import { Connection } from "../connection/Connection"; import { Migration } from "./Migration"; import { QueryRunner } from "../query-runner/QueryRunner"; /** * Executes migrations: runs pending and reverts previously executed migrations. */ export declare class MigrationExecutor { protected connection: Connection; protected queryRunner?: QueryRunner | undefined; /** * Indicates how migrations should be run in transactions. * all: all migrations are run in a single transaction * none: all migrations are run without a transaction * each: each migration is run in a separate transaction */ transaction: "all" | "none" | "each"; private readonly migrationsDatabase?; private readonly migrationsSchema?; private readonly migrationsTable; private readonly migrationsTableName; constructor(connection: Connection, queryRunner?: QueryRunner | undefined); /** * Tries to execute a single migration given. */ executeMigration(migration: Migration): Promise; /** * Returns an array of all migrations. */ getAllMigrations(): Promise; /** * Returns an array of all executed migrations. */ getExecutedMigrations(): Promise; /** * Returns an array of all pending migrations. */ getPendingMigrations(): Promise; /** * Inserts an executed migration. */ insertMigration(migration: Migration): Promise; /** * Deletes an executed migration. */ deleteMigration(migration: Migration): Promise; /** * Lists all migrations and whether they have been executed or not * returns true if there are unapplied migrations */ showMigrations(): Promise; /** * Executes all pending migrations. Pending migrations are migrations that are not yet executed, * thus not saved in the database. */ executePendingMigrations(): Promise; /** * Reverts last migration that were run. */ undoLastMigration(): Promise; /** * Creates table "migrations" that will store information about executed migrations. */ protected createMigrationsTableIfNotExist(queryRunner: QueryRunner): Promise; /** * Loads all migrations that were executed and saved into the database (sorts by id). */ protected loadExecutedMigrations(queryRunner: QueryRunner): Promise; /** * Gets all migrations that setup for this connection. */ protected getMigrations(): Migration[]; protected checkForDuplicateMigrations(migrations: Migration[]): void; /** * Finds the latest migration (sorts by timestamp) in the given array of migrations. */ protected getLatestTimestampMigration(migrations: Migration[]): Migration | undefined; /** * Finds the latest migration in the given array of migrations. * PRE: Migration array must be sorted by descending id. */ protected getLatestExecutedMigration(sortedMigrations: Migration[]): Migration | undefined; /** * Inserts new executed migration's data into migrations table. */ protected insertExecutedMigration(queryRunner: QueryRunner, migration: Migration): Promise; /** * Delete previously executed migration's data from the migrations table. */ protected deleteExecutedMigration(queryRunner: QueryRunner, migration: Migration): Promise; protected withQueryRunner(callback: (queryRunner: QueryRunner) => T): Promise; }