@mikro-orm/migrations 7.2.0-dev.0 → 7.2.0-dev.10
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/JSMigrationGenerator.js +1 -0
- package/Migration.d.ts +2 -0
- package/Migration.js +2 -0
- package/Migrator.js +6 -2
- package/TSMigrationGenerator.js +1 -0
- package/package.json +4 -4
package/JSMigrationGenerator.js
CHANGED
|
@@ -9,6 +9,7 @@ export class JSMigrationGenerator extends MigrationGenerator {
|
|
|
9
9
|
ret += `Object.defineProperty(exports, '__esModule', { value: true });\n`;
|
|
10
10
|
ret += `const { Migration } = require('@mikro-orm/migrations');\n\n`;
|
|
11
11
|
ret += `class ${className} extends Migration {\n\n`;
|
|
12
|
+
ret += ` name = '${className}';\n\n`;
|
|
12
13
|
ret += ` async up() {\n`;
|
|
13
14
|
diff.up.forEach(sql => (ret += this.createStatement(sql, 4)));
|
|
14
15
|
ret += ` }\n\n`;
|
package/Migration.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export declare abstract class Migration {
|
|
|
7
7
|
#private;
|
|
8
8
|
protected readonly driver: AbstractSqlDriver;
|
|
9
9
|
protected readonly config: Configuration;
|
|
10
|
+
/** Stable migration name, used instead of the class name (which minifiers can mangle). */
|
|
11
|
+
name?: string;
|
|
10
12
|
protected ctx?: Transaction;
|
|
11
13
|
constructor(driver: AbstractSqlDriver, config: Configuration);
|
|
12
14
|
abstract up(): Promise<void> | void;
|
package/Migration.js
CHANGED
package/Migrator.js
CHANGED
|
@@ -30,6 +30,9 @@ export class Migrator extends AbstractMigrator {
|
|
|
30
30
|
}
|
|
31
31
|
async getSnapshotPath() {
|
|
32
32
|
if (!this.#snapshotPath) {
|
|
33
|
+
// the snapshot is probed before `init()`, so the source folder auto-detection has to run first,
|
|
34
|
+
// otherwise the path stays unresolved and the snapshot is looked up in `baseDir`
|
|
35
|
+
await this.resolvePaths();
|
|
33
36
|
const { fs } = await import('@mikro-orm/core/fs-utils');
|
|
34
37
|
// for snapshots, we always want to use the path based on `emit` option, regardless of whether we run in TS context
|
|
35
38
|
/* v8 ignore next */
|
|
@@ -146,9 +149,10 @@ export class Migrator extends AbstractMigrator {
|
|
|
146
149
|
}
|
|
147
150
|
async runMigrations(method, options) {
|
|
148
151
|
const result = await super.runMigrations(method, options);
|
|
149
|
-
if (result.length > 0 && this.options.snapshot) {
|
|
152
|
+
if (result.length > 0 && this.options.snapshot && this.options.snapshotOnMigrate) {
|
|
150
153
|
const ctx = Utils.isObject(options) ? options.transaction : undefined;
|
|
151
|
-
const
|
|
154
|
+
const { skipTables, skipViews } = this.config.get('schemaGenerator');
|
|
155
|
+
const schema = await DatabaseSchema.create(this.em.getConnection(), this.em.getPlatform(), this.config, undefined, undefined, undefined, skipTables, skipViews, ctx);
|
|
152
156
|
// keep the snapshot authored by `migration:create` when the migrated DB still matches it
|
|
153
157
|
// semantically — rewriting it from introspection only churns cosmetic serialization noise
|
|
154
158
|
// (expression casing/reformatting, native-enum mapped type, index method, ...) into the diff
|
package/TSMigrationGenerator.js
CHANGED
|
@@ -7,6 +7,7 @@ export class TSMigrationGenerator extends MigrationGenerator {
|
|
|
7
7
|
generateMigrationFile(className, diff) {
|
|
8
8
|
let ret = `import { Migration } from '@mikro-orm/migrations';\n\n`;
|
|
9
9
|
ret += `export class ${className} extends Migration {\n\n`;
|
|
10
|
+
ret += ` override name = '${className}';\n\n`;
|
|
10
11
|
ret += ` override up(): void | Promise<void> {\n`;
|
|
11
12
|
diff.up.forEach(sql => (ret += this.createStatement(sql, 4)));
|
|
12
13
|
ret += ` }\n\n`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/migrations",
|
|
3
|
-
"version": "7.2.0-dev.
|
|
3
|
+
"version": "7.2.0-dev.10",
|
|
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.2.0-dev.
|
|
50
|
+
"@mikro-orm/sql": "7.2.0-dev.10"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@mikro-orm/core": "^7.1.
|
|
53
|
+
"@mikro-orm/core": "^7.1.11"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.2.0-dev.
|
|
56
|
+
"@mikro-orm/core": "7.2.0-dev.10"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|