UNPKG

@kwaeri/migration

Version:

The @kwaeri/migration component of the @kwaer/node-kit application platform.

124 lines (123 loc) 3.15 kB
import { Filesystem } from '@kwaeri/filesystem'; import { Configuration } from '@kwaeri/configuration'; import { MySQLDriver } from '@kwaeri/driver/build/src/mysql'; import { PostgreSQLDriver } from '@kwaeri/driver/build/src/postgres'; export declare type MigrationRecord = { id: number; date: string; name: string; sequel: string; applied: boolean; }; export declare type MigrationPromise = { version?: string; result: boolean; migrations: MigrationRecord[]; }; export declare type MigratorConfiguration = { version: string; type?: string; table?: string; environment?: string; }; export declare type MigrationMap = { timestamp: string; name: string; path: string; }; /** * The Migrator Class * * The { Migrator } class handles everything that has to do with the migration * system, including; Setup, Management, and Execution of migrations. */ export declare class Migration extends Filesystem { /** * @var { string } */ path: string; /** * @var { string } */ file: string; /** * @var {string } */ version: string; /** * @var { string } */ type: string; /** * @var { string } */ table: string; /** * @var { Configuration } */ configuration: Configuration; /** * @var { Configuration } */ databaseConfiguration: Configuration; /** * @var { MySQLDriver|PostgreSQLDriver } */ dbo: MySQLDriver | PostgreSQLDriver; /** * Class constructor * * @since 0.1.10 */ constructor(configuration?: MigratorConfiguration); /** * Checks if the migration system has been installed * * @pram { void } * * @return { Promise<boolean> } A promise with a boolean value indicating whether the migration system is installed. * * @since 0.1.10 */ checkInstall<T extends MigrationPromise>(): Promise<boolean>; /** * Installs the migration system * * @param { string } content The migration configuration file content * * @return { Promise<T> } A promise that indicates the result of installing the migration system * * @since 0.1.10 */ install<T extends MigrationPromise>(content: string): Promise<T>; /** * Applies or reverts [a] migration(s) * * @param options Parameters that shape the migration command * * @returns { Promise<MigrationPromise> } * * @since 0.1.0 */ migrate<T extends MigrationPromise>(options: any): Promise<T>; /** * [DEPRECATED] Runs a [series of] migration(s), if any exist which have not already been applied * * @param void * * @returns { Promise<T> } A promise indicating the result of running migrations * * @since 0.1.11 */ run<T extends MigrationPromise>(options: any): Promise<T>; /** * [DEPRECATED] Adds a migration to the filesystem * * @param void * * @returns { Promise<MigrationPromise> } * * @since 0.1.0 */ add<T extends MigrationPromise>(): Promise<T>; }