@mikro-orm/migrations 7.0.15-dev.6 → 7.0.15-dev.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@ export declare class MigrationRunner {
8
8
  protected readonly options: MigrationsOptions;
9
9
  protected readonly config: Configuration;
10
10
  constructor(driver: AbstractSqlDriver, options: MigrationsOptions, config: Configuration);
11
- run(migration: Migration, method: 'up' | 'down'): Promise<void>;
11
+ run(migration: Migration, method: 'up' | 'down', afterRun?: (tx?: Transaction) => Promise<void>): Promise<void>;
12
12
  setMasterMigration(trx: Transaction): void;
13
13
  unsetMasterMigration(): void;
14
14
  private getQueries;
@@ -14,17 +14,19 @@ export class MigrationRunner {
14
14
  this.#connection = this.driver.getConnection();
15
15
  this.#helper = this.driver.getPlatform().getSchemaHelper();
16
16
  }
17
- async run(migration, method) {
17
+ async run(migration, method, afterRun) {
18
18
  migration.reset();
19
19
  if (!this.options.transactional || !migration.isTransactional()) {
20
20
  const queries = await this.getQueries(migration, method);
21
21
  await Utils.runSerial(queries, sql => this.driver.execute(sql));
22
+ await afterRun?.();
22
23
  }
23
24
  else {
24
25
  await this.#connection.transactional(async (tx) => {
25
26
  migration.setTransactionContext(tx);
26
27
  const queries = await this.getQueries(migration, method);
27
28
  await Utils.runSerial(queries, sql => this.driver.execute(sql, undefined, 'all', tx));
29
+ await afterRun?.(tx);
28
30
  }, { ctx: this.#masterTransaction });
29
31
  }
30
32
  }
@@ -10,10 +10,10 @@ export declare class MigrationStorage {
10
10
  executed(): Promise<string[]>;
11
11
  logMigration(params: {
12
12
  name: string;
13
- }): Promise<void>;
13
+ }, tx?: Transaction): Promise<void>;
14
14
  unlogMigration(params: {
15
15
  name: string;
16
- }): Promise<void>;
16
+ }, tx?: Transaction): Promise<void>;
17
17
  getExecutedMigrations(): Promise<MigrationRow[]>;
18
18
  ensureTable(): Promise<void>;
19
19
  setMasterMigration(trx: Transaction): void;
@@ -19,16 +19,16 @@ export class MigrationStorage {
19
19
  const migrations = await this.getExecutedMigrations();
20
20
  return migrations.map(({ name }) => this.getMigrationName(name));
21
21
  }
22
- async logMigration(params) {
22
+ async logMigration(params, tx) {
23
23
  const { entity } = this.getTableName();
24
24
  const name = this.getMigrationName(params.name);
25
- await this.driver.nativeInsert(entity, { name }, { ctx: this.#masterTransaction });
25
+ await this.driver.nativeInsert(entity, { name }, { ctx: tx ?? this.#masterTransaction });
26
26
  }
27
- async unlogMigration(params) {
27
+ async unlogMigration(params, tx) {
28
28
  const { entity } = this.getTableName();
29
29
  const withoutExt = this.getMigrationName(params.name);
30
30
  const names = [withoutExt, withoutExt + '.js', withoutExt + '.ts'];
31
- await this.driver.nativeDelete(entity, { name: { $in: [params.name, ...names] } }, { ctx: this.#masterTransaction });
31
+ await this.driver.nativeDelete(entity, { name: { $in: [params.name, ...names] } }, { ctx: tx ?? this.#masterTransaction });
32
32
  }
33
33
  async getExecutedMigrations() {
34
34
  const { entity, schemaName } = this.getTableName();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/migrations",
3
- "version": "7.0.15-dev.6",
3
+ "version": "7.0.15-dev.7",
4
4
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
5
5
  "keywords": [
6
6
  "data-mapper",
@@ -47,13 +47,13 @@
47
47
  "copy": "node ../../scripts/copy.mjs"
48
48
  },
49
49
  "dependencies": {
50
- "@mikro-orm/sql": "7.0.15-dev.6"
50
+ "@mikro-orm/sql": "7.0.15-dev.7"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@mikro-orm/core": "^7.0.14"
54
54
  },
55
55
  "peerDependencies": {
56
- "@mikro-orm/core": "7.0.15-dev.6"
56
+ "@mikro-orm/core": "7.0.15-dev.7"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"