Skip to main content
Version: 5.9

Migrator

Implements

  • IMigrator

Index

Constructors

constructor

  • new Migrator(em: SqlEntityManager<AbstractSqlDriver<AbstractSqlConnection, AbstractSqlPlatform>>): Migrator
  • Parameters

    • em: SqlEntityManager<AbstractSqlDriver<AbstractSqlConnection, AbstractSqlPlatform>>

    Returns Migrator

Methods

checkMigrationNeeded

  • checkMigrationNeeded(): Promise<boolean>
  • Checks current schema for changes.


    Returns Promise<boolean>

createInitialMigration

  • createInitialMigration(path?: string, name?: string): Promise<MigrationResult>
  • Creates initial migration. This generates the schema based on metadata, and checks whether all the tables are already present. If yes, it will also automatically log the migration as executed. Initial migration can be created only if the schema is already aligned with the metadata, or when no schema is present - in such case regular migration would have the same effect.


    Parameters

    • optionalpath: string
    • optionalname: string

    Returns Promise<MigrationResult>

createMigration

  • createMigration(path?: string, blank?: boolean, initial?: boolean, name?: string): Promise<MigrationResult>
  • Checks current schema for changes, generates new migration if there are any.


    Parameters

    • optionalpath: string
    • blank: boolean = false
    • initial: boolean = false
    • optionalname: string

    Returns Promise<MigrationResult>

down

  • down(options?: string | string[] | MigrateOptions): Promise<UmzugMigration[]>
  • Executes down migrations to the given point. Without parameter it will migrate one version down.


    Parameters

    • optionaloptions: string | string[] | MigrateOptions

    Returns Promise<UmzugMigration[]>

getExecutedMigrations

  • getExecutedMigrations(): Promise<MigrationRow[]>
  • Returns list of already executed migrations.


    Returns Promise<MigrationRow[]>

getPendingMigrations

  • getPendingMigrations(): Promise<UmzugMigration[]>
  • Returns list of pending (not yet executed) migrations found in the migration directory.


    Returns Promise<UmzugMigration[]>

getStorage

  • getStorage(): MigrationStorage
  • Returns MigrationStorage

up

  • up(options?: string | string[] | MigrateOptions): Promise<UmzugMigration[]>
  • Executes specified migrations. Without parameter it will migrate up to the latest version.


    Parameters

    • optionaloptions: string | string[] | MigrateOptions

    Returns Promise<UmzugMigration[]>

staticregister

  • register(orm: MikroORM<IDatabaseDriver<Connection>>): void
  • Parameters

    • orm: MikroORM<IDatabaseDriver<Connection>>

    Returns void