typeorm 0.2.40-dev.e80f97d → 0.2.41-dev.2d0abe7
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/browser/cache/DbQueryResultCache.js +12 -3
- package/browser/cache/DbQueryResultCache.js.map +1 -1
- package/browser/driver/aurora-data-api/AuroraDataApiQueryRunner.js +33 -39
- package/browser/driver/aurora-data-api/AuroraDataApiQueryRunner.js.map +1 -1
- package/browser/driver/cockroachdb/CockroachQueryRunner.js +24 -30
- package/browser/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/browser/driver/mongodb/MongoConnectionOptions.d.ts +4 -0
- package/browser/driver/mongodb/MongoConnectionOptions.js.map +1 -1
- package/browser/driver/mongodb/MongoQueryRunner.d.ts +2 -0
- package/browser/driver/mongodb/MongoQueryRunner.js +3 -0
- package/browser/driver/mongodb/MongoQueryRunner.js.map +1 -1
- package/browser/driver/mysql/MysqlQueryRunner.js +37 -39
- package/browser/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/browser/driver/oracle/OracleDriver.js +1 -1
- package/browser/driver/oracle/OracleDriver.js.map +1 -1
- package/browser/driver/oracle/OracleQueryRunner.js +13 -24
- package/browser/driver/oracle/OracleQueryRunner.js.map +1 -1
- package/browser/driver/postgres/PostgresDriver.d.ts +1 -0
- package/browser/driver/postgres/PostgresDriver.js +16 -7
- package/browser/driver/postgres/PostgresDriver.js.map +1 -1
- package/browser/driver/postgres/PostgresQueryRunner.d.ts +5 -0
- package/browser/driver/postgres/PostgresQueryRunner.js +314 -135
- package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/browser/driver/sap/SapQueryRunner.js +36 -42
- package/browser/driver/sap/SapQueryRunner.js.map +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +8 -14
- package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
- package/browser/driver/sqlserver/SqlServerQueryRunner.js +31 -33
- package/browser/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
- package/browser/driver/types/MetadataTableType.d.ts +5 -0
- package/browser/driver/types/MetadataTableType.js +8 -0
- package/browser/driver/types/MetadataTableType.js.map +1 -0
- package/browser/find-options/FindTreeOptions.d.ts +5 -1
- package/browser/find-options/FindTreeOptions.js.map +1 -1
- package/browser/migration/MigrationExecutor.js +55 -48
- package/browser/migration/MigrationExecutor.js.map +1 -1
- package/browser/query-runner/BaseQueryRunner.d.ts +23 -0
- package/browser/query-runner/BaseQueryRunner.js +37 -0
- package/browser/query-runner/BaseQueryRunner.js.map +1 -1
- package/browser/query-runner/QueryRunner.d.ts +5 -0
- package/browser/query-runner/QueryRunner.js.map +1 -1
- package/browser/repository/FindTreesOptions.d.ts +9 -0
- package/browser/repository/FindTreesOptions.js +3 -0
- package/browser/repository/FindTreesOptions.js.map +1 -0
- package/browser/repository/TreeRepository.d.ts +4 -1
- package/browser/repository/TreeRepository.js +8 -4
- package/browser/repository/TreeRepository.js.map +1 -1
- package/browser/schema-builder/RdbmsSchemaBuilder.d.ts +5 -1
- package/browser/schema-builder/RdbmsSchemaBuilder.js +58 -49
- package/browser/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
- package/cache/DbQueryResultCache.js +12 -3
- package/cache/DbQueryResultCache.js.map +1 -1
- package/driver/aurora-data-api/AuroraDataApiQueryRunner.js +33 -39
- package/driver/aurora-data-api/AuroraDataApiQueryRunner.js.map +1 -1
- package/driver/cockroachdb/CockroachQueryRunner.js +24 -30
- package/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/driver/mongodb/MongoConnectionOptions.d.ts +4 -0
- package/driver/mongodb/MongoConnectionOptions.js.map +1 -1
- package/driver/mongodb/MongoQueryRunner.d.ts +2 -0
- package/driver/mongodb/MongoQueryRunner.js +3 -0
- package/driver/mongodb/MongoQueryRunner.js.map +1 -1
- package/driver/mysql/MysqlQueryRunner.js +37 -39
- package/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/driver/oracle/OracleDriver.js +1 -1
- package/driver/oracle/OracleDriver.js.map +1 -1
- package/driver/oracle/OracleQueryRunner.js +13 -24
- package/driver/oracle/OracleQueryRunner.js.map +1 -1
- package/driver/postgres/PostgresDriver.d.ts +1 -0
- package/driver/postgres/PostgresDriver.js +16 -7
- package/driver/postgres/PostgresDriver.js.map +1 -1
- package/driver/postgres/PostgresQueryRunner.d.ts +5 -0
- package/driver/postgres/PostgresQueryRunner.js +314 -135
- package/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/driver/sap/SapQueryRunner.js +36 -42
- package/driver/sap/SapQueryRunner.js.map +1 -1
- package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +8 -14
- package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
- package/driver/sqlserver/SqlServerQueryRunner.js +31 -33
- package/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
- package/driver/types/MetadataTableType.d.ts +5 -0
- package/driver/types/MetadataTableType.js +11 -0
- package/driver/types/MetadataTableType.js.map +1 -0
- package/find-options/FindTreeOptions.d.ts +5 -1
- package/find-options/FindTreeOptions.js.map +1 -1
- package/migration/MigrationExecutor.js +55 -48
- package/migration/MigrationExecutor.js.map +1 -1
- package/package.json +1 -1
- package/query-runner/BaseQueryRunner.d.ts +23 -0
- package/query-runner/BaseQueryRunner.js +37 -0
- package/query-runner/BaseQueryRunner.js.map +1 -1
- package/query-runner/QueryRunner.d.ts +5 -0
- package/query-runner/QueryRunner.js.map +1 -1
- package/repository/FindTreesOptions.d.ts +9 -0
- package/repository/FindTreesOptions.js +4 -0
- package/repository/FindTreesOptions.js.map +1 -0
- package/repository/TreeRepository.d.ts +4 -1
- package/repository/TreeRepository.js +7 -3
- package/repository/TreeRepository.js.map +1 -1
- package/schema-builder/RdbmsSchemaBuilder.d.ts +5 -1
- package/schema-builder/RdbmsSchemaBuilder.js +58 -49
- package/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var MetadataTableType;
|
|
2
|
+
(function (MetadataTableType) {
|
|
3
|
+
MetadataTableType["VIEW"] = "VIEW";
|
|
4
|
+
MetadataTableType["MATERIALIZED_VIEW"] = "MATERIALIZED_VIEW";
|
|
5
|
+
MetadataTableType["GENERATED_COLUMN"] = "GENERATED_COLUMN";
|
|
6
|
+
})(MetadataTableType || (MetadataTableType = {}));
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=MetadataTableType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../browser/src/driver/types/MetadataTableType.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IACzB,kCAAa,CAAA;IACb,4DAAuC,CAAA;IACvC,0DAAqC,CAAA;AACzC,CAAC,EAJW,iBAAiB,KAAjB,iBAAiB,QAI5B","file":"MetadataTableType.js","sourcesContent":["export enum MetadataTableType {\n VIEW = \"VIEW\",\n MATERIALIZED_VIEW = \"MATERIALIZED_VIEW\",\n GENERATED_COLUMN = \"GENERATED_COLUMN\"\n}\n"],"sourceRoot":"../.."}
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export interface FindTreeOptions {
|
|
5
5
|
/**
|
|
6
|
-
|
|
6
|
+
* Indicates what relations of entity should be loaded (simplified left join form).
|
|
7
7
|
*/
|
|
8
8
|
relations?: string[];
|
|
9
|
+
/**
|
|
10
|
+
* When loading a tree from a TreeRepository, limits the depth of the descendents loaded
|
|
11
|
+
*/
|
|
12
|
+
depth?: number;
|
|
9
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/find-options/FindTreeOptions.ts"],"names":[],"mappings":"","file":"FindTreeOptions.js","sourcesContent":["/**\n * Defines a special criteria to find specific entities.\n */\nexport interface FindTreeOptions {\n\n
|
|
1
|
+
{"version":3,"sources":["../browser/src/find-options/FindTreeOptions.ts"],"names":[],"mappings":"","file":"FindTreeOptions.js","sourcesContent":["/**\n * Defines a special criteria to find specific entities.\n */\nexport interface FindTreeOptions {\n\n /**\n * Indicates what relations of entity should be loaded (simplified left join form).\n */\n relations?: string[];\n\n /**\n * When loading a tree from a TreeRepository, limits the depth of the descendents loaded\n */\n depth?: number;\n\n}\n"],"sourceRoot":".."}
|
|
@@ -3,6 +3,7 @@ import { Table } from "../schema-builder/table/Table";
|
|
|
3
3
|
import { Migration } from "./Migration";
|
|
4
4
|
import { SqlServerDriver } from "../driver/sqlserver/SqlServerDriver";
|
|
5
5
|
import { MssqlParameter } from "../driver/sqlserver/MssqlParameter";
|
|
6
|
+
import { RdbmsSchemaBuilder } from "../schema-builder/RdbmsSchemaBuilder";
|
|
6
7
|
import { MongoDriver } from "../driver/mongodb/MongoDriver";
|
|
7
8
|
import { TypeORMError } from "../error";
|
|
8
9
|
/**
|
|
@@ -191,7 +192,7 @@ var MigrationExecutor = /** @class */ (function () {
|
|
|
191
192
|
*/
|
|
192
193
|
MigrationExecutor.prototype.executePendingMigrations = function () {
|
|
193
194
|
return __awaiter(this, void 0, void 0, function () {
|
|
194
|
-
var queryRunner, executedMigrations, lastTimeExecutedMigration, allMigrations, successMigrations, pendingMigrations, transactionStartedByUs, _loop_2, this_2, pendingMigrations_1, pendingMigrations_1_1, migration, e_2_1, err_1, rollbackError_1;
|
|
195
|
+
var queryRunner, schemaBuilder, executedMigrations, lastTimeExecutedMigration, allMigrations, successMigrations, pendingMigrations, transactionStartedByUs, _loop_2, this_2, pendingMigrations_1, pendingMigrations_1_1, migration, e_2_1, err_1, rollbackError_1;
|
|
195
196
|
var e_2, _a;
|
|
196
197
|
var _this = this;
|
|
197
198
|
return __generator(this, function (_b) {
|
|
@@ -203,8 +204,14 @@ var MigrationExecutor = /** @class */ (function () {
|
|
|
203
204
|
case 1:
|
|
204
205
|
// create migrations table if its not created yet
|
|
205
206
|
_b.sent();
|
|
206
|
-
|
|
207
|
+
schemaBuilder = this.connection.driver.createSchemaBuilder();
|
|
208
|
+
if (!(schemaBuilder instanceof RdbmsSchemaBuilder)) return [3 /*break*/, 3];
|
|
209
|
+
return [4 /*yield*/, schemaBuilder.createMetadataTableIfNecessary(queryRunner)];
|
|
207
210
|
case 2:
|
|
211
|
+
_b.sent();
|
|
212
|
+
_b.label = 3;
|
|
213
|
+
case 3: return [4 /*yield*/, this.loadExecutedMigrations(queryRunner)];
|
|
214
|
+
case 4:
|
|
208
215
|
executedMigrations = _b.sent();
|
|
209
216
|
lastTimeExecutedMigration = this.getLatestTimestampMigration(executedMigrations);
|
|
210
217
|
allMigrations = this.getMigrations();
|
|
@@ -220,15 +227,15 @@ var MigrationExecutor = /** @class */ (function () {
|
|
|
220
227
|
// every check is passed means that migration was not run yet and we need to run it
|
|
221
228
|
return true;
|
|
222
229
|
});
|
|
223
|
-
if (!!pendingMigrations.length) return [3 /*break*/,
|
|
230
|
+
if (!!pendingMigrations.length) return [3 /*break*/, 7];
|
|
224
231
|
this.connection.logger.logSchemaBuild("No migrations are pending");
|
|
225
|
-
if (!!this.queryRunner) return [3 /*break*/,
|
|
232
|
+
if (!!this.queryRunner) return [3 /*break*/, 6];
|
|
226
233
|
return [4 /*yield*/, queryRunner.release()];
|
|
227
|
-
case 3:
|
|
228
|
-
_b.sent();
|
|
229
|
-
_b.label = 4;
|
|
230
|
-
case 4: return [2 /*return*/, []];
|
|
231
234
|
case 5:
|
|
235
|
+
_b.sent();
|
|
236
|
+
_b.label = 6;
|
|
237
|
+
case 6: return [2 /*return*/, []];
|
|
238
|
+
case 7:
|
|
232
239
|
// log information about migration execution
|
|
233
240
|
this.connection.logger.logSchemaBuild(executedMigrations.length + " migrations are already loaded in the database.");
|
|
234
241
|
this.connection.logger.logSchemaBuild(allMigrations.length + " migrations were found in the source code.");
|
|
@@ -236,14 +243,14 @@ var MigrationExecutor = /** @class */ (function () {
|
|
|
236
243
|
this.connection.logger.logSchemaBuild(lastTimeExecutedMigration.name + " is the last executed migration. It was executed on " + new Date(lastTimeExecutedMigration.timestamp).toString() + ".");
|
|
237
244
|
this.connection.logger.logSchemaBuild(pendingMigrations.length + " migrations are new migrations that needs to be executed.");
|
|
238
245
|
transactionStartedByUs = false;
|
|
239
|
-
if (!(this.transaction === "all" && !queryRunner.isTransactionActive)) return [3 /*break*/,
|
|
246
|
+
if (!(this.transaction === "all" && !queryRunner.isTransactionActive)) return [3 /*break*/, 9];
|
|
240
247
|
return [4 /*yield*/, queryRunner.startTransaction()];
|
|
241
|
-
case
|
|
248
|
+
case 8:
|
|
242
249
|
_b.sent();
|
|
243
250
|
transactionStartedByUs = true;
|
|
244
|
-
_b.label =
|
|
245
|
-
case
|
|
246
|
-
_b.trys.push([
|
|
251
|
+
_b.label = 9;
|
|
252
|
+
case 9:
|
|
253
|
+
_b.trys.push([9, 20, 25, 28]);
|
|
247
254
|
_loop_2 = function (migration) {
|
|
248
255
|
return __generator(this, function (_c) {
|
|
249
256
|
switch (_c.label) {
|
|
@@ -286,61 +293,61 @@ var MigrationExecutor = /** @class */ (function () {
|
|
|
286
293
|
});
|
|
287
294
|
};
|
|
288
295
|
this_2 = this;
|
|
289
|
-
_b.label =
|
|
290
|
-
case
|
|
291
|
-
_b.trys.push([
|
|
296
|
+
_b.label = 10;
|
|
297
|
+
case 10:
|
|
298
|
+
_b.trys.push([10, 15, 16, 17]);
|
|
292
299
|
pendingMigrations_1 = __values(pendingMigrations), pendingMigrations_1_1 = pendingMigrations_1.next();
|
|
293
|
-
_b.label =
|
|
294
|
-
case
|
|
295
|
-
if (!!pendingMigrations_1_1.done) return [3 /*break*/,
|
|
300
|
+
_b.label = 11;
|
|
301
|
+
case 11:
|
|
302
|
+
if (!!pendingMigrations_1_1.done) return [3 /*break*/, 14];
|
|
296
303
|
migration = pendingMigrations_1_1.value;
|
|
297
304
|
return [5 /*yield**/, _loop_2(migration)];
|
|
298
|
-
case
|
|
305
|
+
case 12:
|
|
299
306
|
_b.sent();
|
|
300
|
-
_b.label =
|
|
301
|
-
case 11:
|
|
302
|
-
pendingMigrations_1_1 = pendingMigrations_1.next();
|
|
303
|
-
return [3 /*break*/, 9];
|
|
304
|
-
case 12: return [3 /*break*/, 15];
|
|
307
|
+
_b.label = 13;
|
|
305
308
|
case 13:
|
|
309
|
+
pendingMigrations_1_1 = pendingMigrations_1.next();
|
|
310
|
+
return [3 /*break*/, 11];
|
|
311
|
+
case 14: return [3 /*break*/, 17];
|
|
312
|
+
case 15:
|
|
306
313
|
e_2_1 = _b.sent();
|
|
307
314
|
e_2 = { error: e_2_1 };
|
|
308
|
-
return [3 /*break*/,
|
|
309
|
-
case
|
|
315
|
+
return [3 /*break*/, 17];
|
|
316
|
+
case 16:
|
|
310
317
|
try {
|
|
311
318
|
if (pendingMigrations_1_1 && !pendingMigrations_1_1.done && (_a = pendingMigrations_1.return)) _a.call(pendingMigrations_1);
|
|
312
319
|
}
|
|
313
320
|
finally { if (e_2) throw e_2.error; }
|
|
314
321
|
return [7 /*endfinally*/];
|
|
315
|
-
case
|
|
316
|
-
if (!(this.transaction === "all" && transactionStartedByUs)) return [3 /*break*/,
|
|
322
|
+
case 17:
|
|
323
|
+
if (!(this.transaction === "all" && transactionStartedByUs)) return [3 /*break*/, 19];
|
|
317
324
|
return [4 /*yield*/, queryRunner.commitTransaction()];
|
|
318
|
-
case 16:
|
|
319
|
-
_b.sent();
|
|
320
|
-
_b.label = 17;
|
|
321
|
-
case 17: return [3 /*break*/, 26];
|
|
322
325
|
case 18:
|
|
323
|
-
|
|
324
|
-
if (!transactionStartedByUs) return [3 /*break*/, 22];
|
|
326
|
+
_b.sent();
|
|
325
327
|
_b.label = 19;
|
|
326
|
-
case 19:
|
|
327
|
-
_b.trys.push([19, 21, , 22]);
|
|
328
|
-
return [4 /*yield*/, queryRunner.rollbackTransaction()];
|
|
328
|
+
case 19: return [3 /*break*/, 28];
|
|
329
329
|
case 20:
|
|
330
|
-
_b.sent();
|
|
331
|
-
return [3 /*break*/,
|
|
330
|
+
err_1 = _b.sent();
|
|
331
|
+
if (!transactionStartedByUs) return [3 /*break*/, 24];
|
|
332
|
+
_b.label = 21;
|
|
332
333
|
case 21:
|
|
333
|
-
|
|
334
|
-
return [
|
|
335
|
-
case 22:
|
|
334
|
+
_b.trys.push([21, 23, , 24]);
|
|
335
|
+
return [4 /*yield*/, queryRunner.rollbackTransaction()];
|
|
336
|
+
case 22:
|
|
337
|
+
_b.sent();
|
|
338
|
+
return [3 /*break*/, 24];
|
|
336
339
|
case 23:
|
|
337
|
-
|
|
340
|
+
rollbackError_1 = _b.sent();
|
|
341
|
+
return [3 /*break*/, 24];
|
|
342
|
+
case 24: throw err_1;
|
|
343
|
+
case 25:
|
|
344
|
+
if (!!this.queryRunner) return [3 /*break*/, 27];
|
|
338
345
|
return [4 /*yield*/, queryRunner.release()];
|
|
339
|
-
case
|
|
346
|
+
case 26:
|
|
340
347
|
_b.sent();
|
|
341
|
-
_b.label =
|
|
342
|
-
case
|
|
343
|
-
case
|
|
348
|
+
_b.label = 27;
|
|
349
|
+
case 27: return [7 /*endfinally*/];
|
|
350
|
+
case 28: return [2 /*return*/, successMigrations];
|
|
344
351
|
}
|
|
345
352
|
});
|
|
346
353
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/migration/MigrationExecutor.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,+BAA+B,CAAC;AAEpD,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAGtC,OAAO,EAAC,eAAe,EAAC,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAC,cAAc,EAAC,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAC,WAAW,EAAC,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC;;GAEG;AACH;IAuBI,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,2BAAsB,UAAsB,EACtB,WAAyB;QADzB,eAAU,GAAV,UAAU,C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UAA+C,QAAsD;;;;;;wBAC3F,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC;;;;wBAGxE,sBAAO,QAAQ,CAAC,WAAW,CAAC,EAAC;;6BAEzB,CAAC,IAAI,CAAC,WAAW,EAAjB,wBAAiB;wBACjB,qBAAM,WAAW,CAAC,OAAO,EAAE,EAAA;;wBAA3B,SAA2B,CAAC;;;;;;;KAGvC;IACL,wBAAC;AAAD,CA3eA,AA2eC,IAAA","file":"MigrationExecutor.js","sourcesContent":["import {Table} from \"../schema-builder/table/Table\";\nimport {Connection} from \"../connection/Connection\";\nimport {Migration} from \"./Migration\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {SqlServerDriver} from \"../driver/sqlserver/SqlServerDriver\";\nimport {MssqlParameter} from \"../driver/sqlserver/MssqlParameter\";\nimport {MongoDriver} from \"../driver/mongodb/MongoDriver\";\nimport {MongoQueryRunner} from \"../driver/mongodb/MongoQueryRunner\";\nimport { TypeORMError } from \"../error\";\n\n/**\n * Executes migrations: runs pending and reverts previously executed migrations.\n */\nexport class MigrationExecutor {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Indicates how migrations should be run in transactions.\n * all: all migrations are run in a single transaction\n * none: all migrations are run without a transaction\n * each: each migration is run in a separate transaction\n */\n transaction: \"all\" | \"none\" | \"each\" = \"all\";\n\n // -------------------------------------------------------------------------\n // Private Properties\n // -------------------------------------------------------------------------\n\n private readonly migrationsDatabase?: string;\n private readonly migrationsSchema?: string;\n private readonly migrationsTable: string;\n private readonly migrationsTableName: string;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected connection: Connection,\n protected queryRunner?: QueryRunner) {\n\n const { schema } = this.connection.driver.options as any;\n const database = this.connection.driver.database;\n this.migrationsDatabase = database;\n this.migrationsSchema = schema;\n this.migrationsTableName = connection.options.migrationsTableName || \"migrations\";\n this.migrationsTable = this.connection.driver.buildTableName(this.migrationsTableName, schema, database);\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Tries to execute a single migration given.\n */\n public async executeMigration(migration: Migration): Promise<Migration> {\n return this.withQueryRunner(async (queryRunner) => {\n await this.createMigrationsTableIfNotExist(queryRunner);\n await (migration.instance as any).up(queryRunner);\n await this.insertExecutedMigration(queryRunner, migration);\n\n return migration;\n });\n }\n\n /**\n * Returns an array of all migrations.\n */\n public async getAllMigrations(): Promise<Migration[]> {\n return Promise.resolve(this.getMigrations());\n }\n\n /**\n * Returns an array of all executed migrations.\n */\n public async getExecutedMigrations(): Promise<Migration[]> {\n return this.withQueryRunner(async queryRunner => {\n await this.createMigrationsTableIfNotExist(queryRunner);\n\n return await this.loadExecutedMigrations(queryRunner);\n });\n }\n\n /**\n * Returns an array of all pending migrations.\n */\n public async getPendingMigrations(): Promise<Migration[]> {\n const allMigrations = await this.getAllMigrations();\n const executedMigrations = await this.getExecutedMigrations();\n\n return allMigrations.filter(migration =>\n !executedMigrations.find(\n executedMigration =>\n executedMigration.name === migration.name\n )\n );\n }\n\n /**\n * Inserts an executed migration.\n */\n public insertMigration(migration: Migration): Promise<void> {\n return this.withQueryRunner(q => this.insertExecutedMigration(q, migration));\n }\n\n /**\n * Deletes an executed migration.\n */\n public deleteMigration(migration: Migration): Promise<void> {\n return this.withQueryRunner(q => this.deleteExecutedMigration(q, migration));\n }\n\n /**\n * Lists all migrations and whether they have been executed or not\n * returns true if there are unapplied migrations\n */\n async showMigrations(): Promise<boolean> {\n let hasUnappliedMigrations = false;\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner);\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(queryRunner);\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations();\n\n for (const migration of allMigrations) {\n const executedMigration = executedMigrations.find(executedMigration => executedMigration.name === migration.name);\n\n if (executedMigration) {\n this.connection.logger.logSchemaBuild(` [X] ${migration.name}`);\n } else {\n hasUnappliedMigrations = true;\n this.connection.logger.logSchemaBuild(` [ ] ${migration.name}`);\n }\n }\n\n // if query runner was created by us then release it\n if (!this.queryRunner) {\n await queryRunner.release();\n }\n\n return hasUnappliedMigrations;\n }\n\n /**\n * Executes all pending migrations. Pending migrations are migrations that are not yet executed,\n * thus not saved in the database.\n */\n async executePendingMigrations(): Promise<Migration[]> {\n\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner);\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(queryRunner);\n\n // get the time when last migration was executed\n let lastTimeExecutedMigration = this.getLatestTimestampMigration(executedMigrations);\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations();\n\n // variable to store all migrations we did successefuly\n const successMigrations: Migration[] = [];\n\n // find all migrations that needs to be executed\n const pendingMigrations = allMigrations.filter(migration => {\n // check if we already have executed migration\n const executedMigration = executedMigrations.find(executedMigration => executedMigration.name === migration.name);\n if (executedMigration)\n return false;\n\n // migration is new and not executed. now check if its timestamp is correct\n // if (lastTimeExecutedMigration && migration.timestamp < lastTimeExecutedMigration.timestamp)\n // throw new TypeORMError(`New migration found: ${migration.name}, however this migration's timestamp is not valid. Migration's timestamp should not be older then migrations already executed in the database.`);\n\n // every check is passed means that migration was not run yet and we need to run it\n return true;\n });\n\n // if no migrations are pending then nothing to do here\n if (!pendingMigrations.length) {\n this.connection.logger.logSchemaBuild(`No migrations are pending`);\n // if query runner was created by us then release it\n if (!this.queryRunner)\n await queryRunner.release();\n return [];\n }\n\n // log information about migration execution\n this.connection.logger.logSchemaBuild(`${executedMigrations.length} migrations are already loaded in the database.`);\n this.connection.logger.logSchemaBuild(`${allMigrations.length} migrations were found in the source code.`);\n if (lastTimeExecutedMigration)\n this.connection.logger.logSchemaBuild(`${lastTimeExecutedMigration.name} is the last executed migration. It was executed on ${new Date(lastTimeExecutedMigration.timestamp).toString()}.`);\n this.connection.logger.logSchemaBuild(`${pendingMigrations.length} migrations are new migrations that needs to be executed.`);\n\n // start transaction if its not started yet\n let transactionStartedByUs = false;\n if (this.transaction === \"all\" && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n // run all pending migrations in a sequence\n try {\n for (const migration of pendingMigrations) {\n if (this.transaction === \"each\" && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n await migration.instance!.up(queryRunner)\n .catch(error => { // informative log about migration failure\n this.connection.logger.logMigration(`Migration \"${migration.name}\" has been failed, error: ${error?.message}`);\n throw error;\n })\n .then(async () => { // now when migration is executed we need to insert record about it into the database\n await this.insertExecutedMigration(queryRunner, migration);\n // commit transaction if we started it\n if (this.transaction === \"each\" && transactionStartedByUs)\n await queryRunner.commitTransaction();\n })\n .then(() => { // informative log about migration success\n successMigrations.push(migration);\n this.connection.logger.logSchemaBuild(`Migration ${migration.name} has been executed successfully.`);\n });\n }\n\n // commit transaction if we started it\n if (this.transaction === \"all\" && transactionStartedByUs)\n await queryRunner.commitTransaction();\n\n } catch (err) { // rollback transaction if we started it\n if (transactionStartedByUs) {\n try { // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction();\n } catch (rollbackError) { }\n }\n\n throw err;\n\n } finally {\n\n // if query runner was created by us then release it\n if (!this.queryRunner)\n await queryRunner.release();\n }\n return successMigrations;\n\n }\n\n /**\n * Reverts last migration that were run.\n */\n async undoLastMigration(): Promise<void> {\n\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner);\n\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(queryRunner);\n\n // get the time when last migration was executed\n let lastTimeExecutedMigration = this.getLatestExecutedMigration(executedMigrations);\n\n // if no migrations found in the database then nothing to revert\n if (!lastTimeExecutedMigration) {\n this.connection.logger.logSchemaBuild(`No migrations was found in the database. Nothing to revert!`);\n return;\n }\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations();\n\n // find the instance of the migration we need to remove\n const migrationToRevert = allMigrations.find(migration => migration.name === lastTimeExecutedMigration!.name);\n\n // if no migrations found in the database then nothing to revert\n if (!migrationToRevert)\n throw new TypeORMError(`No migration ${lastTimeExecutedMigration.name} was found in the source code. Make sure you have this migration in your codebase and its included in the connection options.`);\n\n // log information about migration execution\n this.connection.logger.logSchemaBuild(`${executedMigrations.length} migrations are already loaded in the database.`);\n this.connection.logger.logSchemaBuild(`${lastTimeExecutedMigration.name} is the last executed migration. It was executed on ${new Date(lastTimeExecutedMigration.timestamp).toString()}.`);\n this.connection.logger.logSchemaBuild(`Now reverting it...`);\n\n // start transaction if its not started yet\n let transactionStartedByUs = false;\n if ((this.transaction !== \"none\") && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n try {\n await migrationToRevert.instance!.down(queryRunner);\n await this.deleteExecutedMigration(queryRunner, migrationToRevert);\n this.connection.logger.logSchemaBuild(`Migration ${migrationToRevert.name} has been reverted successfully.`);\n\n // commit transaction if we started it\n if (transactionStartedByUs)\n await queryRunner.commitTransaction();\n\n } catch (err) { // rollback transaction if we started it\n if (transactionStartedByUs) {\n try { // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction();\n } catch (rollbackError) { }\n }\n\n throw err;\n\n } finally {\n\n // if query runner was created by us then release it\n if (!this.queryRunner)\n await queryRunner.release();\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates table \"migrations\" that will store information about executed migrations.\n */\n protected async createMigrationsTableIfNotExist(queryRunner: QueryRunner): Promise<void> {\n // If driver is mongo no need to create\n if (this.connection.driver instanceof MongoDriver) {\n return;\n }\n const tableExist = await queryRunner.hasTable(this.migrationsTable); // todo: table name should be configurable\n if (!tableExist) {\n await queryRunner.createTable(new Table(\n {\n database: this.migrationsDatabase,\n schema: this.migrationsSchema,\n name: this.migrationsTable,\n columns: [\n {\n name: \"id\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationId}),\n isGenerated: true,\n generationStrategy: \"increment\",\n isPrimary: true,\n isNullable: false\n },\n {\n name: \"timestamp\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationTimestamp}),\n isPrimary: false,\n isNullable: false\n },\n {\n name: \"name\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationName}),\n isNullable: false\n },\n ]\n },\n ));\n }\n }\n\n /**\n * Loads all migrations that were executed and saved into the database (sorts by id).\n */\n protected async loadExecutedMigrations(queryRunner: QueryRunner): Promise<Migration[]> {\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n return await mongoRunner.databaseConnection\n .db(this.connection.driver.database!)\n .collection(this.migrationsTableName)\n .find<Migration>()\n .sort({\"_id\": -1})\n .toArray();\n } else {\n const migrationsRaw: ObjectLiteral[] = await this.connection.manager\n .createQueryBuilder(queryRunner)\n .select()\n .orderBy(this.connection.driver.escape(\"id\"), \"DESC\")\n .from(this.migrationsTable, this.migrationsTableName)\n .getRawMany();\n return migrationsRaw.map(migrationRaw => {\n return new Migration(parseInt(migrationRaw[\"id\"]), parseInt(migrationRaw[\"timestamp\"]), migrationRaw[\"name\"]);\n });\n }\n }\n\n /**\n * Gets all migrations that setup for this connection.\n */\n protected getMigrations(): Migration[] {\n const migrations = this.connection.migrations.map(migration => {\n const migrationClassName = migration.name || (migration.constructor as any).name;\n const migrationTimestamp = parseInt(migrationClassName.substr(-13), 10);\n if (!migrationTimestamp || isNaN(migrationTimestamp)) {\n throw new TypeORMError(`${migrationClassName} migration name is wrong. Migration class name should have a JavaScript timestamp appended.`);\n }\n\n return new Migration(undefined, migrationTimestamp, migrationClassName, migration);\n });\n\n this.checkForDuplicateMigrations(migrations);\n\n // sort them by timestamp\n return migrations.sort((a, b) => a.timestamp - b.timestamp);\n }\n\n protected checkForDuplicateMigrations(migrations: Migration[]) {\n const migrationNames = migrations.map(migration => migration.name);\n const duplicates = Array.from(new Set(migrationNames.filter((migrationName, index) => migrationNames.indexOf(migrationName) < index)));\n if (duplicates.length > 0) {\n throw Error(`Duplicate migrations: ${duplicates.join(\", \")}`);\n }\n }\n\n /**\n * Finds the latest migration (sorts by timestamp) in the given array of migrations.\n */\n protected getLatestTimestampMigration(migrations: Migration[]): Migration|undefined {\n const sortedMigrations = migrations.map(migration => migration).sort((a, b) => (a.timestamp - b.timestamp) * -1);\n return sortedMigrations.length > 0 ? sortedMigrations[0] : undefined;\n }\n\n /**\n * Finds the latest migration in the given array of migrations.\n * PRE: Migration array must be sorted by descending id.\n */\n protected getLatestExecutedMigration(sortedMigrations: Migration[]): Migration|undefined {\n return sortedMigrations.length > 0 ? sortedMigrations[0] : undefined;\n }\n\n /**\n * Inserts new executed migration's data into migrations table.\n */\n protected async insertExecutedMigration(queryRunner: QueryRunner, migration: Migration): Promise<void> {\n const values: ObjectLiteral = {};\n if (this.connection.driver instanceof SqlServerDriver) {\n values[\"timestamp\"] = new MssqlParameter(migration.timestamp, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationTimestamp }) as any);\n values[\"name\"] = new MssqlParameter(migration.name, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationName }) as any);\n } else {\n values[\"timestamp\"] = migration.timestamp;\n values[\"name\"] = migration.name;\n }\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n await mongoRunner.databaseConnection.db(this.connection.driver.database!).collection(this.migrationsTableName).insertOne(values);\n } else {\n const qb = queryRunner.manager.createQueryBuilder();\n await qb.insert()\n .into(this.migrationsTable)\n .values(values)\n .execute();\n }\n }\n\n /**\n * Delete previously executed migration's data from the migrations table.\n */\n protected async deleteExecutedMigration(queryRunner: QueryRunner, migration: Migration): Promise<void> {\n\n const conditions: ObjectLiteral = {};\n if (this.connection.driver instanceof SqlServerDriver) {\n conditions[\"timestamp\"] = new MssqlParameter(migration.timestamp, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationTimestamp }) as any);\n conditions[\"name\"] = new MssqlParameter(migration.name, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationName }) as any);\n } else {\n conditions[\"timestamp\"] = migration.timestamp;\n conditions[\"name\"] = migration.name;\n }\n\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n await mongoRunner.databaseConnection.db(this.connection.driver.database!).collection(this.migrationsTableName).deleteOne(conditions);\n } else {\n const qb = queryRunner.manager.createQueryBuilder();\n await qb.delete()\n .from(this.migrationsTable)\n .where(`${qb.escape(\"timestamp\")} = :timestamp`)\n .andWhere(`${qb.escape(\"name\")} = :name`)\n .setParameters(conditions)\n .execute();\n }\n\n }\n\n protected async withQueryRunner<T extends any>(callback: (queryRunner: QueryRunner) => T | Promise<T>) {\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n\n try {\n return callback(queryRunner);\n } finally {\n if (!this.queryRunner) {\n await queryRunner.release();\n }\n }\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../browser/src/migration/MigrationExecutor.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,+BAA+B,CAAC;AAEpD,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAGtC,OAAO,EAAC,eAAe,EAAC,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAC,cAAc,EAAC,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAC,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAC,WAAW,EAAC,MAAM,+BAA+B,CAA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E/H,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC;wBACpD,qBAAM,EAAE,CAAC,MAAM,EAAE;iCACZ,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC;iCAC1B,KAAK,CAAI,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAe,CAAC;iCAC/C,QAAQ,CAAI,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,aAAU,CAAC;iCACxC,aAAa,CAAC,UAAU,CAAC;iCACzB,OAAO,EAAE,EAAA;;wBALd,SAKc,CAAC;;;;;;KAGtB;IAEe,2CAAe,GAA/B,UAA+C,QAAsD;;;;;;wBAC3F,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC;;;;wBAGxE,sBAAO,QAAQ,CAAC,WAAW,CAAC,EAAC;;6BAEzB,CAAC,IAAI,CAAC,WAAW,EAAjB,wBAAiB;wBACjB,qBAAM,WAAW,CAAC,OAAO,EAAE,EAAA;;wBAA3B,SAA2B,CAAC;;;;;;;KAGvC;IACL,wBAAC;AAAD,CAnfA,AAmfC,IAAA","file":"MigrationExecutor.js","sourcesContent":["import {Table} from \"../schema-builder/table/Table\";\nimport {Connection} from \"../connection/Connection\";\nimport {Migration} from \"./Migration\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {SqlServerDriver} from \"../driver/sqlserver/SqlServerDriver\";\nimport {MssqlParameter} from \"../driver/sqlserver/MssqlParameter\";\nimport {RdbmsSchemaBuilder} from \"../schema-builder/RdbmsSchemaBuilder\";\nimport {MongoDriver} from \"../driver/mongodb/MongoDriver\";\nimport {MongoQueryRunner} from \"../driver/mongodb/MongoQueryRunner\";\nimport {TypeORMError} from \"../error\";\n\n/**\n * Executes migrations: runs pending and reverts previously executed migrations.\n */\nexport class MigrationExecutor {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Indicates how migrations should be run in transactions.\n * all: all migrations are run in a single transaction\n * none: all migrations are run without a transaction\n * each: each migration is run in a separate transaction\n */\n transaction: \"all\" | \"none\" | \"each\" = \"all\";\n\n // -------------------------------------------------------------------------\n // Private Properties\n // -------------------------------------------------------------------------\n\n private readonly migrationsDatabase?: string;\n private readonly migrationsSchema?: string;\n private readonly migrationsTable: string;\n private readonly migrationsTableName: string;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected connection: Connection,\n protected queryRunner?: QueryRunner) {\n\n const { schema } = this.connection.driver.options as any;\n const database = this.connection.driver.database;\n this.migrationsDatabase = database;\n this.migrationsSchema = schema;\n this.migrationsTableName = connection.options.migrationsTableName || \"migrations\";\n this.migrationsTable = this.connection.driver.buildTableName(this.migrationsTableName, schema, database);\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Tries to execute a single migration given.\n */\n public async executeMigration(migration: Migration): Promise<Migration> {\n return this.withQueryRunner(async (queryRunner) => {\n await this.createMigrationsTableIfNotExist(queryRunner);\n await (migration.instance as any).up(queryRunner);\n await this.insertExecutedMigration(queryRunner, migration);\n\n return migration;\n });\n }\n\n /**\n * Returns an array of all migrations.\n */\n public async getAllMigrations(): Promise<Migration[]> {\n return Promise.resolve(this.getMigrations());\n }\n\n /**\n * Returns an array of all executed migrations.\n */\n public async getExecutedMigrations(): Promise<Migration[]> {\n return this.withQueryRunner(async queryRunner => {\n await this.createMigrationsTableIfNotExist(queryRunner);\n\n return await this.loadExecutedMigrations(queryRunner);\n });\n }\n\n /**\n * Returns an array of all pending migrations.\n */\n public async getPendingMigrations(): Promise<Migration[]> {\n const allMigrations = await this.getAllMigrations();\n const executedMigrations = await this.getExecutedMigrations();\n\n return allMigrations.filter(migration =>\n !executedMigrations.find(\n executedMigration =>\n executedMigration.name === migration.name\n )\n );\n }\n\n /**\n * Inserts an executed migration.\n */\n public insertMigration(migration: Migration): Promise<void> {\n return this.withQueryRunner(q => this.insertExecutedMigration(q, migration));\n }\n\n /**\n * Deletes an executed migration.\n */\n public deleteMigration(migration: Migration): Promise<void> {\n return this.withQueryRunner(q => this.deleteExecutedMigration(q, migration));\n }\n\n /**\n * Lists all migrations and whether they have been executed or not\n * returns true if there are unapplied migrations\n */\n async showMigrations(): Promise<boolean> {\n let hasUnappliedMigrations = false;\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner);\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(queryRunner);\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations();\n\n for (const migration of allMigrations) {\n const executedMigration = executedMigrations.find(executedMigration => executedMigration.name === migration.name);\n\n if (executedMigration) {\n this.connection.logger.logSchemaBuild(` [X] ${migration.name}`);\n } else {\n hasUnappliedMigrations = true;\n this.connection.logger.logSchemaBuild(` [ ] ${migration.name}`);\n }\n }\n\n // if query runner was created by us then release it\n if (!this.queryRunner) {\n await queryRunner.release();\n }\n\n return hasUnappliedMigrations;\n }\n\n /**\n * Executes all pending migrations. Pending migrations are migrations that are not yet executed,\n * thus not saved in the database.\n */\n async executePendingMigrations(): Promise<Migration[]> {\n\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner);\n\n // create the typeorm_metadata table if necessary\n const schemaBuilder = this.connection.driver.createSchemaBuilder();\n\n if (schemaBuilder instanceof RdbmsSchemaBuilder) {\n await schemaBuilder.createMetadataTableIfNecessary(queryRunner);\n }\n\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(queryRunner);\n\n // get the time when last migration was executed\n let lastTimeExecutedMigration = this.getLatestTimestampMigration(executedMigrations);\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations();\n\n // variable to store all migrations we did successefuly\n const successMigrations: Migration[] = [];\n\n // find all migrations that needs to be executed\n const pendingMigrations = allMigrations.filter(migration => {\n // check if we already have executed migration\n const executedMigration = executedMigrations.find(executedMigration => executedMigration.name === migration.name);\n if (executedMigration)\n return false;\n\n // migration is new and not executed. now check if its timestamp is correct\n // if (lastTimeExecutedMigration && migration.timestamp < lastTimeExecutedMigration.timestamp)\n // throw new TypeORMError(`New migration found: ${migration.name}, however this migration's timestamp is not valid. Migration's timestamp should not be older then migrations already executed in the database.`);\n\n // every check is passed means that migration was not run yet and we need to run it\n return true;\n });\n\n // if no migrations are pending then nothing to do here\n if (!pendingMigrations.length) {\n this.connection.logger.logSchemaBuild(`No migrations are pending`);\n // if query runner was created by us then release it\n if (!this.queryRunner)\n await queryRunner.release();\n return [];\n }\n\n // log information about migration execution\n this.connection.logger.logSchemaBuild(`${executedMigrations.length} migrations are already loaded in the database.`);\n this.connection.logger.logSchemaBuild(`${allMigrations.length} migrations were found in the source code.`);\n if (lastTimeExecutedMigration)\n this.connection.logger.logSchemaBuild(`${lastTimeExecutedMigration.name} is the last executed migration. It was executed on ${new Date(lastTimeExecutedMigration.timestamp).toString()}.`);\n this.connection.logger.logSchemaBuild(`${pendingMigrations.length} migrations are new migrations that needs to be executed.`);\n\n // start transaction if its not started yet\n let transactionStartedByUs = false;\n if (this.transaction === \"all\" && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n // run all pending migrations in a sequence\n try {\n for (const migration of pendingMigrations) {\n if (this.transaction === \"each\" && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n await migration.instance!.up(queryRunner)\n .catch(error => { // informative log about migration failure\n this.connection.logger.logMigration(`Migration \"${migration.name}\" has been failed, error: ${error?.message}`);\n throw error;\n })\n .then(async () => { // now when migration is executed we need to insert record about it into the database\n await this.insertExecutedMigration(queryRunner, migration);\n // commit transaction if we started it\n if (this.transaction === \"each\" && transactionStartedByUs)\n await queryRunner.commitTransaction();\n })\n .then(() => { // informative log about migration success\n successMigrations.push(migration);\n this.connection.logger.logSchemaBuild(`Migration ${migration.name} has been executed successfully.`);\n });\n }\n\n // commit transaction if we started it\n if (this.transaction === \"all\" && transactionStartedByUs)\n await queryRunner.commitTransaction();\n\n } catch (err) { // rollback transaction if we started it\n if (transactionStartedByUs) {\n try { // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction();\n } catch (rollbackError) { }\n }\n\n throw err;\n\n } finally {\n\n // if query runner was created by us then release it\n if (!this.queryRunner)\n await queryRunner.release();\n }\n return successMigrations;\n\n }\n\n /**\n * Reverts last migration that were run.\n */\n async undoLastMigration(): Promise<void> {\n\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n\n // create migrations table if its not created yet\n await this.createMigrationsTableIfNotExist(queryRunner);\n\n // get all migrations that are executed and saved in the database\n const executedMigrations = await this.loadExecutedMigrations(queryRunner);\n\n // get the time when last migration was executed\n let lastTimeExecutedMigration = this.getLatestExecutedMigration(executedMigrations);\n\n // if no migrations found in the database then nothing to revert\n if (!lastTimeExecutedMigration) {\n this.connection.logger.logSchemaBuild(`No migrations was found in the database. Nothing to revert!`);\n return;\n }\n\n // get all user's migrations in the source code\n const allMigrations = this.getMigrations();\n\n // find the instance of the migration we need to remove\n const migrationToRevert = allMigrations.find(migration => migration.name === lastTimeExecutedMigration!.name);\n\n // if no migrations found in the database then nothing to revert\n if (!migrationToRevert)\n throw new TypeORMError(`No migration ${lastTimeExecutedMigration.name} was found in the source code. Make sure you have this migration in your codebase and its included in the connection options.`);\n\n // log information about migration execution\n this.connection.logger.logSchemaBuild(`${executedMigrations.length} migrations are already loaded in the database.`);\n this.connection.logger.logSchemaBuild(`${lastTimeExecutedMigration.name} is the last executed migration. It was executed on ${new Date(lastTimeExecutedMigration.timestamp).toString()}.`);\n this.connection.logger.logSchemaBuild(`Now reverting it...`);\n\n // start transaction if its not started yet\n let transactionStartedByUs = false;\n if ((this.transaction !== \"none\") && !queryRunner.isTransactionActive) {\n await queryRunner.startTransaction();\n transactionStartedByUs = true;\n }\n\n try {\n await migrationToRevert.instance!.down(queryRunner);\n await this.deleteExecutedMigration(queryRunner, migrationToRevert);\n this.connection.logger.logSchemaBuild(`Migration ${migrationToRevert.name} has been reverted successfully.`);\n\n // commit transaction if we started it\n if (transactionStartedByUs)\n await queryRunner.commitTransaction();\n\n } catch (err) { // rollback transaction if we started it\n if (transactionStartedByUs) {\n try { // we throw original error even if rollback thrown an error\n await queryRunner.rollbackTransaction();\n } catch (rollbackError) { }\n }\n\n throw err;\n\n } finally {\n\n // if query runner was created by us then release it\n if (!this.queryRunner)\n await queryRunner.release();\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates table \"migrations\" that will store information about executed migrations.\n */\n protected async createMigrationsTableIfNotExist(queryRunner: QueryRunner): Promise<void> {\n // If driver is mongo no need to create\n if (this.connection.driver instanceof MongoDriver) {\n return;\n }\n const tableExist = await queryRunner.hasTable(this.migrationsTable); // todo: table name should be configurable\n if (!tableExist) {\n await queryRunner.createTable(new Table(\n {\n database: this.migrationsDatabase,\n schema: this.migrationsSchema,\n name: this.migrationsTable,\n columns: [\n {\n name: \"id\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationId}),\n isGenerated: true,\n generationStrategy: \"increment\",\n isPrimary: true,\n isNullable: false\n },\n {\n name: \"timestamp\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationTimestamp}),\n isPrimary: false,\n isNullable: false\n },\n {\n name: \"name\",\n type: this.connection.driver.normalizeType({type: this.connection.driver.mappedDataTypes.migrationName}),\n isNullable: false\n },\n ]\n },\n ));\n }\n }\n\n /**\n * Loads all migrations that were executed and saved into the database (sorts by id).\n */\n protected async loadExecutedMigrations(queryRunner: QueryRunner): Promise<Migration[]> {\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n return await mongoRunner.databaseConnection\n .db(this.connection.driver.database!)\n .collection(this.migrationsTableName)\n .find<Migration>()\n .sort({\"_id\": -1})\n .toArray();\n } else {\n const migrationsRaw: ObjectLiteral[] = await this.connection.manager\n .createQueryBuilder(queryRunner)\n .select()\n .orderBy(this.connection.driver.escape(\"id\"), \"DESC\")\n .from(this.migrationsTable, this.migrationsTableName)\n .getRawMany();\n return migrationsRaw.map(migrationRaw => {\n return new Migration(parseInt(migrationRaw[\"id\"]), parseInt(migrationRaw[\"timestamp\"]), migrationRaw[\"name\"]);\n });\n }\n }\n\n /**\n * Gets all migrations that setup for this connection.\n */\n protected getMigrations(): Migration[] {\n const migrations = this.connection.migrations.map(migration => {\n const migrationClassName = migration.name || (migration.constructor as any).name;\n const migrationTimestamp = parseInt(migrationClassName.substr(-13), 10);\n if (!migrationTimestamp || isNaN(migrationTimestamp)) {\n throw new TypeORMError(`${migrationClassName} migration name is wrong. Migration class name should have a JavaScript timestamp appended.`);\n }\n\n return new Migration(undefined, migrationTimestamp, migrationClassName, migration);\n });\n\n this.checkForDuplicateMigrations(migrations);\n\n // sort them by timestamp\n return migrations.sort((a, b) => a.timestamp - b.timestamp);\n }\n\n protected checkForDuplicateMigrations(migrations: Migration[]) {\n const migrationNames = migrations.map(migration => migration.name);\n const duplicates = Array.from(new Set(migrationNames.filter((migrationName, index) => migrationNames.indexOf(migrationName) < index)));\n if (duplicates.length > 0) {\n throw Error(`Duplicate migrations: ${duplicates.join(\", \")}`);\n }\n }\n\n /**\n * Finds the latest migration (sorts by timestamp) in the given array of migrations.\n */\n protected getLatestTimestampMigration(migrations: Migration[]): Migration|undefined {\n const sortedMigrations = migrations.map(migration => migration).sort((a, b) => (a.timestamp - b.timestamp) * -1);\n return sortedMigrations.length > 0 ? sortedMigrations[0] : undefined;\n }\n\n /**\n * Finds the latest migration in the given array of migrations.\n * PRE: Migration array must be sorted by descending id.\n */\n protected getLatestExecutedMigration(sortedMigrations: Migration[]): Migration|undefined {\n return sortedMigrations.length > 0 ? sortedMigrations[0] : undefined;\n }\n\n /**\n * Inserts new executed migration's data into migrations table.\n */\n protected async insertExecutedMigration(queryRunner: QueryRunner, migration: Migration): Promise<void> {\n const values: ObjectLiteral = {};\n if (this.connection.driver instanceof SqlServerDriver) {\n values[\"timestamp\"] = new MssqlParameter(migration.timestamp, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationTimestamp }) as any);\n values[\"name\"] = new MssqlParameter(migration.name, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationName }) as any);\n } else {\n values[\"timestamp\"] = migration.timestamp;\n values[\"name\"] = migration.name;\n }\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n await mongoRunner.databaseConnection.db(this.connection.driver.database!).collection(this.migrationsTableName).insertOne(values);\n } else {\n const qb = queryRunner.manager.createQueryBuilder();\n await qb.insert()\n .into(this.migrationsTable)\n .values(values)\n .execute();\n }\n }\n\n /**\n * Delete previously executed migration's data from the migrations table.\n */\n protected async deleteExecutedMigration(queryRunner: QueryRunner, migration: Migration): Promise<void> {\n\n const conditions: ObjectLiteral = {};\n if (this.connection.driver instanceof SqlServerDriver) {\n conditions[\"timestamp\"] = new MssqlParameter(migration.timestamp, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationTimestamp }) as any);\n conditions[\"name\"] = new MssqlParameter(migration.name, this.connection.driver.normalizeType({ type: this.connection.driver.mappedDataTypes.migrationName }) as any);\n } else {\n conditions[\"timestamp\"] = migration.timestamp;\n conditions[\"name\"] = migration.name;\n }\n\n if (this.connection.driver instanceof MongoDriver) {\n const mongoRunner = queryRunner as MongoQueryRunner;\n await mongoRunner.databaseConnection.db(this.connection.driver.database!).collection(this.migrationsTableName).deleteOne(conditions);\n } else {\n const qb = queryRunner.manager.createQueryBuilder();\n await qb.delete()\n .from(this.migrationsTable)\n .where(`${qb.escape(\"timestamp\")} = :timestamp`)\n .andWhere(`${qb.escape(\"name\")} = :name`)\n .setParameters(conditions)\n .execute();\n }\n\n }\n\n protected async withQueryRunner<T extends any>(callback: (queryRunner: QueryRunner) => T | Promise<T>) {\n const queryRunner = this.queryRunner || this.connection.createQueryRunner();\n\n try {\n return callback(queryRunner);\n } finally {\n if (!this.queryRunner) {\n await queryRunner.release();\n }\n }\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -9,6 +9,7 @@ import { Broadcaster } from "../subscriber/Broadcaster";
|
|
|
9
9
|
import { ReplicationMode } from "../driver/types/ReplicationMode";
|
|
10
10
|
import { EntityMetadata } from "../metadata/EntityMetadata";
|
|
11
11
|
import { TableForeignKey } from "../schema-builder/table/TableForeignKey";
|
|
12
|
+
import { MetadataTableType } from "../driver/types/MetadataTableType";
|
|
12
13
|
export declare abstract class BaseQueryRunner {
|
|
13
14
|
/**
|
|
14
15
|
* Connection used by this query runner.
|
|
@@ -114,6 +115,7 @@ export declare abstract class BaseQueryRunner {
|
|
|
114
115
|
* Executes down sql queries.
|
|
115
116
|
*/
|
|
116
117
|
executeMemoryDownSql(): Promise<void>;
|
|
118
|
+
getReplicationMode(): ReplicationMode;
|
|
117
119
|
/**
|
|
118
120
|
* Gets view from previously loaded views, otherwise loads it from database.
|
|
119
121
|
*/
|
|
@@ -128,6 +130,27 @@ export declare abstract class BaseQueryRunner {
|
|
|
128
130
|
protected replaceCachedTable(table: Table, changedTable: Table): void;
|
|
129
131
|
protected getTablePath(target: EntityMetadata | Table | View | TableForeignKey | string): string;
|
|
130
132
|
protected getTypeormMetadataTableName(): string;
|
|
133
|
+
/**
|
|
134
|
+
* Generates SQL query to insert a record into "typeorm_metadata" table.
|
|
135
|
+
*/
|
|
136
|
+
protected insertTypeormMetadataSql({ database, schema, table, type, name, value }: {
|
|
137
|
+
database?: string;
|
|
138
|
+
schema?: string;
|
|
139
|
+
table?: string;
|
|
140
|
+
type: MetadataTableType;
|
|
141
|
+
name: string;
|
|
142
|
+
value?: string;
|
|
143
|
+
}): Query;
|
|
144
|
+
/**
|
|
145
|
+
* Generates SQL query to delete a record from "typeorm_metadata" table.
|
|
146
|
+
*/
|
|
147
|
+
protected deleteTypeormMetadataSql({ database, schema, table, type, name }: {
|
|
148
|
+
database?: string;
|
|
149
|
+
schema?: string;
|
|
150
|
+
table?: string;
|
|
151
|
+
type: MetadataTableType;
|
|
152
|
+
name: string;
|
|
153
|
+
}): Query;
|
|
131
154
|
/**
|
|
132
155
|
* Checks if at least one of column properties was changed.
|
|
133
156
|
* Does not checks column type, length and autoincrement, because these properties changes separately.
|
|
@@ -231,6 +231,9 @@ var BaseQueryRunner = /** @class */ (function () {
|
|
|
231
231
|
});
|
|
232
232
|
});
|
|
233
233
|
};
|
|
234
|
+
BaseQueryRunner.prototype.getReplicationMode = function () {
|
|
235
|
+
return this.mode;
|
|
236
|
+
};
|
|
234
237
|
// -------------------------------------------------------------------------
|
|
235
238
|
// Protected Methods
|
|
236
239
|
// -------------------------------------------------------------------------
|
|
@@ -346,6 +349,40 @@ var BaseQueryRunner = /** @class */ (function () {
|
|
|
346
349
|
var options = this.connection.driver.options;
|
|
347
350
|
return this.connection.driver.buildTableName("typeorm_metadata", options.schema, options.database);
|
|
348
351
|
};
|
|
352
|
+
/**
|
|
353
|
+
* Generates SQL query to insert a record into "typeorm_metadata" table.
|
|
354
|
+
*/
|
|
355
|
+
BaseQueryRunner.prototype.insertTypeormMetadataSql = function (_a) {
|
|
356
|
+
var database = _a.database, schema = _a.schema, table = _a.table, type = _a.type, name = _a.name, value = _a.value;
|
|
357
|
+
var _b = __read(this.connection.createQueryBuilder()
|
|
358
|
+
.insert()
|
|
359
|
+
.into(this.getTypeormMetadataTableName())
|
|
360
|
+
.values({ database: database, schema: schema, table: table, type: type, name: name, value: value })
|
|
361
|
+
.getQueryAndParameters(), 2), query = _b[0], parameters = _b[1];
|
|
362
|
+
return new Query(query, parameters);
|
|
363
|
+
};
|
|
364
|
+
/**
|
|
365
|
+
* Generates SQL query to delete a record from "typeorm_metadata" table.
|
|
366
|
+
*/
|
|
367
|
+
BaseQueryRunner.prototype.deleteTypeormMetadataSql = function (_a) {
|
|
368
|
+
var database = _a.database, schema = _a.schema, table = _a.table, type = _a.type, name = _a.name;
|
|
369
|
+
var qb = this.connection.createQueryBuilder();
|
|
370
|
+
var deleteQb = qb.delete()
|
|
371
|
+
.from(this.getTypeormMetadataTableName())
|
|
372
|
+
.where(qb.escape("type") + " = :type", { type: type })
|
|
373
|
+
.andWhere(qb.escape("name") + " = :name", { name: name });
|
|
374
|
+
if (database) {
|
|
375
|
+
deleteQb.andWhere(qb.escape("database") + " = :database", { database: database });
|
|
376
|
+
}
|
|
377
|
+
if (schema) {
|
|
378
|
+
deleteQb.andWhere(qb.escape("schema") + " = :schema", { schema: schema });
|
|
379
|
+
}
|
|
380
|
+
if (table) {
|
|
381
|
+
deleteQb.andWhere(qb.escape("table") + " = :table", { table: table });
|
|
382
|
+
}
|
|
383
|
+
var _b = __read(deleteQb.getQueryAndParameters(), 2), query = _b[0], parameters = _b[1];
|
|
384
|
+
return new Query(query, parameters);
|
|
385
|
+
};
|
|
349
386
|
/**
|
|
350
387
|
* Checks if at least one of column properties was changed.
|
|
351
388
|
* Does not checks column type, length and autoincrement, because these properties changes separately.
|