@mikro-orm/migrations 6.6.8-dev.1 → 6.6.8-dev.2
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.
- package/Migrator.d.ts +1 -1
- package/Migrator.js +14 -6
- package/package.json +3 -3
package/Migrator.d.ts
CHANGED
|
@@ -65,7 +65,7 @@ export declare class Migrator implements IMigrator {
|
|
|
65
65
|
getStorage(): MigrationStorage;
|
|
66
66
|
protected resolve(params: MigrationParams<any>): RunnableMigration<any>;
|
|
67
67
|
protected getSchemaFromSnapshot(): DatabaseSchema | undefined;
|
|
68
|
-
protected storeCurrentSchema(): Promise<void>;
|
|
68
|
+
protected storeCurrentSchema(schema?: DatabaseSchema): Promise<void>;
|
|
69
69
|
protected initialize(MigrationClass: Constructor<Migration>, name: string): RunnableMigration<any>;
|
|
70
70
|
private getSchemaDiff;
|
|
71
71
|
private getMigrationFilename;
|
package/Migrator.js
CHANGED
|
@@ -248,11 +248,11 @@ class Migrator {
|
|
|
248
248
|
Object.assign(schema, { tables: tableInstances, namespaces: new Set(namespaces), ...rest });
|
|
249
249
|
return schema;
|
|
250
250
|
}
|
|
251
|
-
async storeCurrentSchema() {
|
|
251
|
+
async storeCurrentSchema(schema) {
|
|
252
252
|
if (!this.options.snapshot) {
|
|
253
253
|
return;
|
|
254
254
|
}
|
|
255
|
-
|
|
255
|
+
schema ??= this.schemaGenerator.getTargetSchema();
|
|
256
256
|
await (0, fs_extra_1.writeJSON)(this.snapshotPath, schema, { spaces: 2 });
|
|
257
257
|
}
|
|
258
258
|
initialize(MigrationClass, name) {
|
|
@@ -343,13 +343,21 @@ class Migrator {
|
|
|
343
343
|
}
|
|
344
344
|
async runMigrations(method, options) {
|
|
345
345
|
await this.ensureDatabase();
|
|
346
|
+
let result;
|
|
346
347
|
if (!this.options.transactional || !this.options.allOrNothing) {
|
|
347
|
-
|
|
348
|
+
result = await this.umzug[method](this.prefix(options));
|
|
348
349
|
}
|
|
349
|
-
if (core_1.Utils.isObject(options) && options.transaction) {
|
|
350
|
-
|
|
350
|
+
else if (core_1.Utils.isObject(options) && options.transaction) {
|
|
351
|
+
result = await this.runInTransaction(options.transaction, method, options);
|
|
351
352
|
}
|
|
352
|
-
|
|
353
|
+
else {
|
|
354
|
+
result = await this.driver.getConnection().transactional(trx => this.runInTransaction(trx, method, options));
|
|
355
|
+
}
|
|
356
|
+
if (result.length > 0 && this.options.snapshot) {
|
|
357
|
+
const schema = await knex_1.DatabaseSchema.create(this.em.getConnection(), this.em.getPlatform(), this.config);
|
|
358
|
+
await this.storeCurrentSchema(schema);
|
|
359
|
+
}
|
|
360
|
+
return result;
|
|
353
361
|
}
|
|
354
362
|
async runInTransaction(trx, method, options) {
|
|
355
363
|
this.runner.setMasterMigration(trx);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/migrations",
|
|
3
|
-
"version": "6.6.8-dev.
|
|
3
|
+
"version": "6.6.8-dev.2",
|
|
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
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@mikro-orm/knex": "6.6.8-dev.
|
|
61
|
+
"@mikro-orm/knex": "6.6.8-dev.2",
|
|
62
62
|
"fs-extra": "11.3.3",
|
|
63
63
|
"umzug": "3.8.2"
|
|
64
64
|
},
|
|
@@ -66,6 +66,6 @@
|
|
|
66
66
|
"@mikro-orm/core": "^6.6.7"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "6.6.8-dev.
|
|
69
|
+
"@mikro-orm/core": "6.6.8-dev.2"
|
|
70
70
|
}
|
|
71
71
|
}
|