@mikro-orm/migrations-mongodb 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
  private readonly connection;
9
9
  private masterTransaction?;
10
10
  constructor(driver: MongoDriver, options: MigrationsOptions);
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
  setRunSchema(schema?: string): void;
@@ -10,19 +10,22 @@ export class MigrationRunner {
10
10
  this.options = options;
11
11
  this.connection = this.driver.getConnection();
12
12
  }
13
- async run(migration, method) {
13
+ async run(migration, method, afterRun) {
14
14
  migration.reset();
15
15
  if (!this.options.transactional || !migration.isTransactional()) {
16
16
  await migration[method]();
17
+ await afterRun?.();
17
18
  }
18
19
  else if (this.masterTransaction) {
19
20
  migration.setTransactionContext(this.masterTransaction);
20
21
  await migration[method]();
22
+ await afterRun?.(this.masterTransaction);
21
23
  }
22
24
  else {
23
25
  await this.connection.transactional(async (tx) => {
24
26
  migration.setTransactionContext(tx);
25
27
  await migration[method]();
28
+ await afterRun?.(tx);
26
29
  }, { ctx: this.masterTransaction });
27
30
  }
28
31
  }
@@ -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
  setMasterMigration(trx: Transaction): void;
19
19
  unsetMasterMigration(): void;
@@ -13,15 +13,15 @@ export class MigrationStorage {
13
13
  const migrations = await this.getExecutedMigrations();
14
14
  return migrations.map(({ name }) => this.getMigrationName(name));
15
15
  }
16
- async logMigration(params) {
16
+ async logMigration(params, tx) {
17
17
  const name = this.getMigrationName(params.name);
18
18
  const entity = this.getEntityDefinition();
19
- await this.driver.nativeInsert(entity, { name, executed_at: new Date() }, { ctx: this.masterTransaction });
19
+ await this.driver.nativeInsert(entity, { name, executed_at: new Date() }, { ctx: tx ?? this.masterTransaction });
20
20
  }
21
- async unlogMigration(params) {
21
+ async unlogMigration(params, tx) {
22
22
  const withoutExt = this.getMigrationName(params.name);
23
23
  const entity = this.getEntityDefinition();
24
- await this.driver.nativeDelete(entity, { name: { $in: [params.name, withoutExt] } }, { ctx: this.masterTransaction });
24
+ await this.driver.nativeDelete(entity, { name: { $in: [params.name, withoutExt] } }, { ctx: tx ?? this.masterTransaction });
25
25
  }
26
26
  async getExecutedMigrations() {
27
27
  const entity = this.getEntityDefinition();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/migrations-mongodb",
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,14 +47,14 @@
47
47
  "copy": "node ../../scripts/copy.mjs"
48
48
  },
49
49
  "dependencies": {
50
- "@mikro-orm/mongodb": "7.1.0-dev.29",
50
+ "@mikro-orm/mongodb": "7.1.0-dev.30",
51
51
  "mongodb": "7.2.0"
52
52
  },
53
53
  "devDependencies": {
54
- "@mikro-orm/core": "^7.0.14"
54
+ "@mikro-orm/core": "^7.0.15"
55
55
  },
56
56
  "peerDependencies": {
57
- "@mikro-orm/core": "7.1.0-dev.29"
57
+ "@mikro-orm/core": "7.1.0-dev.30"
58
58
  },
59
59
  "engines": {
60
60
  "node": ">= 22.17.0"