Skip to content

Class: SQLAdapterMigrator

A class that wraps Knex's migration API for use with Kyoo's SQL adapter, providing a consistent interface for running and managing migrations.

Example

ts
const migrator = getSqlAdapterMigrator(config);
await migrator.latest();

Implements

Methods

currentVersion()

ts
currentVersion(): Promise<string>;

Get the current migration version (as a string or number). Equivalent to knex.migrate.currentVersion().

Returns

Promise<string>

Implementation of

SQLAdapterMigatorType.currentVersion


down()

ts
down(): Promise<any>;

Roll back the last migration that was run. Equivalent to knex.migrate.down().

Returns

Promise<any>

Implementation of

SQLAdapterMigatorType.down


forceFreeMigrationsLock()

ts
forceFreeMigrationsLock(): Promise<any>;

Force release the migration lock if stuck. Equivalent to knex.migrate.forceFreeMigrationsLock().

Returns

Promise<any>

Implementation of

SQLAdapterMigatorType.forceFreeMigrationsLock


latest()

ts
latest(): Promise<any>;

Run all pending migrations. Equivalent to knex.migrate.latest().

Returns

Promise<any>

Implementation of

SQLAdapterMigatorType.latest


list()

ts
list(): Promise<any>;

List all completed and pending migrations. Equivalent to knex.migrate.list().

Returns

Promise<any>

Implementation of

SQLAdapterMigatorType.list


rollback()

ts
rollback(): Promise<any>;

Roll back the last batch of migrations. Equivalent to knex.migrate.rollback().

Returns

Promise<any>

Implementation of

SQLAdapterMigatorType.rollback


shutdown()

ts
shutdown(): Promise<void>;

Shuts down (destroys) the Knex instance underlying the migrator instance.

Returns

Promise<void>

WARNING

If an error occurs during shutdown by knex or one if its underlying libraries, it will be thrown


status()

ts
status(): Promise<number>;

Get the current migration status (number of migrations run or a status code). Equivalent to knex.migrate.status().

Returns

Promise<number>

Implementation of

SQLAdapterMigatorType.status


up()

ts
up(): Promise<any>;

Run the next migration that has not yet been run. Equivalent to knex.migrate.up().

Returns

Promise<any>

Implementation of

SQLAdapterMigatorType.up