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>

Current migration version recorded in the database.

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>

Rollback details for the single reverted migration.

Implementation of ​

SQLAdapterMigatorType.down


forceFreeMigrationsLock() ​

ts
forceFreeMigrationsLock(): Promise<any>;

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

Returns ​

Promise<any>

Promise fulfilled once Knex unlocks the migrations table.

Implementation of ​

SQLAdapterMigatorType.forceFreeMigrationsLock


latest() ​

ts
latest(): Promise<any>;

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

Returns ​

Promise<any>

Migrator run details containing the batch number and migration list.

Implementation of ​

SQLAdapterMigatorType.latest


list() ​

ts
list(): Promise<any>;

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

Returns ​

Promise<any>

Tuple containing completed migrations and pending migration files.

Implementation of ​

SQLAdapterMigatorType.list


rollback() ​

ts
rollback(): Promise<any>;

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

Returns ​

Promise<any>

Rollback details containing the batch number and reverted migrations.

Implementation of ​

SQLAdapterMigatorType.rollback


shutdown() ​

ts
shutdown(): Promise<void>;

Releases a hold taken through a provider. Standalone migrators borrow one per operation instead, so this is an idempotent no-op for them and calling it is optional: the hold is already back at the cache after every method call.

Returns ​

Promise<void>

​

WARNING

If an error occurs during shutdown by Knex or one of 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>

Status code or count of remaining pending migrations.

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>

Migration run details for the single applied file.

Implementation of ​

SQLAdapterMigatorType.up