@mikro-orm/migrations 7.0.0-dev.106 → 7.0.0-dev.108
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/MigrationGenerator.js +1 -2
- package/Migrator.js +4 -4
- package/package.json +3 -3
package/MigrationGenerator.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Utils, } from '@mikro-orm/core';
|
|
2
1
|
import { fs } from '@mikro-orm/core/fs-utils';
|
|
3
2
|
import { writeFile } from 'node:fs/promises';
|
|
4
3
|
export class MigrationGenerator {
|
|
@@ -16,7 +15,7 @@ export class MigrationGenerator {
|
|
|
16
15
|
async generate(diff, path, name) {
|
|
17
16
|
/* v8 ignore next */
|
|
18
17
|
const defaultPath = this.options.emit === 'ts' && this.options.pathTs ? this.options.pathTs : this.options.path;
|
|
19
|
-
path =
|
|
18
|
+
path = fs.normalizePath(this.driver.config.get('baseDir'), path ?? defaultPath);
|
|
20
19
|
fs.ensureDir(path);
|
|
21
20
|
const timestamp = new Date().toISOString().replace(/[-T:]|\.\d{3}z$/ig, '');
|
|
22
21
|
const className = this.namingStrategy.classToMigrationName(timestamp, name);
|
package/Migrator.js
CHANGED
|
@@ -29,14 +29,14 @@ export class Migrator {
|
|
|
29
29
|
this.detectSourceFolder();
|
|
30
30
|
/* v8 ignore next */
|
|
31
31
|
const key = (this.config.get('preferTs', Utils.detectTypeScriptSupport()) && this.options.pathTs) ? 'pathTs' : 'path';
|
|
32
|
-
this.absolutePath =
|
|
32
|
+
this.absolutePath = fs.absolutePath(this.options[key], this.config.get('baseDir'));
|
|
33
33
|
// for snapshots, we always want to use the path based on `emit` option, regardless of whether we run in TS context
|
|
34
34
|
/* v8 ignore next */
|
|
35
35
|
const snapshotPath = this.options.emit === 'ts' && this.options.pathTs ? this.options.pathTs : this.options.path;
|
|
36
|
-
const absoluteSnapshotPath =
|
|
36
|
+
const absoluteSnapshotPath = fs.absolutePath(snapshotPath, this.config.get('baseDir'));
|
|
37
37
|
const dbName = basename(this.config.get('dbName'));
|
|
38
38
|
const snapshotName = this.options.snapshotName ?? `.snapshot-${dbName}`;
|
|
39
|
-
this.snapshotPath =
|
|
39
|
+
this.snapshotPath = fs.normalizePath(absoluteSnapshotPath, `${snapshotName}.json`);
|
|
40
40
|
this.createUmzug();
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
@@ -242,7 +242,7 @@ export class Migrator {
|
|
|
242
242
|
}
|
|
243
243
|
resolve(params) {
|
|
244
244
|
const createMigrationHandler = async (method) => {
|
|
245
|
-
const migration = await
|
|
245
|
+
const migration = await fs.dynamicImport(params.path);
|
|
246
246
|
const MigrationClass = Object.values(migration).find(cls => typeof cls === 'function' && typeof cls.constructor === 'function');
|
|
247
247
|
const instance = new MigrationClass(this.driver, this.config);
|
|
248
248
|
await this.runner.run(instance, method);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/migrations",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.0.0-dev.
|
|
4
|
+
"version": "7.0.0-dev.108",
|
|
5
5
|
"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.",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./package.json": "./package.json",
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@mikro-orm/sql": "7.0.0-dev.
|
|
53
|
+
"@mikro-orm/sql": "7.0.0-dev.108",
|
|
54
54
|
"umzug": "3.8.2"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@mikro-orm/core": "^6.6.2"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@mikro-orm/core": "7.0.0-dev.
|
|
60
|
+
"@mikro-orm/core": "7.0.0-dev.108"
|
|
61
61
|
}
|
|
62
62
|
}
|