Skip to main content
Version: 4.4

Class: Migrator#

migrations.Migrator

Hierarchy#

  • Migrator

Constructors#

constructor#

+ new Migrator(em: EntityManager<AbstractSqlDriver<AbstractSqlConnection>>): Migrator

Parameters:#

NameType
emEntityManager<AbstractSqlDriver<AbstractSqlConnection>>

Returns: Migrator

Defined in: packages/migrations/src/Migrator.ts:20

Properties#

config#

Private Readonly config: Configuration<IDatabaseDriver<Connection>>

Defined in: packages/migrations/src/Migrator.ts:16


driver#

Private Readonly driver: AbstractSqlDriver<AbstractSqlConnection>

Defined in: packages/migrations/src/Migrator.ts:14


generator#

Private Readonly generator: MigrationGenerator

Defined in: packages/migrations/src/Migrator.ts:19


options#

Private Readonly options: MigrationsOptions

Defined in: packages/migrations/src/Migrator.ts:17


runner#

Private Readonly runner: MigrationRunner

Defined in: packages/migrations/src/Migrator.ts:18


schemaGenerator#

Private Readonly schemaGenerator: SchemaGenerator

Defined in: packages/migrations/src/Migrator.ts:15


storage#

Private Readonly storage: MigrationStorage

Defined in: packages/migrations/src/Migrator.ts:20


umzug#

Private Readonly umzug: Umzug

Defined in: packages/migrations/src/Migrator.ts:13

Methods#

createInitialMigration#

createInitialMigration(path?: string): Promise<MigrationResult>

Parameters:#

NameType
path?string

Returns: Promise<MigrationResult>

Defined in: packages/migrations/src/Migrator.ts:62


createMigration#

createMigration(path?: string, blank?: boolean, initial?: boolean): Promise<MigrationResult>

Parameters:#

NameTypeDefault value
path?string-
blankbooleanfalse
initialbooleanfalse

Returns: Promise<MigrationResult>

Defined in: packages/migrations/src/Migrator.ts:41


down#

down(options?: string | string[] | MigrateOptions): Promise<UmzugMigration[]>

Parameters:#

NameType
options?string | string[] | MigrateOptions

Returns: Promise<UmzugMigration[]>

Defined in: packages/migrations/src/Migrator.ts:139


ensureMigrationsDirExists#

PrivateensureMigrationsDirExists(): Promise<void>

Returns: Promise<void>

Defined in: packages/migrations/src/Migrator.ts:239


getExecutedMigrations#

getExecutedMigrations(): Promise<MigrationRow[]>

Returns: Promise<MigrationRow[]>

Defined in: packages/migrations/src/Migrator.ts:123


getPendingMigrations#

getPendingMigrations(): Promise<UmzugMigration[]>

Returns: Promise<UmzugMigration[]>

Defined in: packages/migrations/src/Migrator.ts:129


getSchemaDiff#

PrivategetSchemaDiff(blank: boolean, initial: boolean): Promise<string[]>

Parameters:#

NameType
blankboolean
initialboolean

Returns: Promise<string[]>

Defined in: packages/migrations/src/Migrator.ts:165


getStorage#

getStorage(): MigrationStorage

Returns: MigrationStorage

Defined in: packages/migrations/src/Migrator.ts:143


initialize#

Protectedinitialize(MigrationClass: Constructor<Migration>, name?: string): object

Parameters:#

NameType
MigrationClassConstructor<Migration>
name?string

Returns: object

NameType
down() => Promise<void>
nameundefined | string
up() => Promise<void>

Defined in: packages/migrations/src/Migrator.ts:155


prefix#

Privateprefix<T>(options?: T): T

Type parameters:#

NameType
Tstring | string[] | { from?: undefined | string ; migrations?: undefined | string[] ; to?: undefined | string ; transaction?: any }

Parameters:#

NameType
options?T

Returns: T

Defined in: packages/migrations/src/Migrator.ts:189


resolve#

Protectedresolve(file: string): object

Parameters:#

NameType
filestring

Returns: object

NameType
down() => Promise<void>
nameundefined | string
up() => Promise<void>

Defined in: packages/migrations/src/Migrator.ts:147


runInTransaction#

PrivaterunInTransaction(trx: any, method: up | down, options: undefined | string | string[] | MigrateOptions): Promise<Migration[]>

Parameters:#

NameType
trxany
methodup | down
optionsundefined | string | string[] | MigrateOptions

Returns: Promise<Migration[]>

Defined in: packages/migrations/src/Migrator.ts:229


runMigrations#

PrivaterunMigrations(method: up | down, options?: string | string[] | MigrateOptions): Promise<Migration[]>

Parameters:#

NameType
methodup | down
options?string | string[] | MigrateOptions

Returns: Promise<Migration[]>

Defined in: packages/migrations/src/Migrator.ts:214


up#

up(options?: string | string[] | MigrateOptions): Promise<UmzugMigration[]>

Parameters:#

NameType
options?string | string[] | MigrateOptions

Returns: Promise<UmzugMigration[]>

Defined in: packages/migrations/src/Migrator.ts:135


validateInitialMigration#

PrivatevalidateInitialMigration(): Promise<boolean>

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.

Returns: Promise<boolean>

Defined in: packages/migrations/src/Migrator.ts:87

Last updated on by renovate[bot]