@mikro-orm/migrations 7.1.0-dev.29 → 7.1.0-dev.30

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
  private resetSessionSchema;
13
13
  setMasterMigration(trx: Transaction): void;
14
14
  unsetMasterMigration(): void;
@@ -15,7 +15,7 @@ export class MigrationRunner {
15
15
  this.#connection = this.driver.getConnection();
16
16
  this.#helper = this.driver.getPlatform().getSchemaHelper();
17
17
  }
18
- async run(migration, method) {
18
+ async run(migration, method, afterRun) {
19
19
  migration.reset();
20
20
  if (!this.options.transactional || !migration.isTransactional()) {
21
21
  // Without a pinned transaction the set/reset statements may land on different pooled
@@ -25,6 +25,7 @@ export class MigrationRunner {
25
25
  }
26
26
  const queries = await this.getQueries(migration, method);
27
27
  await Utils.runSerial(queries, sql => this.driver.execute(sql));
28
+ await afterRun?.();
28
29
  }
29
30
  else {
30
31
  await this.#connection.transactional(async (tx) => {
@@ -32,6 +33,7 @@ export class MigrationRunner {
32
33
  try {
33
34
  const queries = await this.getQueries(migration, method);
34
35
  await Utils.runSerial(queries, sql => this.driver.execute(sql, undefined, 'all', tx));
36
+ await afterRun?.(tx);
35
37
  }
36
38
  finally {
37
39
  await this.resetSessionSchema(tx);
@@ -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;
@@ -21,18 +21,18 @@ export class MigrationStorage {
21
21
  const migrations = await this.getExecutedMigrations();
22
22
  return migrations.map(({ name }) => this.getMigrationName(name));
23
23
  }
24
- async logMigration(params) {
24
+ async logMigration(params, tx) {
25
25
  await this.ensureTable();
26
26
  const { entity } = this.getTableName();
27
27
  const name = this.getMigrationName(params.name);
28
- await this.driver.nativeInsert(entity, { name }, { ctx: this.#masterTransaction });
28
+ await this.driver.nativeInsert(entity, { name }, { ctx: tx ?? this.#masterTransaction });
29
29
  }
30
- async unlogMigration(params) {
30
+ async unlogMigration(params, tx) {
31
31
  await this.ensureTable();
32
32
  const { entity } = this.getTableName();
33
33
  const withoutExt = this.getMigrationName(params.name);
34
34
  const names = [withoutExt, withoutExt + '.js', withoutExt + '.ts'];
35
- await this.driver.nativeDelete(entity, { name: { $in: [params.name, ...names] } }, { ctx: this.#masterTransaction });
35
+ await this.driver.nativeDelete(entity, { name: { $in: [params.name, ...names] } }, { ctx: tx ?? this.#masterTransaction });
36
36
  }
37
37
  async getExecutedMigrations() {
38
38
  await this.ensureTable();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/migrations",
3
- "version": "7.1.0-dev.29",
3
+ "version": "7.1.0-dev.30",
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.1.0-dev.29"
50
+ "@mikro-orm/sql": "7.1.0-dev.30"
51
51
  },
52
52
  "devDependencies": {
53
- "@mikro-orm/core": "^7.0.14"
53
+ "@mikro-orm/core": "^7.0.15"
54
54
  },
55
55
  "peerDependencies": {
56
- "@mikro-orm/core": "7.1.0-dev.29"
56
+ "@mikro-orm/core": "7.1.0-dev.30"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"