@mikro-orm/migrations 7.0.0-dev.0 → 7.0.0-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/JSMigrationGenerator.d.ts +1 -1
- package/JSMigrationGenerator.js +3 -7
- package/Migration.js +1 -5
- package/MigrationGenerator.js +7 -11
- package/MigrationRunner.d.ts +1 -1
- package/MigrationRunner.js +5 -9
- package/MigrationStorage.d.ts +1 -1
- package/MigrationStorage.js +4 -41
- package/Migrator.d.ts +3 -3
- package/Migrator.js +44 -48
- package/TSMigrationGenerator.d.ts +1 -1
- package/TSMigrationGenerator.js +2 -6
- package/index.d.ts +8 -8
- package/index.js +8 -24
- package/package.json +6 -15
- package/typings.js +1 -2
- package/index.mjs +0 -10
package/JSMigrationGenerator.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.JSMigrationGenerator = void 0;
|
|
4
|
-
const MigrationGenerator_1 = require("./MigrationGenerator");
|
|
5
|
-
class JSMigrationGenerator extends MigrationGenerator_1.MigrationGenerator {
|
|
1
|
+
import { MigrationGenerator } from './MigrationGenerator.js';
|
|
2
|
+
export class JSMigrationGenerator extends MigrationGenerator {
|
|
6
3
|
/**
|
|
7
4
|
* @inheritDoc
|
|
8
5
|
*/
|
|
@@ -14,7 +11,7 @@ class JSMigrationGenerator extends MigrationGenerator_1.MigrationGenerator {
|
|
|
14
11
|
ret += ` async up() {\n`;
|
|
15
12
|
diff.up.forEach(sql => ret += this.createStatement(sql, 4));
|
|
16
13
|
ret += ` }\n\n`;
|
|
17
|
-
/*
|
|
14
|
+
/* v8 ignore next 5 */
|
|
18
15
|
if (diff.down.length > 0) {
|
|
19
16
|
ret += ` async down() {\n`;
|
|
20
17
|
diff.down.forEach(sql => ret += this.createStatement(sql, 4));
|
|
@@ -25,4 +22,3 @@ class JSMigrationGenerator extends MigrationGenerator_1.MigrationGenerator {
|
|
|
25
22
|
return ret;
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
|
-
exports.JSMigrationGenerator = JSMigrationGenerator;
|
package/Migration.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Migration = void 0;
|
|
4
|
-
class Migration {
|
|
1
|
+
export class Migration {
|
|
5
2
|
driver;
|
|
6
3
|
config;
|
|
7
4
|
queries = [];
|
|
@@ -49,4 +46,3 @@ class Migration {
|
|
|
49
46
|
return this.queries;
|
|
50
47
|
}
|
|
51
48
|
}
|
|
52
|
-
exports.Migration = Migration;
|
package/MigrationGenerator.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const core_1 = require("@mikro-orm/core");
|
|
5
|
-
const fs_extra_1 = require("fs-extra");
|
|
6
|
-
class MigrationGenerator {
|
|
1
|
+
import { Utils, } from '@mikro-orm/core';
|
|
2
|
+
import { writeFile } from 'node:fs/promises';
|
|
3
|
+
export class MigrationGenerator {
|
|
7
4
|
driver;
|
|
8
5
|
namingStrategy;
|
|
9
6
|
options;
|
|
@@ -16,15 +13,15 @@ class MigrationGenerator {
|
|
|
16
13
|
* @inheritDoc
|
|
17
14
|
*/
|
|
18
15
|
async generate(diff, path, name) {
|
|
19
|
-
/*
|
|
16
|
+
/* v8 ignore next */
|
|
20
17
|
const defaultPath = this.options.emit === 'ts' && this.options.pathTs ? this.options.pathTs : this.options.path;
|
|
21
|
-
path =
|
|
22
|
-
|
|
18
|
+
path = Utils.normalizePath(this.driver.config.get('baseDir'), path ?? defaultPath);
|
|
19
|
+
Utils.ensureDir(path);
|
|
23
20
|
const timestamp = new Date().toISOString().replace(/[-T:]|\.\d{3}z$/ig, '');
|
|
24
21
|
const className = this.namingStrategy.classToMigrationName(timestamp, name);
|
|
25
22
|
const fileName = `${this.options.fileName(timestamp, name)}.${this.options.emit}`;
|
|
26
23
|
const ret = await this.generateMigrationFile(className, diff);
|
|
27
|
-
await
|
|
24
|
+
await writeFile(path + '/' + fileName, ret, { flush: true });
|
|
28
25
|
return [ret, fileName];
|
|
29
26
|
}
|
|
30
27
|
/**
|
|
@@ -38,4 +35,3 @@ class MigrationGenerator {
|
|
|
38
35
|
return '\n';
|
|
39
36
|
}
|
|
40
37
|
}
|
|
41
|
-
exports.MigrationGenerator = MigrationGenerator;
|
package/MigrationRunner.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Configuration, type MigrationsOptions, type Transaction } from '@mikro-orm/core';
|
|
2
2
|
import type { AbstractSqlDriver } from '@mikro-orm/knex';
|
|
3
|
-
import type { Migration } from './Migration';
|
|
3
|
+
import type { Migration } from './Migration.js';
|
|
4
4
|
export declare class MigrationRunner {
|
|
5
5
|
protected readonly driver: AbstractSqlDriver;
|
|
6
6
|
protected readonly options: MigrationsOptions;
|
package/MigrationRunner.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.MigrationRunner = void 0;
|
|
4
|
-
const core_1 = require("@mikro-orm/core");
|
|
5
|
-
class MigrationRunner {
|
|
1
|
+
import { Utils } from '@mikro-orm/core';
|
|
2
|
+
export class MigrationRunner {
|
|
6
3
|
driver;
|
|
7
4
|
options;
|
|
8
5
|
config;
|
|
@@ -20,13 +17,13 @@ class MigrationRunner {
|
|
|
20
17
|
migration.reset();
|
|
21
18
|
if (!this.options.transactional || !migration.isTransactional()) {
|
|
22
19
|
const queries = await this.getQueries(migration, method);
|
|
23
|
-
await
|
|
20
|
+
await Utils.runSerial(queries, sql => this.driver.execute(sql));
|
|
24
21
|
}
|
|
25
22
|
else {
|
|
26
23
|
await this.connection.transactional(async (tx) => {
|
|
27
24
|
migration.setTransactionContext(tx);
|
|
28
25
|
const queries = await this.getQueries(migration, method);
|
|
29
|
-
await
|
|
26
|
+
await Utils.runSerial(queries, sql => this.driver.execute(sql, undefined, 'all', tx));
|
|
30
27
|
}, { ctx: this.masterTransaction });
|
|
31
28
|
}
|
|
32
29
|
}
|
|
@@ -42,8 +39,7 @@ class MigrationRunner {
|
|
|
42
39
|
let queries = migration.getQueries();
|
|
43
40
|
queries.unshift(...this.helper.getSchemaBeginning(charset, this.options.disableForeignKeys).split('\n'));
|
|
44
41
|
queries.push(...this.helper.getSchemaEnd(this.options.disableForeignKeys).split('\n'));
|
|
45
|
-
queries = queries.filter(sql => !
|
|
42
|
+
queries = queries.filter(sql => !Utils.isString(sql) || sql.trim().length > 0);
|
|
46
43
|
return queries;
|
|
47
44
|
}
|
|
48
45
|
}
|
|
49
|
-
exports.MigrationRunner = MigrationRunner;
|
package/MigrationStorage.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MigrationsOptions, Transaction } from '@mikro-orm/core';
|
|
2
2
|
import { type AbstractSqlDriver } from '@mikro-orm/knex';
|
|
3
3
|
import type { MigrationParams, UmzugStorage } from 'umzug';
|
|
4
|
-
import type { MigrationRow } from './typings';
|
|
4
|
+
import type { MigrationRow } from './typings.js';
|
|
5
5
|
export declare class MigrationStorage implements UmzugStorage {
|
|
6
6
|
protected readonly driver: AbstractSqlDriver;
|
|
7
7
|
protected readonly options: MigrationsOptions;
|
package/MigrationStorage.js
CHANGED
|
@@ -1,42 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.MigrationStorage = void 0;
|
|
37
|
-
const knex_1 = require("@mikro-orm/knex");
|
|
38
|
-
const path = __importStar(require("node:path"));
|
|
39
|
-
class MigrationStorage {
|
|
1
|
+
import { DatabaseTable, } from '@mikro-orm/knex';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
export class MigrationStorage {
|
|
40
4
|
driver;
|
|
41
5
|
options;
|
|
42
6
|
connection;
|
|
@@ -89,7 +53,7 @@ class MigrationStorage {
|
|
|
89
53
|
const sql = this.helper.getCreateNamespaceSQL(schemaName);
|
|
90
54
|
await this.connection.execute(sql);
|
|
91
55
|
}
|
|
92
|
-
const table = new
|
|
56
|
+
const table = new DatabaseTable(this.platform, tableName, schemaName);
|
|
93
57
|
table.addColumn({
|
|
94
58
|
name: 'id',
|
|
95
59
|
type: this.platform.getIntegerTypeDeclarationSQL({ autoincrement: true, unsigned: true }),
|
|
@@ -140,4 +104,3 @@ class MigrationStorage {
|
|
|
140
104
|
return { tableName, schemaName };
|
|
141
105
|
}
|
|
142
106
|
}
|
|
143
|
-
exports.MigrationStorage = MigrationStorage;
|
package/Migrator.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type MigrationParams, type RunnableMigration } from 'umzug';
|
|
2
2
|
import { type Constructor, type IMigrator, type MikroORM, type MigratorEvent, type MaybePromise } from '@mikro-orm/core';
|
|
3
3
|
import { DatabaseSchema, type EntityManager } from '@mikro-orm/knex';
|
|
4
|
-
import type { Migration } from './Migration';
|
|
5
|
-
import { MigrationStorage } from './MigrationStorage';
|
|
6
|
-
import type { MigrateOptions, MigrationResult, MigrationRow, UmzugMigration } from './typings';
|
|
4
|
+
import type { Migration } from './Migration.js';
|
|
5
|
+
import { MigrationStorage } from './MigrationStorage.js';
|
|
6
|
+
import type { MigrateOptions, MigrationResult, MigrationRow, UmzugMigration } from './typings.js';
|
|
7
7
|
export declare class Migrator implements IMigrator {
|
|
8
8
|
private readonly em;
|
|
9
9
|
private umzug;
|
package/Migrator.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const TSMigrationGenerator_1 = require("./TSMigrationGenerator");
|
|
12
|
-
const JSMigrationGenerator_1 = require("./JSMigrationGenerator");
|
|
13
|
-
class Migrator {
|
|
1
|
+
import { Umzug } from 'umzug';
|
|
2
|
+
import { basename, join } from 'node:path';
|
|
3
|
+
import { existsSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { t, Type, UnknownType, Utils, } from '@mikro-orm/core';
|
|
5
|
+
import { DatabaseSchema, DatabaseTable, SqlSchemaGenerator, } from '@mikro-orm/knex';
|
|
6
|
+
import { MigrationRunner } from './MigrationRunner.js';
|
|
7
|
+
import { MigrationStorage } from './MigrationStorage.js';
|
|
8
|
+
import { TSMigrationGenerator } from './TSMigrationGenerator.js';
|
|
9
|
+
import { JSMigrationGenerator } from './JSMigrationGenerator.js';
|
|
10
|
+
export class Migrator {
|
|
14
11
|
em;
|
|
15
12
|
umzug;
|
|
16
13
|
runner;
|
|
@@ -25,19 +22,19 @@ class Migrator {
|
|
|
25
22
|
constructor(em) {
|
|
26
23
|
this.em = em;
|
|
27
24
|
this.driver = this.em.getDriver();
|
|
28
|
-
this.schemaGenerator = new
|
|
25
|
+
this.schemaGenerator = new SqlSchemaGenerator(this.em);
|
|
29
26
|
this.config = this.em.config;
|
|
30
27
|
this.options = this.config.get('migrations');
|
|
31
|
-
/*
|
|
32
|
-
const key = (this.config.get('preferTs',
|
|
33
|
-
this.absolutePath =
|
|
34
|
-
// for snapshots, we always want to use the path based on `emit` option, regardless of whether we run in
|
|
35
|
-
/*
|
|
28
|
+
/* v8 ignore next */
|
|
29
|
+
const key = (this.config.get('preferTs', Utils.detectTypeScriptSupport()) && this.options.pathTs) ? 'pathTs' : 'path';
|
|
30
|
+
this.absolutePath = Utils.absolutePath(this.options[key], this.config.get('baseDir'));
|
|
31
|
+
// for snapshots, we always want to use the path based on `emit` option, regardless of whether we run in TS context
|
|
32
|
+
/* v8 ignore next */
|
|
36
33
|
const snapshotPath = this.options.emit === 'ts' && this.options.pathTs ? this.options.pathTs : this.options.path;
|
|
37
|
-
const absoluteSnapshotPath =
|
|
38
|
-
const dbName =
|
|
34
|
+
const absoluteSnapshotPath = Utils.absolutePath(snapshotPath, this.config.get('baseDir'));
|
|
35
|
+
const dbName = basename(this.config.get('dbName'));
|
|
39
36
|
const snapshotName = this.options.snapshotName ?? `.snapshot-${dbName}`;
|
|
40
|
-
this.snapshotPath =
|
|
37
|
+
this.snapshotPath = Utils.normalizePath(absoluteSnapshotPath, `${snapshotName}.json`);
|
|
41
38
|
this.createUmzug();
|
|
42
39
|
}
|
|
43
40
|
static register(orm) {
|
|
@@ -50,7 +47,7 @@ class Migrator {
|
|
|
50
47
|
if (initial) {
|
|
51
48
|
return this.createInitialMigration(path, name, blank);
|
|
52
49
|
}
|
|
53
|
-
|
|
50
|
+
this.ensureMigrationsDirExists();
|
|
54
51
|
const diff = await this.getSchemaDiff(blank, initial);
|
|
55
52
|
if (diff.up.length === 0) {
|
|
56
53
|
return { fileName: '', code: '', diff };
|
|
@@ -64,7 +61,7 @@ class Migrator {
|
|
|
64
61
|
};
|
|
65
62
|
}
|
|
66
63
|
async checkMigrationNeeded() {
|
|
67
|
-
|
|
64
|
+
this.ensureMigrationsDirExists();
|
|
68
65
|
const diff = await this.getSchemaDiff(false, false);
|
|
69
66
|
return diff.up.length > 0;
|
|
70
67
|
}
|
|
@@ -72,7 +69,7 @@ class Migrator {
|
|
|
72
69
|
* @inheritDoc
|
|
73
70
|
*/
|
|
74
71
|
async createInitialMigration(path, name, blank = false) {
|
|
75
|
-
|
|
72
|
+
this.ensureMigrationsDirExists();
|
|
76
73
|
const schemaExists = await this.validateInitialMigration(blank);
|
|
77
74
|
const diff = await this.getSchemaDiff(blank, true);
|
|
78
75
|
const migration = await this.generator.generate(diff, path, name);
|
|
@@ -101,10 +98,10 @@ class Migrator {
|
|
|
101
98
|
return this;
|
|
102
99
|
}
|
|
103
100
|
createUmzug() {
|
|
104
|
-
this.runner = new
|
|
105
|
-
this.storage = new
|
|
101
|
+
this.runner = new MigrationRunner(this.driver, this.options, this.config);
|
|
102
|
+
this.storage = new MigrationStorage(this.driver, this.options);
|
|
106
103
|
let migrations = {
|
|
107
|
-
glob:
|
|
104
|
+
glob: join(this.absolutePath, this.options.glob).replace(/\\/g, '/'),
|
|
108
105
|
resolve: (params) => this.resolve(params),
|
|
109
106
|
};
|
|
110
107
|
if (this.options.migrationsList) {
|
|
@@ -115,7 +112,7 @@ class Migrator {
|
|
|
115
112
|
return this.initialize(migration.class, migration.name);
|
|
116
113
|
});
|
|
117
114
|
}
|
|
118
|
-
this.umzug = new
|
|
115
|
+
this.umzug = new Umzug({
|
|
119
116
|
storage: this.storage,
|
|
120
117
|
logger: undefined,
|
|
121
118
|
migrations,
|
|
@@ -131,10 +128,10 @@ class Migrator {
|
|
|
131
128
|
this.generator = new this.options.generator(this.driver, this.config.getNamingStrategy(), this.options);
|
|
132
129
|
}
|
|
133
130
|
else if (this.options.emit === 'js' || this.options.emit === 'cjs') {
|
|
134
|
-
this.generator = new
|
|
131
|
+
this.generator = new JSMigrationGenerator(this.driver, this.config.getNamingStrategy(), this.options);
|
|
135
132
|
}
|
|
136
133
|
else {
|
|
137
|
-
this.generator = new
|
|
134
|
+
this.generator = new TSMigrationGenerator(this.driver, this.config.getNamingStrategy(), this.options);
|
|
138
135
|
}
|
|
139
136
|
}
|
|
140
137
|
/**
|
|
@@ -151,7 +148,7 @@ class Migrator {
|
|
|
151
148
|
if (executed.length > 0 || pending.length > 0) {
|
|
152
149
|
throw new Error('Initial migration cannot be created, as some migrations already exist');
|
|
153
150
|
}
|
|
154
|
-
const schema = await
|
|
151
|
+
const schema = await DatabaseSchema.create(this.em.getConnection(), this.em.getPlatform(), this.config);
|
|
155
152
|
const exists = new Set();
|
|
156
153
|
const expected = new Set();
|
|
157
154
|
Object.values(this.em.getMetadata().getAll())
|
|
@@ -183,9 +180,9 @@ class Migrator {
|
|
|
183
180
|
return this.storage.getExecutedMigrations();
|
|
184
181
|
}
|
|
185
182
|
async ensureDatabase() {
|
|
186
|
-
|
|
183
|
+
this.ensureMigrationsDirExists();
|
|
187
184
|
const created = await this.schemaGenerator.ensureDatabase();
|
|
188
|
-
/*
|
|
185
|
+
/* v8 ignore next 3 */
|
|
189
186
|
if (created) {
|
|
190
187
|
this.createUmzug();
|
|
191
188
|
}
|
|
@@ -215,7 +212,7 @@ class Migrator {
|
|
|
215
212
|
}
|
|
216
213
|
resolve(params) {
|
|
217
214
|
const createMigrationHandler = async (method) => {
|
|
218
|
-
const migration = await
|
|
215
|
+
const migration = await Utils.dynamicImport(params.path);
|
|
219
216
|
const MigrationClass = Object.values(migration)[0];
|
|
220
217
|
const instance = new MigrationClass(this.driver, this.config);
|
|
221
218
|
await this.runner.run(instance, method);
|
|
@@ -227,20 +224,20 @@ class Migrator {
|
|
|
227
224
|
};
|
|
228
225
|
}
|
|
229
226
|
getSchemaFromSnapshot() {
|
|
230
|
-
if (!this.options.snapshot || !(
|
|
227
|
+
if (!this.options.snapshot || !existsSync(this.snapshotPath)) {
|
|
231
228
|
return undefined;
|
|
232
229
|
}
|
|
233
|
-
const data =
|
|
234
|
-
const schema = new
|
|
230
|
+
const data = Utils.readJSONSync(this.snapshotPath);
|
|
231
|
+
const schema = new DatabaseSchema(this.driver.getPlatform(), this.config.get('schema'));
|
|
235
232
|
const { tables, namespaces, ...rest } = data;
|
|
236
233
|
const tableInstances = tables.map((tbl) => {
|
|
237
|
-
const table = new
|
|
234
|
+
const table = new DatabaseTable(this.driver.getPlatform(), tbl.name);
|
|
238
235
|
const { columns, ...restTable } = tbl;
|
|
239
236
|
Object.assign(table, restTable);
|
|
240
237
|
Object.keys(columns).forEach(col => {
|
|
241
238
|
const column = { ...columns[col] };
|
|
242
|
-
/*
|
|
243
|
-
column.mappedType =
|
|
239
|
+
/* v8 ignore next */
|
|
240
|
+
column.mappedType = Type.getType(t[columns[col].mappedType] ?? UnknownType);
|
|
244
241
|
table.addColumn(column);
|
|
245
242
|
});
|
|
246
243
|
return table;
|
|
@@ -253,7 +250,7 @@ class Migrator {
|
|
|
253
250
|
return;
|
|
254
251
|
}
|
|
255
252
|
const schema = this.schemaGenerator.getTargetSchema();
|
|
256
|
-
|
|
253
|
+
writeFileSync(this.snapshotPath, JSON.stringify(schema, null, 2));
|
|
257
254
|
}
|
|
258
255
|
initialize(MigrationClass, name) {
|
|
259
256
|
const instance = new MigrationClass(this.driver, this.config);
|
|
@@ -301,8 +298,8 @@ class Migrator {
|
|
|
301
298
|
return name.match(/^\d{14}$/) ? this.options.fileName(name) : name;
|
|
302
299
|
}
|
|
303
300
|
prefix(options) {
|
|
304
|
-
if (
|
|
305
|
-
return { migrations:
|
|
301
|
+
if (Utils.isString(options) || Array.isArray(options)) {
|
|
302
|
+
return { migrations: Utils.asArray(options).map(name => this.getMigrationFilename(name)) };
|
|
306
303
|
}
|
|
307
304
|
if (!options) {
|
|
308
305
|
return {};
|
|
@@ -321,7 +318,7 @@ class Migrator {
|
|
|
321
318
|
if (!this.options.transactional || !this.options.allOrNothing) {
|
|
322
319
|
return this.umzug[method](this.prefix(options));
|
|
323
320
|
}
|
|
324
|
-
if (
|
|
321
|
+
if (Utils.isObject(options) && options.transaction) {
|
|
325
322
|
return this.runInTransaction(options.transaction, method, options);
|
|
326
323
|
}
|
|
327
324
|
return this.driver.getConnection().transactional(trx => this.runInTransaction(trx, method, options));
|
|
@@ -334,10 +331,9 @@ class Migrator {
|
|
|
334
331
|
this.storage.unsetMasterMigration();
|
|
335
332
|
return ret;
|
|
336
333
|
}
|
|
337
|
-
|
|
334
|
+
ensureMigrationsDirExists() {
|
|
338
335
|
if (!this.options.migrationsList) {
|
|
339
|
-
|
|
336
|
+
Utils.ensureDir(this.absolutePath);
|
|
340
337
|
}
|
|
341
338
|
}
|
|
342
339
|
}
|
|
343
|
-
exports.Migrator = Migrator;
|
package/TSMigrationGenerator.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.TSMigrationGenerator = void 0;
|
|
4
|
-
const MigrationGenerator_1 = require("./MigrationGenerator");
|
|
5
|
-
class TSMigrationGenerator extends MigrationGenerator_1.MigrationGenerator {
|
|
1
|
+
import { MigrationGenerator } from './MigrationGenerator.js';
|
|
2
|
+
export class TSMigrationGenerator extends MigrationGenerator {
|
|
6
3
|
/**
|
|
7
4
|
* @inheritDoc
|
|
8
5
|
*/
|
|
@@ -21,4 +18,3 @@ class TSMigrationGenerator extends MigrationGenerator_1.MigrationGenerator {
|
|
|
21
18
|
return ret;
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
|
-
exports.TSMigrationGenerator = TSMigrationGenerator;
|
package/index.d.ts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* @packageDocumentation
|
|
3
3
|
* @module migrations
|
|
4
4
|
*/
|
|
5
|
-
export * from './Migrator';
|
|
6
|
-
export * from './Migration';
|
|
7
|
-
export * from './MigrationRunner';
|
|
8
|
-
export * from './MigrationGenerator';
|
|
9
|
-
export * from './JSMigrationGenerator';
|
|
10
|
-
export * from './TSMigrationGenerator';
|
|
11
|
-
export * from './MigrationStorage';
|
|
12
|
-
export * from './typings';
|
|
5
|
+
export * from './Migrator.js';
|
|
6
|
+
export * from './Migration.js';
|
|
7
|
+
export * from './MigrationRunner.js';
|
|
8
|
+
export * from './MigrationGenerator.js';
|
|
9
|
+
export * from './JSMigrationGenerator.js';
|
|
10
|
+
export * from './TSMigrationGenerator.js';
|
|
11
|
+
export * from './MigrationStorage.js';
|
|
12
|
+
export * from './typings.js';
|
package/index.js
CHANGED
|
@@ -1,28 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
1
|
/**
|
|
18
2
|
* @packageDocumentation
|
|
19
3
|
* @module migrations
|
|
20
4
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
5
|
+
export * from './Migrator.js';
|
|
6
|
+
export * from './Migration.js';
|
|
7
|
+
export * from './MigrationRunner.js';
|
|
8
|
+
export * from './MigrationGenerator.js';
|
|
9
|
+
export * from './JSMigrationGenerator.js';
|
|
10
|
+
export * from './TSMigrationGenerator.js';
|
|
11
|
+
export * from './MigrationStorage.js';
|
|
12
|
+
export * from './typings.js';
|
package/package.json
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/migrations",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "7.0.0-dev.2",
|
|
4
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.",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"module": "index.mjs",
|
|
7
|
-
"typings": "index.d.ts",
|
|
8
6
|
"exports": {
|
|
9
7
|
"./package.json": "./package.json",
|
|
10
|
-
".":
|
|
11
|
-
"import": {
|
|
12
|
-
"types": "./index.d.ts",
|
|
13
|
-
"default": "./index.mjs"
|
|
14
|
-
},
|
|
15
|
-
"require": "./index.js"
|
|
16
|
-
}
|
|
8
|
+
".": "./index.js"
|
|
17
9
|
},
|
|
18
10
|
"repository": {
|
|
19
11
|
"type": "git",
|
|
@@ -49,7 +41,7 @@
|
|
|
49
41
|
"node": ">= 22.11.0"
|
|
50
42
|
},
|
|
51
43
|
"scripts": {
|
|
52
|
-
"build": "yarn clean && yarn compile && yarn copy
|
|
44
|
+
"build": "yarn clean && yarn compile && yarn copy",
|
|
53
45
|
"clean": "yarn run -T rimraf ./dist",
|
|
54
46
|
"compile": "yarn run -T tsc -p tsconfig.build.json",
|
|
55
47
|
"copy": "node ../../scripts/copy.mjs"
|
|
@@ -58,14 +50,13 @@
|
|
|
58
50
|
"access": "public"
|
|
59
51
|
},
|
|
60
52
|
"dependencies": {
|
|
61
|
-
"@mikro-orm/knex": "7.0.0-dev.
|
|
62
|
-
"fs-extra": "11.3.0",
|
|
53
|
+
"@mikro-orm/knex": "7.0.0-dev.2",
|
|
63
54
|
"umzug": "3.8.2"
|
|
64
55
|
},
|
|
65
56
|
"devDependencies": {
|
|
66
57
|
"@mikro-orm/core": "^6.4.5"
|
|
67
58
|
},
|
|
68
59
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "7.0.0-dev.
|
|
60
|
+
"@mikro-orm/core": "7.0.0-dev.2"
|
|
70
61
|
}
|
|
71
62
|
}
|
package/typings.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/index.mjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import mod from "./index.js";
|
|
2
|
-
|
|
3
|
-
export default mod;
|
|
4
|
-
export const JSMigrationGenerator = mod.JSMigrationGenerator;
|
|
5
|
-
export const Migration = mod.Migration;
|
|
6
|
-
export const MigrationGenerator = mod.MigrationGenerator;
|
|
7
|
-
export const MigrationRunner = mod.MigrationRunner;
|
|
8
|
-
export const MigrationStorage = mod.MigrationStorage;
|
|
9
|
-
export const Migrator = mod.Migrator;
|
|
10
|
-
export const TSMigrationGenerator = mod.TSMigrationGenerator;
|