UNPKG

@palmares/databases

Version:

Add support for working with databases with palmares framework

57 lines 3.13 kB
import type { MigrationsToAddAfterIterationType } from './type'; import type { DatabaseSettingsType, InitializedEngineInstancesType } from '../../types'; import type { FoundMigrationsFileType } from '../types'; /** * This class holds the logic for evaluating migrations, usually evaluating migrations is simple because we just * need to build and call the `Migration` class. */ export declare class Migrate { settings: DatabaseSettingsType; migrationsToAddAfterIteration: MigrationsToAddAfterIterationType[]; private constructor(); /** * Instead of passing the values to save here, you see that we look through the `migrationsToAddAfterIteration` * because although we recommend adding the '@palmares/database' as the first domain in the project, there might * have use cases where users set other stuff first. * * Because of that, we hold the data to save in PalmaresMigration until it is created in the database so when it is * created we can save all of the data. * * So what you do is that you append a data to `migrationsToAddAfterIteration`, and only after that you can iterate * over. To save to the database that the migration was added. * * @param migrationName - The name of the migration file that was evaluated. * @param engineName - The name of the user defined engine that was created in `DATABASES` */ saveMigration(migrationName: string, engineName: string): Promise<void>; /** * Retrieve the last migration name that was created in the database. This is the last migration file name * that was evaluated by palmares. This way we can filter only the migrations after that. * * @param engineName - The name of the engine to use, usually it will be the `default`. */ getLastMigration(engineName: string): Promise<string | null>; /** * This is the main method that is used to run the migrations in the specific database. * * There are 2 ways to run the migrations: * - Either we batch them into a single migration that just gets the current state and let the ORM handle the rest. * - Run each migration file individually and each migration action one by one. * * @param engineInstance - The engine instance that is being used to run all of the migrations * in the database. * @param allMigrationsOfDatabase - All of the migration files that are available to be used inside of * this database. */ private _run; /** * This is a factory method that MUST be called to create a new instance of the `Migrate` class. * * @param settings - The settings that is being used. * @param migrations - All of the migrations that are available to be used for this database. * @param initializedEngineInstances - The engine instances that were initialized so we can run the migrations * in each database. */ static buildAndRun(settings: DatabaseSettingsType, migrations: FoundMigrationsFileType[], initializedEngineInstances: InitializedEngineInstancesType): Promise<void>; } //# sourceMappingURL=index.d.ts.map