Umzug: custom storage option

This commit is contained in:
Troy McKinnon
2018-03-02 15:09:54 -06:00
parent 71ab18345e
commit 58f4097397

View File

@@ -2,6 +2,7 @@
// Project: https://github.com/sequelize/umzug
// Definitions by: Ivan Drinchev <https://github.com/drinchev>
// Margus Lamp <https://github.com/mlamp>
// Troy McKinnon <https://github.com/trodi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -39,10 +40,32 @@ declare namespace umzug {
* for examples.
*/
customResolver?(path: string): { up: () => Promise<any>, down?: () => Promise<any> };
}
interface JSONStorageOptions {
/**
* In order to keep track of already executed tasks, umzug logs successfully executed migrations.
* This is done in order to allow rollbacks of tasks. This is the interface these `Storages` must
* follow.
*/
interface Storage {
/**
* Logs migration to be considered as executed.
*
* @param migrationName - Name of the migration to be logged.
*/
logMigration(migrationName: string): Promise<void>;
/**
* Unlogs migration to be considered as pending.
*
* @param migrationName - Name of the migration to be unlogged.
*/
unlogMigration(migrationName: string): Promise<void>;
/** Gets list of executed migrations. */
executed(): Promise<String[]>;
}
interface JSONStorageOptions extends Storage {
/**
* The path to the json storage.
@@ -52,7 +75,7 @@ declare namespace umzug {
}
interface SequelizeStorageOptions {
interface SequelizeStorageOptions extends Storage {
/**
* The configured instance of Sequelize.
@@ -99,12 +122,10 @@ declare namespace umzug {
}
interface UmzugOptions {
/**
* The storage.
* Possible values: 'json', 'sequelize', an object
*/
storage?: string;
storage?: "json" | "sequelize" | Storage;
/**
* The options for the storage.