@medusajs/utils
Version:
Medusa utilities functions shared by Medusa core and Modules
54 lines • 1.9 kB
TypeScript
import { MikroORM, MikroORMOptions } from "@mikro-orm/core";
import { MigrateOptions, MigrationResult, UmzugMigration } from "@mikro-orm/migrations";
import { PostgreSqlDriver } from "@mikro-orm/postgresql";
import { EventEmitter } from "events";
/**
* Events emitted by the migrations class
*/
export type MigrationsEvents = {
migrating: [UmzugMigration];
migrated: [UmzugMigration];
reverting: [UmzugMigration];
reverted: [UmzugMigration];
"revert:skipped": [UmzugMigration & {
reason: string;
}];
};
/**
* Exposes the API to programmatically manage Mikro ORM migrations
*/
export declare class Migrations extends EventEmitter<MigrationsEvents> {
#private;
constructor(configOrConnection: Partial<MikroORMOptions> | MikroORM<PostgreSqlDriver>);
/**
* Generates migrations for a collection of entities defined
* in the config
*/
generate(): Promise<MigrationResult>;
/**
* Run migrations for the provided entities
*/
run(options?: string | string[] | MigrateOptions): Promise<UmzugMigration[]>;
/**
* Run migrations for the provided entities
*/
revert(options?: string | string[] | MigrateOptions): Promise<UmzugMigration[]>;
/**
* Migrates the existing snapshot file of a module to follow to be
* named after the current snapshot file.
*
* If there are multiple snapshot files inside the directory, then
* the first one will be used.
*/
protected migrateSnapshotFile(snapshotPath: string): Promise<void>;
/**
* Generate a default snapshot file if it does not already exists. This
* prevent from creating a database to manage the migrations and instead
* rely on the snapshot.
*
* @param snapshotPath
* @protected
*/
protected ensureSnapshot(snapshotPath: string): Promise<void>;
}
//# sourceMappingURL=index.d.ts.map