Skip to main content
Version: Next

IMigrator

Interface for the migrator, responsible for creating and executing database migrations.

Index

Methods

checkSchema

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


    Returns Promise<boolean>

create

  • Checks current schema for changes, generates new migration if there are any.


    Parameters

    • optionalpath: string
    • optionalblank: boolean
    • optionalinitial: boolean
    • optionalname: string

    Returns Promise<MigrationResult>

createInitial

  • 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

    Returns Promise<MigrationResult>

down

  • Executes down migrations to the given point. Without parameter it will migrate one version down.


    Parameters

    Returns Promise<MigrationInfo[]>

getExecuted

  • Returns list of already executed migrations.


    Parameters

    • optionaloptions: { schema?: string }
      • optionalschema: string

    Returns Promise<MigrationRow[]>

getPending

  • Returns list of pending (not yet executed) migrations found in the migration directory.


    Parameters

    • optionaloptions: { schema?: string }
      • optionalschema: string

    Returns Promise<MigrationInfo[]>

logMigration

  • logMigration(name): Promise<void>
  • Marks a migration as executed without actually running it.


    Parameters

    • name: string

    Returns Promise<void>

off

on

rollup

  • Combines multiple executed migrations into a single migration file. Concatenates source code without touching the database schema.


    Parameters

    • optionalmigrations: string[]

    Returns Promise<MigrationResult>

unlogMigration

  • unlogMigration(name): Promise<void>
  • Removes a migration from the executed list without reverting it.


    Parameters

    • name: string

    Returns Promise<void>

up

  • Executes specified migrations. Without parameter it will migrate up to the latest version.


    Parameters

    Returns Promise<MigrationInfo[]>