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

Function runMigrations

packages/core/src/utils/AbstractMigrator.ts:715–738  ·  view source on GitHub ↗
(
    method: 'up' | 'down',
    options?: string | string[] | MigrateOptions,
  )

Source from the content-addressed store, hash-verified

713 }
714
715 protected async runMigrations(
716 method: 'up' | 'down',
717 options?: string | string[] | MigrateOptions,
718 ): Promise<MigrationInfo[]> {
719 await this.init();
720 const normalized = this.prefix(options);
721 this.runner.setRunSchema?.(normalized.schema);
722 this.storage.setRunSchema?.(normalized.schema);
723
724 try {
725 if (!this.options.transactional || !this.options.allOrNothing) {
726 return await this.executeMigrations(method, normalized);
727 }
728
729 if (Utils.isObject<MigrateOptions>(options) && options.transaction) {
730 return await this.runInTransaction(options.transaction, method, normalized);
731 }
732
733 return await this.driver.getConnection().transactional(trx => this.runInTransaction(trx, method, normalized));
734 } finally {
735 this.runner.unsetRunSchema?.();
736 this.storage.unsetRunSchema?.();
737 }
738 }
739
740 private async runInTransaction(trx: Transaction, method: 'up' | 'down', options: NormalizedMigrateOptions) {
741 this.runner.setMasterMigration(trx);

Callers

nothing calls this directly

Calls 7

isObjectMethod · 0.80
initMethod · 0.65
prefixMethod · 0.65
setRunSchemaMethod · 0.65
getConnectionMethod · 0.65
unsetRunSchemaMethod · 0.65
transactionalMethod · 0.45

Tested by

no test coverage detected