MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / createMigrationHandler

Function createMigrationHandler

packages/core/src/utils/AbstractMigrator.ts:454–463  ·  view source on GitHub ↗
(method: 'up' | 'down', afterRun?: (tx?: Transaction) => Promise<void>)

Source from the content-addressed store, hash-verified

452
453 protected resolve(params: { name: string; path: string }): RunnableMigration {
454 const createMigrationHandler = async (method: 'up' | 'down', afterRun?: (tx?: Transaction) => Promise<void>) => {
455 const { fs } = await import('@mikro-orm/core/fs-utils');
456 const migration = await fs.dynamicImport(params.path);
457 const MigrationClass = Object.values(migration).find(
458 cls => typeof cls === 'function' && typeof cls.constructor === 'function',
459 ) as Constructor<Migration>;
460 const instance = new MigrationClass(this.driver, this.config);
461
462 await this.runner.run(instance, method, afterRun);
463 };
464
465 return {
466 name: this.storage.getMigrationName(params.name),

Callers 1

resolveFunction · 0.85

Calls 4

dynamicImportMethod · 0.80
findMethod · 0.65
runMethod · 0.65
valuesMethod · 0.45

Tested by

no test coverage detected