@elsikora/nestjs-crud-config 4.1.0-dev.1 → 5.0.0-dev.1
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/README.md +31 -24
- package/dist/{esm/external → external}/tslib/tslib.es6.js +0 -1
- package/dist/{esm/index.d.ts → index.d.ts} +2 -2
- package/dist/{esm/index.js → index.js} +0 -1
- package/dist/{esm/modules → modules}/config/config.module.d.ts +1 -1
- package/dist/{esm/modules → modules}/config/config.module.js +0 -1
- package/dist/{cjs/modules → modules}/config/config.service.d.ts +5 -5
- package/dist/{esm/modules → modules}/config/config.service.js +0 -1
- package/dist/{cjs/modules → modules}/config/data/controller.d.ts +4 -4
- package/dist/{esm/modules → modules}/config/data/controller.js +0 -1
- package/dist/{cjs/modules → modules}/config/data/entity/entity.d.ts +3 -3
- package/dist/{esm/modules → modules}/config/data/entity/entity.js +0 -1
- package/dist/modules/config/data/entity/index.d.ts +1 -0
- package/dist/modules/config/data/index.d.ts +3 -0
- package/dist/modules/config/data/interface/index.d.ts +1 -0
- package/dist/{cjs/modules → modules}/config/data/interface/interface.d.ts +1 -1
- package/dist/modules/config/index.d.ts +11 -0
- package/dist/modules/config/interface/index.d.ts +4 -0
- package/dist/{cjs/modules → modules}/config/migration/entity/entity.d.ts +2 -2
- package/dist/{esm/modules → modules}/config/migration/entity/entity.js +0 -1
- package/dist/modules/config/migration/entity/index.d.ts +1 -0
- package/dist/modules/config/migration/enum/index.d.ts +1 -0
- package/dist/{esm/modules → modules}/config/migration/enum/status.js +0 -1
- package/dist/modules/config/migration/index.d.ts +5 -0
- package/dist/{cjs/modules → modules}/config/migration/interface/index.d.ts +3 -3
- package/dist/{esm/modules → modules}/config/migration/interface/interface.d.ts +1 -1
- package/dist/{cjs/modules → modules}/config/migration/interface/migration-definition.interface.d.ts +1 -1
- package/dist/{esm/modules → modules}/config/migration/interface/migration-options.interface.d.ts +1 -1
- package/dist/{esm/modules → modules}/config/migration/migration-runner.service.d.ts +2 -2
- package/dist/{esm/modules → modules}/config/migration/migration-runner.service.js +0 -1
- package/dist/{esm/modules → modules}/config/migration/migration.service.d.ts +3 -3
- package/dist/{esm/modules → modules}/config/migration/migration.service.js +2 -6
- package/dist/{cjs/modules → modules}/config/section/controller.d.ts +4 -4
- package/dist/{esm/modules → modules}/config/section/controller.js +0 -1
- package/dist/{esm/modules → modules}/config/section/entity/entity.d.ts +2 -2
- package/dist/{esm/modules → modules}/config/section/entity/entity.js +0 -1
- package/dist/modules/config/section/entity/index.d.ts +1 -0
- package/dist/modules/config/section/index.d.ts +2 -0
- package/dist/modules/config/section/interface/index.d.ts +1 -0
- package/dist/modules/config/type/index.d.ts +2 -0
- package/dist/{cjs/modules → modules}/config/type/type.d.ts +1 -1
- package/dist/modules/index.d.ts +1 -0
- package/dist/{esm/shared → shared}/constant/api-property.constant.js +0 -1
- package/dist/{esm/shared → shared}/constant/config/data.constant.js +0 -1
- package/dist/shared/constant/config/index.d.ts +3 -0
- package/dist/{esm/shared → shared}/constant/config/migration.constant.js +0 -1
- package/dist/{esm/shared → shared}/constant/config/section.constant.js +0 -1
- package/dist/{esm/shared → shared}/constant/crypto.constant.js +0 -1
- package/dist/shared/constant/index.d.ts +4 -0
- package/dist/{esm/shared → shared}/constant/token.constant.js +0 -1
- package/dist/{esm/shared → shared}/enum/environment.enum.js +0 -1
- package/dist/shared/enum/index.d.ts +6 -0
- package/dist/{esm/shared → shared}/enum/instance-name.enum.js +0 -1
- package/dist/{esm/shared → shared}/enum/service.enum.js +0 -1
- package/dist/shared/index.d.ts +5 -0
- package/dist/{cjs/shared → shared}/interface/config/async-module-properties.interface.d.ts +4 -4
- package/dist/{cjs/shared → shared}/interface/config/controller-options.interface.d.ts +2 -2
- package/dist/{cjs/shared → shared}/interface/config/entity/index.d.ts +3 -3
- package/dist/{esm/shared → shared}/interface/config/entity/options.interface.d.ts +1 -1
- package/dist/{cjs/shared → shared}/interface/config/index.d.ts +8 -8
- package/dist/{esm/shared → shared}/interface/config/options.interface.d.ts +5 -5
- package/dist/{cjs/shared → shared}/interface/config/properties-factory.interface.d.ts +1 -1
- package/dist/{esm/shared → shared}/interface/config/static-options.interface.d.ts +2 -2
- package/dist/shared/interface/index.d.ts +2 -0
- package/dist/{cjs/shared → shared}/interface/utility/create-dynamic-entity/index.d.ts +2 -2
- package/dist/{esm/shared → shared}/interface/utility/create-dynamic-entity/options.interface.d.ts +1 -1
- package/dist/shared/interface/utility/index.d.ts +1 -0
- package/dist/shared/type/index.d.ts +1 -0
- package/dist/{cjs/shared → shared}/utility/create-dynamic/entity.utility.d.ts +2 -2
- package/dist/{esm/shared → shared}/utility/create-dynamic/entity.utility.js +0 -1
- package/dist/shared/utility/create-dynamic/index.d.ts +2 -0
- package/dist/{cjs/shared → shared}/utility/create-dynamic/service.utility.d.ts +1 -1
- package/dist/{esm/shared → shared}/utility/create-dynamic/service.utility.js +0 -1
- package/dist/{cjs/shared → shared}/utility/crypto.utility.d.ts +1 -1
- package/dist/{esm/shared → shared}/utility/crypto.utility.js +0 -1
- package/dist/shared/utility/index.d.ts +4 -0
- package/dist/shared/utility/logger.utility.d.ts +37 -0
- package/dist/{esm/shared → shared}/utility/logger.utility.js +26 -6
- package/package.json +72 -65
- package/dist/cjs/external/tslib/tslib.es6.js +0 -43
- package/dist/cjs/external/tslib/tslib.es6.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -11
- package/dist/cjs/index.js +0 -81
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/modules/config/config.module.d.ts +0 -33
- package/dist/cjs/modules/config/config.module.js +0 -321
- package/dist/cjs/modules/config/config.module.js.map +0 -1
- package/dist/cjs/modules/config/config.service.js +0 -315
- package/dist/cjs/modules/config/config.service.js.map +0 -1
- package/dist/cjs/modules/config/data/controller.js +0 -124
- package/dist/cjs/modules/config/data/controller.js.map +0 -1
- package/dist/cjs/modules/config/data/entity/entity.js +0 -161
- package/dist/cjs/modules/config/data/entity/entity.js.map +0 -1
- package/dist/cjs/modules/config/data/entity/index.d.ts +0 -1
- package/dist/cjs/modules/config/data/index.d.ts +0 -3
- package/dist/cjs/modules/config/data/interface/index.d.ts +0 -1
- package/dist/cjs/modules/config/index.d.ts +0 -11
- package/dist/cjs/modules/config/interface/index.d.ts +0 -4
- package/dist/cjs/modules/config/migration/entity/entity.js +0 -141
- package/dist/cjs/modules/config/migration/entity/entity.js.map +0 -1
- package/dist/cjs/modules/config/migration/entity/index.d.ts +0 -1
- package/dist/cjs/modules/config/migration/enum/index.d.ts +0 -1
- package/dist/cjs/modules/config/migration/enum/status.js +0 -11
- package/dist/cjs/modules/config/migration/enum/status.js.map +0 -1
- package/dist/cjs/modules/config/migration/index.d.ts +0 -5
- package/dist/cjs/modules/config/migration/interface/interface.d.ts +0 -12
- package/dist/cjs/modules/config/migration/interface/migration-options.interface.d.ts +0 -39
- package/dist/cjs/modules/config/migration/migration-runner.service.d.ts +0 -26
- package/dist/cjs/modules/config/migration/migration-runner.service.js +0 -93
- package/dist/cjs/modules/config/migration/migration-runner.service.js.map +0 -1
- package/dist/cjs/modules/config/migration/migration.service.d.ts +0 -79
- package/dist/cjs/modules/config/migration/migration.service.js +0 -377
- package/dist/cjs/modules/config/migration/migration.service.js.map +0 -1
- package/dist/cjs/modules/config/section/controller.js +0 -86
- package/dist/cjs/modules/config/section/controller.js.map +0 -1
- package/dist/cjs/modules/config/section/entity/entity.d.ts +0 -18
- package/dist/cjs/modules/config/section/entity/entity.js +0 -99
- package/dist/cjs/modules/config/section/entity/entity.js.map +0 -1
- package/dist/cjs/modules/config/section/entity/index.d.ts +0 -1
- package/dist/cjs/modules/config/section/index.d.ts +0 -2
- package/dist/cjs/modules/config/section/interface/index.d.ts +0 -1
- package/dist/cjs/modules/config/type/index.d.ts +0 -2
- package/dist/cjs/modules/index.d.ts +0 -1
- package/dist/cjs/package.json +0 -8
- package/dist/cjs/shared/constant/api-property.constant.js +0 -11
- package/dist/cjs/shared/constant/api-property.constant.js.map +0 -1
- package/dist/cjs/shared/constant/config/data.constant.js +0 -17
- package/dist/cjs/shared/constant/config/data.constant.js.map +0 -1
- package/dist/cjs/shared/constant/config/index.d.ts +0 -3
- package/dist/cjs/shared/constant/config/migration.constant.js +0 -15
- package/dist/cjs/shared/constant/config/migration.constant.js.map +0 -1
- package/dist/cjs/shared/constant/config/section.constant.js +0 -13
- package/dist/cjs/shared/constant/config/section.constant.js.map +0 -1
- package/dist/cjs/shared/constant/crypto.constant.js +0 -17
- package/dist/cjs/shared/constant/crypto.constant.js.map +0 -1
- package/dist/cjs/shared/constant/index.d.ts +0 -4
- package/dist/cjs/shared/constant/token.constant.js +0 -24
- package/dist/cjs/shared/constant/token.constant.js.map +0 -1
- package/dist/cjs/shared/enum/environment.enum.js +0 -20
- package/dist/cjs/shared/enum/environment.enum.js.map +0 -1
- package/dist/cjs/shared/enum/index.d.ts +0 -6
- package/dist/cjs/shared/enum/instance-name.enum.js +0 -11
- package/dist/cjs/shared/enum/instance-name.enum.js.map +0 -1
- package/dist/cjs/shared/enum/service.enum.js +0 -224
- package/dist/cjs/shared/enum/service.enum.js.map +0 -1
- package/dist/cjs/shared/index.d.ts +0 -5
- package/dist/cjs/shared/interface/config/entity/options.interface.d.ts +0 -25
- package/dist/cjs/shared/interface/config/options.interface.d.ts +0 -39
- package/dist/cjs/shared/interface/config/static-options.interface.d.ts +0 -45
- package/dist/cjs/shared/interface/index.d.ts +0 -2
- package/dist/cjs/shared/interface/utility/create-dynamic-entity/options.interface.d.ts +0 -15
- package/dist/cjs/shared/interface/utility/index.d.ts +0 -1
- package/dist/cjs/shared/type/index.d.ts +0 -1
- package/dist/cjs/shared/utility/create-dynamic/entity.utility.js +0 -68
- package/dist/cjs/shared/utility/create-dynamic/entity.utility.js.map +0 -1
- package/dist/cjs/shared/utility/create-dynamic/index.d.ts +0 -2
- package/dist/cjs/shared/utility/create-dynamic/service.utility.js +0 -35
- package/dist/cjs/shared/utility/create-dynamic/service.utility.js.map +0 -1
- package/dist/cjs/shared/utility/crypto.utility.js +0 -133
- package/dist/cjs/shared/utility/crypto.utility.js.map +0 -1
- package/dist/cjs/shared/utility/index.d.ts +0 -4
- package/dist/cjs/shared/utility/logger.utility.d.ts +0 -21
- package/dist/cjs/shared/utility/logger.utility.js +0 -68
- package/dist/cjs/shared/utility/logger.utility.js.map +0 -1
- package/dist/esm/external/tslib/tslib.es6.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/modules/config/config.module.js.map +0 -1
- package/dist/esm/modules/config/config.service.d.ts +0 -56
- package/dist/esm/modules/config/config.service.js.map +0 -1
- package/dist/esm/modules/config/data/controller.d.ts +0 -11
- package/dist/esm/modules/config/data/controller.js.map +0 -1
- package/dist/esm/modules/config/data/entity/entity.d.ts +0 -25
- package/dist/esm/modules/config/data/entity/entity.js.map +0 -1
- package/dist/esm/modules/config/data/entity/index.d.ts +0 -1
- package/dist/esm/modules/config/data/index.d.ts +0 -3
- package/dist/esm/modules/config/data/interface/index.d.ts +0 -1
- package/dist/esm/modules/config/data/interface/interface.d.ts +0 -13
- package/dist/esm/modules/config/index.d.ts +0 -11
- package/dist/esm/modules/config/interface/delete-options.interface.d.ts +0 -24
- package/dist/esm/modules/config/interface/get-list-options.interface.d.ts +0 -24
- package/dist/esm/modules/config/interface/get-options.interface.d.ts +0 -32
- package/dist/esm/modules/config/interface/index.d.ts +0 -4
- package/dist/esm/modules/config/interface/set-options.interface.d.ts +0 -36
- package/dist/esm/modules/config/migration/entity/entity.d.ts +0 -16
- package/dist/esm/modules/config/migration/entity/entity.js.map +0 -1
- package/dist/esm/modules/config/migration/entity/index.d.ts +0 -1
- package/dist/esm/modules/config/migration/enum/index.d.ts +0 -1
- package/dist/esm/modules/config/migration/enum/status.d.ts +0 -7
- package/dist/esm/modules/config/migration/enum/status.js.map +0 -1
- package/dist/esm/modules/config/migration/index.d.ts +0 -5
- package/dist/esm/modules/config/migration/interface/index.d.ts +0 -3
- package/dist/esm/modules/config/migration/interface/migration-definition.interface.d.ts +0 -31
- package/dist/esm/modules/config/migration/migration-runner.service.js.map +0 -1
- package/dist/esm/modules/config/migration/migration.service.js.map +0 -1
- package/dist/esm/modules/config/section/controller.d.ts +0 -11
- package/dist/esm/modules/config/section/controller.js.map +0 -1
- package/dist/esm/modules/config/section/entity/entity.js.map +0 -1
- package/dist/esm/modules/config/section/entity/index.d.ts +0 -1
- package/dist/esm/modules/config/section/index.d.ts +0 -2
- package/dist/esm/modules/config/section/interface/index.d.ts +0 -1
- package/dist/esm/modules/config/section/interface/interface.d.ts +0 -8
- package/dist/esm/modules/config/type/index.d.ts +0 -2
- package/dist/esm/modules/config/type/item.type.d.ts +0 -1
- package/dist/esm/modules/config/type/type.d.ts +0 -2
- package/dist/esm/modules/index.d.ts +0 -1
- package/dist/esm/package.json +0 -8
- package/dist/esm/shared/constant/api-property.constant.d.ts +0 -4
- package/dist/esm/shared/constant/api-property.constant.js.map +0 -1
- package/dist/esm/shared/constant/config/data.constant.d.ts +0 -7
- package/dist/esm/shared/constant/config/data.constant.js.map +0 -1
- package/dist/esm/shared/constant/config/index.d.ts +0 -3
- package/dist/esm/shared/constant/config/migration.constant.d.ts +0 -6
- package/dist/esm/shared/constant/config/migration.constant.js.map +0 -1
- package/dist/esm/shared/constant/config/section.constant.d.ts +0 -5
- package/dist/esm/shared/constant/config/section.constant.js.map +0 -1
- package/dist/esm/shared/constant/crypto.constant.d.ts +0 -7
- package/dist/esm/shared/constant/crypto.constant.js.map +0 -1
- package/dist/esm/shared/constant/index.d.ts +0 -4
- package/dist/esm/shared/constant/token.constant.d.ts +0 -10
- package/dist/esm/shared/constant/token.constant.js.map +0 -1
- package/dist/esm/shared/enum/environment.enum.d.ts +0 -16
- package/dist/esm/shared/enum/environment.enum.js.map +0 -1
- package/dist/esm/shared/enum/index.d.ts +0 -6
- package/dist/esm/shared/enum/instance-name.enum.d.ts +0 -7
- package/dist/esm/shared/enum/instance-name.enum.js.map +0 -1
- package/dist/esm/shared/enum/service.enum.d.ts +0 -220
- package/dist/esm/shared/enum/service.enum.js.map +0 -1
- package/dist/esm/shared/index.d.ts +0 -5
- package/dist/esm/shared/interface/config/async-module-properties.interface.d.ts +0 -47
- package/dist/esm/shared/interface/config/cache-options.interface.d.ts +0 -18
- package/dist/esm/shared/interface/config/controller-options.interface.d.ts +0 -32
- package/dist/esm/shared/interface/config/encryption-options.interface.d.ts +0 -19
- package/dist/esm/shared/interface/config/entity/data-options.interface.d.ts +0 -25
- package/dist/esm/shared/interface/config/entity/index.d.ts +0 -3
- package/dist/esm/shared/interface/config/entity/section-options.interface.d.ts +0 -17
- package/dist/esm/shared/interface/config/index.d.ts +0 -8
- package/dist/esm/shared/interface/config/properties-factory.interface.d.ts +0 -11
- package/dist/esm/shared/interface/index.d.ts +0 -2
- package/dist/esm/shared/interface/utility/create-dynamic-entity/index.d.ts +0 -2
- package/dist/esm/shared/interface/utility/create-dynamic-entity/relation-options.interface.d.ts +0 -9
- package/dist/esm/shared/interface/utility/index.d.ts +0 -1
- package/dist/esm/shared/type/dynamic-entity.type.d.ts +0 -2
- package/dist/esm/shared/type/index.d.ts +0 -1
- package/dist/esm/shared/utility/create-dynamic/entity.utility.d.ts +0 -11
- package/dist/esm/shared/utility/create-dynamic/entity.utility.js.map +0 -1
- package/dist/esm/shared/utility/create-dynamic/index.d.ts +0 -2
- package/dist/esm/shared/utility/create-dynamic/service.utility.d.ts +0 -10
- package/dist/esm/shared/utility/create-dynamic/service.utility.js.map +0 -1
- package/dist/esm/shared/utility/crypto.utility.d.ts +0 -37
- package/dist/esm/shared/utility/crypto.utility.js.map +0 -1
- package/dist/esm/shared/utility/index.d.ts +0 -4
- package/dist/esm/shared/utility/logger.utility.d.ts +0 -21
- package/dist/esm/shared/utility/logger.utility.js.map +0 -1
- /package/dist/{cjs/modules → modules}/config/interface/delete-options.interface.d.ts +0 -0
- /package/dist/{cjs/modules → modules}/config/interface/get-list-options.interface.d.ts +0 -0
- /package/dist/{cjs/modules → modules}/config/interface/get-options.interface.d.ts +0 -0
- /package/dist/{cjs/modules → modules}/config/interface/set-options.interface.d.ts +0 -0
- /package/dist/{cjs/modules → modules}/config/migration/enum/status.d.ts +0 -0
- /package/dist/{cjs/modules → modules}/config/section/interface/interface.d.ts +0 -0
- /package/dist/{cjs/modules → modules}/config/type/item.type.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/constant/api-property.constant.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/constant/config/data.constant.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/constant/config/migration.constant.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/constant/config/section.constant.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/constant/crypto.constant.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/constant/token.constant.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/enum/environment.enum.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/enum/instance-name.enum.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/enum/service.enum.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/interface/config/cache-options.interface.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/interface/config/encryption-options.interface.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/interface/config/entity/data-options.interface.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/interface/config/entity/section-options.interface.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/interface/utility/create-dynamic-entity/relation-options.interface.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/type/dynamic-entity.type.d.ts +0 -0
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var tslib_es6 = require('../../../external/tslib/tslib.es6.js');
|
|
4
|
-
var common = require('@nestjs/common');
|
|
5
|
-
var migration_constant = require('../../../shared/constant/config/migration.constant.js');
|
|
6
|
-
var token_constant = require('../../../shared/constant/token.constant.js');
|
|
7
|
-
require('typeorm');
|
|
8
|
-
require('@elsikora/nestjs-crud-automator');
|
|
9
|
-
require('@nestjs/typeorm');
|
|
10
|
-
require('../../../shared/utility/crypto.utility.js');
|
|
11
|
-
var logger_utility = require('../../../shared/utility/logger.utility.js');
|
|
12
|
-
var status = require('./enum/status.js');
|
|
13
|
-
var migration_service = require('./migration.service.js');
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Service that runs migrations on application startup
|
|
17
|
-
* @see {@link https://elsikora.com/docs/nestjs-crud-config/migration-system | Migration System}
|
|
18
|
-
* @see {@link https://elsikora.com/docs/nestjs-crud-config/api-reference/classes/config-migration-runner-service | API Reference - ConfigMigrationRunnerService}
|
|
19
|
-
*/
|
|
20
|
-
exports.ConfigMigrationRunnerService = class ConfigMigrationRunnerService {
|
|
21
|
-
migrationService;
|
|
22
|
-
options;
|
|
23
|
-
LOGGER = logger_utility.LoggerUtility.getLogger("ConfigMigrationRunnerService");
|
|
24
|
-
constructor(migrationService, options) {
|
|
25
|
-
this.migrationService = migrationService;
|
|
26
|
-
this.options = options;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Called when the application is fully bootstrapped
|
|
30
|
-
* Runs migrations if enabled and configured to run on startup
|
|
31
|
-
*/
|
|
32
|
-
async onApplicationBootstrap() {
|
|
33
|
-
const migrationOptions = this.options.migrationOptions;
|
|
34
|
-
if (!migrationOptions?.isEnabled) {
|
|
35
|
-
this.LOGGER.verbose("Migrations are disabled");
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
if (!migrationOptions.shouldRunOnStartup) {
|
|
39
|
-
this.LOGGER.verbose("Migrations configured to not run on startup");
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if (!migrationOptions.migrations || migrationOptions.migrations.length === 0) {
|
|
43
|
-
this.LOGGER.verbose("No migrations configured");
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
try {
|
|
47
|
-
this.LOGGER.verbose("Starting migration runner");
|
|
48
|
-
// Check for failed and stuck migrations from previous runs
|
|
49
|
-
const allMigrations = await this.migrationService.getExecutedMigrations();
|
|
50
|
-
const failedMigrations = allMigrations.filter((m) => m.status === status.EConfigMigrationStatus.FAILED);
|
|
51
|
-
if (failedMigrations.length > 0) {
|
|
52
|
-
this.LOGGER.warn(`Found ${failedMigrations.length} failed migration(s) from previous runs: ${failedMigrations.map((m) => m.name).join(", ")}`);
|
|
53
|
-
this.LOGGER.warn("Consider reviewing and cleaning up failed migrations before proceeding");
|
|
54
|
-
}
|
|
55
|
-
// Clean up stuck migrations with configured timeout
|
|
56
|
-
const timeoutMinutes = migrationOptions.stuckMigrationTimeoutMinutes ??
|
|
57
|
-
migration_constant.CONFIG_MIGRATION_CONSTANT.DEFAULT_STUCK_MIGRATION_TIMEOUT_MINUTES;
|
|
58
|
-
await this.migrationService.cleanupStuckMigrations(timeoutMinutes);
|
|
59
|
-
await this.migrationService.executeMigrations(migrationOptions.migrations, migrationOptions.useTransaction ?? true);
|
|
60
|
-
this.LOGGER.verbose("Migration runner completed successfully");
|
|
61
|
-
}
|
|
62
|
-
catch (error) {
|
|
63
|
-
this.LOGGER.error("Migration runner failed:", error);
|
|
64
|
-
throw error;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Manually run migrations, optionally participating in an existing Automator owner
|
|
69
|
-
* @param {EntityManager} [ownerManager] - Existing active owner manager for the configured DataSource
|
|
70
|
-
* @returns {Promise<void>} Promise that resolves when migrations are complete
|
|
71
|
-
*/
|
|
72
|
-
async runMigrations(ownerManager) {
|
|
73
|
-
const migrationOptions = this.options.migrationOptions;
|
|
74
|
-
if (!migrationOptions?.isEnabled) {
|
|
75
|
-
throw new Error("Migrations are not enabled");
|
|
76
|
-
}
|
|
77
|
-
if (!migrationOptions.migrations || migrationOptions.migrations.length === 0) {
|
|
78
|
-
throw new Error("No migrations configured");
|
|
79
|
-
}
|
|
80
|
-
if (ownerManager === undefined) {
|
|
81
|
-
await this.migrationService.executeMigrations(migrationOptions.migrations, migrationOptions.useTransaction ?? true);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
await this.migrationService.executeMigrations(migrationOptions.migrations, migrationOptions.useTransaction ?? true, ownerManager);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
exports.ConfigMigrationRunnerService = tslib_es6.__decorate([
|
|
89
|
-
common.Injectable(),
|
|
90
|
-
tslib_es6.__param(1, common.Inject(token_constant.TOKEN_CONSTANT.CONFIG_OPTIONS)),
|
|
91
|
-
tslib_es6.__metadata("design:paramtypes", [migration_service.ConfigMigrationService, Object])
|
|
92
|
-
], exports.ConfigMigrationRunnerService);
|
|
93
|
-
//# sourceMappingURL=migration-runner.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migration-runner.service.js","sources":["../../../../../../src/modules/config/migration/migration-runner.service.ts"],"sourcesContent":[null],"names":["ConfigMigrationRunnerService","LoggerUtility","EConfigMigrationStatus","CONFIG_MIGRATION_CONSTANT","__decorate","Injectable","__param","Inject","TOKEN_CONSTANT","ConfigMigrationService"],"mappings":";;;;;;;;;;;;;;AAaA;;;;AAIG;AAEUA,oCAA4B,GAAlC,MAAM,4BAA4B,CAAA;AAItB,IAAA,gBAAA;AAEA,IAAA,OAAA;AALD,IAAA,MAAM,GAAkBC,4BAAa,CAAC,SAAS,CAAC,8BAA8B,CAAC;IAEhG,WAAA,CACkB,gBAAwC,EAExC,OAAuB,EAAA;QAFvB,IAAA,CAAA,gBAAgB,GAAhB,gBAAgB;QAEhB,IAAA,CAAA,OAAO,GAAP,OAAO;IACtB;AAEH;;;AAGG;AACH,IAAA,MAAM,sBAAsB,GAAA;AAC3B,QAAA,MAAM,gBAAgB,GAAwC,IAAI,CAAC,OAAO,CAAC,gBAAgB;AAE3F,QAAA,IAAI,CAAC,gBAAgB,EAAE,SAAS,EAAE;AACjC,YAAA,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,yBAAyB,CAAC;YAE9C;QACD;AAEA,QAAA,IAAI,CAAC,gBAAgB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CAAyC,CAAC;QAC/D;QAAE,OAAO,KAAK,EAAE;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC;AAEpD,YAAA,MAAM,KAAK;QACZ;IACD;AAEA;;;;AAIG;IACH,MAAM,aAAa,CAAC,YAA4B,EAAA;AAC/C,QAAA,MAAM,gBAAgB,GAAwC,IAAI,CAAC,OAAO,CAAC,gBAAgB;AAE3F,QAAA,IAAI,CAAC,gBAAgB,EAAE,SAAS,EAAE;AACjC,YAAA,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC;QAC9C;AAEA,QAAA,IAAI,CAAC,gBAAgB,CAAC,UAAU,IAAI,gBAAgB,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;AAC7E,YAAA,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC;QAC5C;AAEA,QAAA,IAAI,YAAY,KAAK,SAAS,EAAE;AAC/B,YAAA,MAAM,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAC5C,gBAAgB,CAAC,UAAU,EAC3B,gBAAgB,CAAC,cAAc,IAAI,IAAI,CACvC;QACF;aAAO;AACN,YAAA,MAAM,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAC5C,gBAAgB,CAAC,UAAU,EAC3B,gBAAgB,CAAC,cAAc,IAAI,IAAI,EACvC,YAAY,CACZ;QACF;IACD;;AAnGYH,oCAA4B,GAAAI,oBAAA,CAAA;AADxC,IAAAC,iBAAU,EAAE;AAMV,IAAAC,iBAAA,CAAA,CAAA,EAAAC,aAAM,CAACC,6BAAc,CAAC,cAAc,CAAC,CAAA;+CADHC,wCAAsB,EAAA,MAAA,CAAA;AAJ9C,CAAA,EAAAT,oCAA4B,CAoGxC"}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { ApiServiceBase } from '@elsikora/nestjs-crud-automator';
|
|
2
|
-
import { IConfigOptions } from '../../../shared/interface/config';
|
|
3
|
-
import { IConfigMigration, IConfigMigrationDefinition } from './interface';
|
|
4
|
-
import { CrudConfigService } from '../config.service';
|
|
5
|
-
import { OnModuleInit } from '@nestjs/common';
|
|
6
|
-
import { DataSource, EntityManager } from 'typeorm';
|
|
7
|
-
/**
|
|
8
|
-
* Service responsible for coordinating and tracking execution of migrations.
|
|
9
|
-
* @see {@link https://elsikora.com/docs/nestjs-crud-config/migration-system | Migration System}
|
|
10
|
-
* @see {@link https://elsikora.com/docs/nestjs-crud-config/api-reference/classes/config-migration-service | API Reference - ConfigMigrationService}
|
|
11
|
-
*/
|
|
12
|
-
export declare class ConfigMigrationService implements OnModuleInit {
|
|
13
|
-
private readonly dataSource;
|
|
14
|
-
private readonly options;
|
|
15
|
-
private readonly configService;
|
|
16
|
-
private readonly LOGGER;
|
|
17
|
-
private readonly MIGRATION_SERVICE;
|
|
18
|
-
constructor(dataSource: DataSource, options: IConfigOptions, configService: CrudConfigService, migrationService: ApiServiceBase<IConfigMigration>);
|
|
19
|
-
/**
|
|
20
|
-
* Cleans up failed migrations
|
|
21
|
-
* @param {string} [migrationName] - Optional migration name to clean up
|
|
22
|
-
* @returns {Promise<void>} Promise that resolves when cleanup is complete
|
|
23
|
-
*/
|
|
24
|
-
cleanupFailedMigrations(migrationName?: string): Promise<void>;
|
|
25
|
-
/**
|
|
26
|
-
* Cleans up stuck migrations (running for too long)
|
|
27
|
-
* @param {number} [timeoutMinutes] - Minutes after which a RUNNING migration is considered stuck
|
|
28
|
-
* @returns {Promise<void>} Promise that resolves when cleanup is complete
|
|
29
|
-
*/
|
|
30
|
-
cleanupStuckMigrations(timeoutMinutes?: number): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Executes pending migrations
|
|
33
|
-
* @param {Array<IConfigMigrationDefinition>} migrations - Array of migration definitions
|
|
34
|
-
* @param {boolean} [useTransaction] - Whether to use the named crud-config-migrations owner; defaults to true
|
|
35
|
-
* @param {EntityManager} [ownerManager] - Existing active Automator owner manager; requires useTransaction
|
|
36
|
-
* @returns {Promise<void>} Promise that resolves when all migrations are executed
|
|
37
|
-
*/
|
|
38
|
-
executeMigrations(migrations: Array<IConfigMigrationDefinition>, useTransaction?: boolean, ownerManager?: EntityManager): Promise<void>;
|
|
39
|
-
/**
|
|
40
|
-
* Gets list of executed migration names
|
|
41
|
-
* @returns {Promise<string[]>} Promise that resolves to list of executed migration names
|
|
42
|
-
*/
|
|
43
|
-
getExecutedMigrationList(): Promise<Array<string>>;
|
|
44
|
-
/**
|
|
45
|
-
* Gets list of executed migrations
|
|
46
|
-
* @returns {Promise<IConfigMigration[]>} Promise that resolves to list of executed migrations
|
|
47
|
-
*/
|
|
48
|
-
getExecutedMigrations(): Promise<Array<IConfigMigration>>;
|
|
49
|
-
/**
|
|
50
|
-
* Checks if a migration has been executed
|
|
51
|
-
* @param {string} migrationName - The name of the migration to check
|
|
52
|
-
* @returns {Promise<boolean>} Promise that resolves to true if migration is executed
|
|
53
|
-
*/
|
|
54
|
-
isMigrationExecuted(migrationName: string): Promise<boolean>;
|
|
55
|
-
onModuleInit(): void;
|
|
56
|
-
/**
|
|
57
|
-
* Rolls back a migration inside the named owner or a supplied active Automator owner
|
|
58
|
-
* @param {string} migrationName - The name of the migration to roll back
|
|
59
|
-
* @param {Array<IConfigMigrationDefinition>} migrations - Array of migration definitions
|
|
60
|
-
* @param {EntityManager} [ownerManager] - Existing active Automator owner manager
|
|
61
|
-
* @returns {Promise<void>} Promise that resolves when rollback is complete
|
|
62
|
-
*/
|
|
63
|
-
rollbackMigration(migrationName: string, migrations: Array<IConfigMigrationDefinition>, ownerManager?: EntityManager): Promise<void>;
|
|
64
|
-
private executePendingMigrations;
|
|
65
|
-
private executeRollback;
|
|
66
|
-
/**
|
|
67
|
-
* Executes a single migration
|
|
68
|
-
* @param {IConfigMigrationDefinition} migration - Migration definition
|
|
69
|
-
* @param {EntityManager} [transactionalEntityManager] - Optional transaction manager
|
|
70
|
-
* @returns {Promise<void>} Promise that resolves when migration is executed
|
|
71
|
-
*/
|
|
72
|
-
private executeSingleMigration;
|
|
73
|
-
private runWithOwnerManager;
|
|
74
|
-
/**
|
|
75
|
-
* Validates migrations for duplicates and naming issues
|
|
76
|
-
* @param {Array<IConfigMigrationDefinition>} migrations - Array of migration definitions
|
|
77
|
-
*/
|
|
78
|
-
private validateMigrations;
|
|
79
|
-
}
|
|
@@ -1,377 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var tslib_es6 = require('../../../external/tslib/tslib.es6.js');
|
|
4
|
-
var nestjsCrudAutomator = require('@elsikora/nestjs-crud-automator');
|
|
5
|
-
var config_service = require('../config.service.js');
|
|
6
|
-
var common = require('@nestjs/common');
|
|
7
|
-
var migration_constant = require('../../../shared/constant/config/migration.constant.js');
|
|
8
|
-
var token_constant = require('../../../shared/constant/token.constant.js');
|
|
9
|
-
var typeorm = require('typeorm');
|
|
10
|
-
var status = require('./enum/status.js');
|
|
11
|
-
|
|
12
|
-
var ConfigMigrationService_1;
|
|
13
|
-
/**
|
|
14
|
-
* Service responsible for coordinating and tracking execution of migrations.
|
|
15
|
-
* @see {@link https://elsikora.com/docs/nestjs-crud-config/migration-system | Migration System}
|
|
16
|
-
* @see {@link https://elsikora.com/docs/nestjs-crud-config/api-reference/classes/config-migration-service | API Reference - ConfigMigrationService}
|
|
17
|
-
*/
|
|
18
|
-
exports.ConfigMigrationService = ConfigMigrationService_1 = class ConfigMigrationService {
|
|
19
|
-
dataSource;
|
|
20
|
-
options;
|
|
21
|
-
configService;
|
|
22
|
-
LOGGER = new common.Logger(ConfigMigrationService_1.name);
|
|
23
|
-
MIGRATION_SERVICE;
|
|
24
|
-
constructor(dataSource, options, configService, migrationService) {
|
|
25
|
-
this.dataSource = dataSource;
|
|
26
|
-
this.options = options;
|
|
27
|
-
this.configService = configService;
|
|
28
|
-
this.MIGRATION_SERVICE = migrationService;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Cleans up failed migrations
|
|
32
|
-
* @param {string} [migrationName] - Optional migration name to clean up
|
|
33
|
-
* @returns {Promise<void>} Promise that resolves when cleanup is complete
|
|
34
|
-
*/
|
|
35
|
-
async cleanupFailedMigrations(migrationName) {
|
|
36
|
-
try {
|
|
37
|
-
const whereCondition = migrationName
|
|
38
|
-
? { name: migrationName, status: status.EConfigMigrationStatus.FAILED }
|
|
39
|
-
: { status: status.EConfigMigrationStatus.FAILED };
|
|
40
|
-
// Use bulk delete operation to avoid N+1 problem
|
|
41
|
-
const result = await this.MIGRATION_SERVICE.getList({ where: whereCondition });
|
|
42
|
-
if (result.items.length === 0) {
|
|
43
|
-
this.LOGGER.verbose("No failed migrations found to clean up");
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
// Delete all failed migrations in bulk
|
|
47
|
-
const migrationIds = result.items.map((m) => m.id);
|
|
48
|
-
for (const id of migrationIds) {
|
|
49
|
-
await this.MIGRATION_SERVICE.delete({ id });
|
|
50
|
-
}
|
|
51
|
-
this.LOGGER.verbose(`Cleaned up ${result.items.length} failed migration(s): ${result.items.map((m) => m.name).join(", ")}`);
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
this.LOGGER.error("Failed to cleanup failed migrations:", error);
|
|
55
|
-
throw error;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Cleans up stuck migrations (running for too long)
|
|
60
|
-
* @param {number} [timeoutMinutes] - Minutes after which a RUNNING migration is considered stuck
|
|
61
|
-
* @returns {Promise<void>} Promise that resolves when cleanup is complete
|
|
62
|
-
*/
|
|
63
|
-
async cleanupStuckMigrations(timeoutMinutes = migration_constant.CONFIG_MIGRATION_CONSTANT.DEFAULT_STUCK_MIGRATION_TIMEOUT_MINUTES) {
|
|
64
|
-
try {
|
|
65
|
-
const cutoffTime = new Date();
|
|
66
|
-
cutoffTime.setMinutes(cutoffTime.getMinutes() - timeoutMinutes);
|
|
67
|
-
const runningMigrations = await this.MIGRATION_SERVICE.getList({
|
|
68
|
-
where: { status: status.EConfigMigrationStatus.RUNNING },
|
|
69
|
-
});
|
|
70
|
-
const stuckMigrations = runningMigrations.items.filter((migration) => {
|
|
71
|
-
return migration.startedAt && new Date(migration.startedAt) < cutoffTime;
|
|
72
|
-
});
|
|
73
|
-
if (stuckMigrations.length === 0) {
|
|
74
|
-
this.LOGGER.verbose("No stuck migrations found");
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
this.LOGGER.warn(`Found ${stuckMigrations.length} stuck migration(s): ${stuckMigrations.map((m) => m.name).join(", ")}`);
|
|
78
|
-
// Mark stuck migrations as STUCK status
|
|
79
|
-
for (const migration of stuckMigrations) {
|
|
80
|
-
await this.MIGRATION_SERVICE.update({ id: migration.id }, {
|
|
81
|
-
failedAt: new Date(),
|
|
82
|
-
status: status.EConfigMigrationStatus.STUCK,
|
|
83
|
-
});
|
|
84
|
-
this.LOGGER.verbose(`Marked migration as stuck: ${migration.name}`);
|
|
85
|
-
}
|
|
86
|
-
this.LOGGER.warn(`Marked ${stuckMigrations.length} migration(s) as stuck. You may need to investigate and clean them up manually.`);
|
|
87
|
-
}
|
|
88
|
-
catch (error) {
|
|
89
|
-
this.LOGGER.error("Failed to cleanup stuck migrations:", error);
|
|
90
|
-
throw error;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Executes pending migrations
|
|
95
|
-
* @param {Array<IConfigMigrationDefinition>} migrations - Array of migration definitions
|
|
96
|
-
* @param {boolean} [useTransaction] - Whether to use the named crud-config-migrations owner; defaults to true
|
|
97
|
-
* @param {EntityManager} [ownerManager] - Existing active Automator owner manager; requires useTransaction
|
|
98
|
-
* @returns {Promise<void>} Promise that resolves when all migrations are executed
|
|
99
|
-
*/
|
|
100
|
-
async executeMigrations(migrations, useTransaction = true, ownerManager) {
|
|
101
|
-
if (ownerManager !== undefined) {
|
|
102
|
-
if (!useTransaction) {
|
|
103
|
-
throw new Error("Owner manager requires transaction-enabled migrations");
|
|
104
|
-
}
|
|
105
|
-
await this.runWithOwnerManager(ownerManager, async () => {
|
|
106
|
-
await this.executePendingMigrations(migrations, true, ownerManager);
|
|
107
|
-
});
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
await this.executePendingMigrations(migrations, useTransaction);
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Gets list of executed migration names
|
|
114
|
-
* @returns {Promise<string[]>} Promise that resolves to list of executed migration names
|
|
115
|
-
*/
|
|
116
|
-
async getExecutedMigrationList() {
|
|
117
|
-
const executedMigrations = await this.getExecutedMigrations();
|
|
118
|
-
return executedMigrations.map((migration) => migration.name);
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Gets list of executed migrations
|
|
122
|
-
* @returns {Promise<IConfigMigration[]>} Promise that resolves to list of executed migrations
|
|
123
|
-
*/
|
|
124
|
-
async getExecutedMigrations() {
|
|
125
|
-
try {
|
|
126
|
-
const result = await this.MIGRATION_SERVICE.getList({
|
|
127
|
-
order: { name: "ASC" },
|
|
128
|
-
});
|
|
129
|
-
return result.items;
|
|
130
|
-
}
|
|
131
|
-
catch (error) {
|
|
132
|
-
const errorMessage = `Failed to get executed migrations: ${error instanceof Error ? error.message : String(error)}`;
|
|
133
|
-
this.LOGGER.error(errorMessage);
|
|
134
|
-
throw error;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Checks if a migration has been executed
|
|
139
|
-
* @param {string} migrationName - The name of the migration to check
|
|
140
|
-
* @returns {Promise<boolean>} Promise that resolves to true if migration is executed
|
|
141
|
-
*/
|
|
142
|
-
async isMigrationExecuted(migrationName) {
|
|
143
|
-
try {
|
|
144
|
-
const result = await this.MIGRATION_SERVICE.getList({
|
|
145
|
-
where: { name: migrationName },
|
|
146
|
-
});
|
|
147
|
-
return result.items.length > 0 && result.items[0]?.status === status.EConfigMigrationStatus.COMPLETED;
|
|
148
|
-
}
|
|
149
|
-
catch (error) {
|
|
150
|
-
this.LOGGER.error(`Failed to check if migration '${migrationName}' is executed:`, error);
|
|
151
|
-
throw error;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
onModuleInit() {
|
|
155
|
-
// Remove the dynamic entity creation - we already have the service injected
|
|
156
|
-
this.LOGGER.log("Migration service initialized");
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Rolls back a migration inside the named owner or a supplied active Automator owner
|
|
160
|
-
* @param {string} migrationName - The name of the migration to roll back
|
|
161
|
-
* @param {Array<IConfigMigrationDefinition>} migrations - Array of migration definitions
|
|
162
|
-
* @param {EntityManager} [ownerManager] - Existing active Automator owner manager
|
|
163
|
-
* @returns {Promise<void>} Promise that resolves when rollback is complete
|
|
164
|
-
*/
|
|
165
|
-
async rollbackMigration(migrationName, migrations, ownerManager) {
|
|
166
|
-
if (ownerManager !== undefined) {
|
|
167
|
-
await this.runWithOwnerManager(ownerManager, async () => {
|
|
168
|
-
await this.executeRollback(migrationName, migrations, ownerManager);
|
|
169
|
-
});
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
await this.executeRollback(migrationName, migrations);
|
|
173
|
-
}
|
|
174
|
-
async executePendingMigrations(migrations, useTransaction, ownerManager) {
|
|
175
|
-
if (!migrations || migrations.length === 0) {
|
|
176
|
-
this.LOGGER.verbose("No migrations to execute");
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
// Validate migrations
|
|
180
|
-
this.validateMigrations(migrations);
|
|
181
|
-
// Sort migrations by name to ensure consistent order
|
|
182
|
-
const sortedMigrations = [];
|
|
183
|
-
for (const migration of migrations) {
|
|
184
|
-
const insertIndex = sortedMigrations.findIndex((item) => migration.name.localeCompare(item.name) < 0);
|
|
185
|
-
if (insertIndex === -1) {
|
|
186
|
-
sortedMigrations.push(migration);
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
sortedMigrations.splice(insertIndex, 0, migration);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
this.LOGGER.verbose(`Starting migration execution for ${sortedMigrations.length} migrations`);
|
|
193
|
-
// Clean up stuck migrations before starting new ones
|
|
194
|
-
const timeoutMinutes = this.options.migrationOptions?.stuckMigrationTimeoutMinutes ??
|
|
195
|
-
migration_constant.CONFIG_MIGRATION_CONSTANT.DEFAULT_STUCK_MIGRATION_TIMEOUT_MINUTES;
|
|
196
|
-
await this.cleanupStuckMigrations(timeoutMinutes);
|
|
197
|
-
const executedMigrations = await this.getExecutedMigrations();
|
|
198
|
-
const completedMigrationNames = new Set(executedMigrations
|
|
199
|
-
.filter((m) => m.status === status.EConfigMigrationStatus.COMPLETED)
|
|
200
|
-
.map((m) => m.name));
|
|
201
|
-
// Also check for currently running migrations to avoid conflicts
|
|
202
|
-
const runningMigrationNames = new Set(executedMigrations
|
|
203
|
-
.filter((m) => m.status === status.EConfigMigrationStatus.RUNNING)
|
|
204
|
-
.map((m) => m.name));
|
|
205
|
-
const pendingMigrations = sortedMigrations.filter((migration) => !completedMigrationNames.has(migration.name) && !runningMigrationNames.has(migration.name));
|
|
206
|
-
if (pendingMigrations.length === 0) {
|
|
207
|
-
this.LOGGER.verbose("No pending migrations to execute");
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
this.LOGGER.verbose(`Found ${pendingMigrations.length} pending migration(s): ${pendingMigrations.map((m) => m.name).join(", ")}`);
|
|
211
|
-
if (ownerManager !== undefined) {
|
|
212
|
-
for (const migration of pendingMigrations) {
|
|
213
|
-
await this.executeSingleMigration(migration, ownerManager);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
else if (useTransaction) {
|
|
217
|
-
await nestjsCrudAutomator.ApiFunctionTransactionScope.runWithDataSource(this.dataSource, { name: "crud-config-migrations" }, async (transactionalEntityManager) => {
|
|
218
|
-
for (const migration of pendingMigrations) {
|
|
219
|
-
await this.executeSingleMigration(migration, transactionalEntityManager);
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
for (const migration of pendingMigrations) {
|
|
225
|
-
await this.executeSingleMigration(migration);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
this.LOGGER.verbose(`Successfully executed ${pendingMigrations.length} migration(s): ${pendingMigrations.map((m) => m.name).join(", ")}`);
|
|
229
|
-
}
|
|
230
|
-
async executeRollback(migrationName, migrations, ownerManager) {
|
|
231
|
-
const migration = migrations.find((m) => m.name === migrationName);
|
|
232
|
-
if (!migration) {
|
|
233
|
-
throw new Error(`Migration '${migrationName}' not found`);
|
|
234
|
-
}
|
|
235
|
-
if (!migration.down) {
|
|
236
|
-
throw new Error(`Migration '${migrationName}' does not have a down method`);
|
|
237
|
-
}
|
|
238
|
-
const startTime = new Date();
|
|
239
|
-
try {
|
|
240
|
-
this.LOGGER.verbose(`Starting rollback for migration: ${migration.name}`);
|
|
241
|
-
const executeDown = async (transactionalEntityManager) => {
|
|
242
|
-
try {
|
|
243
|
-
// Execute the down method
|
|
244
|
-
await migration.down?.(this.configService, transactionalEntityManager);
|
|
245
|
-
// Delete the migration record in the rollback transaction context.
|
|
246
|
-
await this.MIGRATION_SERVICE.delete({ name: migrationName });
|
|
247
|
-
this.LOGGER.verbose(`Successfully rolled back migration: ${migration.name}`);
|
|
248
|
-
}
|
|
249
|
-
catch (downError) {
|
|
250
|
-
const errorMessage = `Failed to rollback migration '${migration.name}': ${downError instanceof Error ? downError.message : String(downError)}`;
|
|
251
|
-
this.LOGGER.error(errorMessage);
|
|
252
|
-
// Don't update the migration record on rollback failure
|
|
253
|
-
throw downError;
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
if (ownerManager === undefined) {
|
|
257
|
-
await nestjsCrudAutomator.ApiFunctionTransactionScope.runWithDataSource(this.dataSource, { name: "crud-config-migrations" }, executeDown);
|
|
258
|
-
}
|
|
259
|
-
else {
|
|
260
|
-
await executeDown(ownerManager);
|
|
261
|
-
}
|
|
262
|
-
const completedTime = new Date();
|
|
263
|
-
this.LOGGER.verbose(`Migration rollback completed: ${migration.name} (took ${completedTime.getTime() - startTime.getTime()}ms)`);
|
|
264
|
-
}
|
|
265
|
-
catch (error) {
|
|
266
|
-
const duration = Date.now() - startTime.getTime();
|
|
267
|
-
this.LOGGER.error(`Migration rollback failed: ${migration.name} (took ${duration}ms)`, error);
|
|
268
|
-
const failedTime = new Date();
|
|
269
|
-
// A failed participant SQL operation can leave the caller's transaction aborted.
|
|
270
|
-
try {
|
|
271
|
-
await this.MIGRATION_SERVICE.update({ name: migrationName }, {
|
|
272
|
-
failedAt: failedTime,
|
|
273
|
-
status: status.EConfigMigrationStatus.FAILED,
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
catch (updateError) {
|
|
277
|
-
if (ownerManager === undefined) {
|
|
278
|
-
throw updateError;
|
|
279
|
-
}
|
|
280
|
-
this.LOGGER.error(`Failed to update migration status for ${migration.name}:`, updateError);
|
|
281
|
-
}
|
|
282
|
-
throw error;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Executes a single migration
|
|
287
|
-
* @param {IConfigMigrationDefinition} migration - Migration definition
|
|
288
|
-
* @param {EntityManager} [transactionalEntityManager] - Optional transaction manager
|
|
289
|
-
* @returns {Promise<void>} Promise that resolves when migration is executed
|
|
290
|
-
*/
|
|
291
|
-
async executeSingleMigration(migration, transactionalEntityManager) {
|
|
292
|
-
this.LOGGER.verbose(`Executing migration: ${migration.name}`);
|
|
293
|
-
// First, record the migration as started (to prevent race conditions)
|
|
294
|
-
const startTime = new Date();
|
|
295
|
-
const migrationRecord = await this.MIGRATION_SERVICE.create({
|
|
296
|
-
name: migration.name,
|
|
297
|
-
startedAt: startTime,
|
|
298
|
-
status: status.EConfigMigrationStatus.RUNNING,
|
|
299
|
-
});
|
|
300
|
-
try {
|
|
301
|
-
// Execute the migration
|
|
302
|
-
await migration.up(this.configService, transactionalEntityManager);
|
|
303
|
-
// Update status to completed with executedAt timestamp
|
|
304
|
-
const completedTime = new Date();
|
|
305
|
-
await this.MIGRATION_SERVICE.update({ id: migrationRecord.id }, {
|
|
306
|
-
executedAt: completedTime,
|
|
307
|
-
status: status.EConfigMigrationStatus.COMPLETED,
|
|
308
|
-
});
|
|
309
|
-
const duration = completedTime.getTime() - startTime.getTime();
|
|
310
|
-
this.LOGGER.verbose(`Successfully executed migration: ${migration.name} (${duration}ms)`);
|
|
311
|
-
}
|
|
312
|
-
catch (error) {
|
|
313
|
-
this.LOGGER.error(`Failed to execute migration: ${migration.name}`, error);
|
|
314
|
-
// Mark migration as failed with failedAt timestamp
|
|
315
|
-
const failedTime = new Date();
|
|
316
|
-
try {
|
|
317
|
-
await this.MIGRATION_SERVICE.update({ id: migrationRecord.id }, {
|
|
318
|
-
failedAt: failedTime,
|
|
319
|
-
status: status.EConfigMigrationStatus.FAILED,
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
catch (updateError) {
|
|
323
|
-
this.LOGGER.error(`Failed to update migration status for ${migration.name}:`, updateError);
|
|
324
|
-
}
|
|
325
|
-
throw error;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
async runWithOwnerManager(ownerManager, callback) {
|
|
329
|
-
const queryRunner = ownerManager.queryRunner;
|
|
330
|
-
if (
|
|
331
|
-
// eslint-disable-next-line @elsikora/sonar/deprecation -- The supported TypeORM 0.3 peer exposes DataSource identity as connection.
|
|
332
|
-
ownerManager.connection !== this.dataSource ||
|
|
333
|
-
// eslint-disable-next-line @elsikora/sonar/deprecation -- The supported TypeORM 0.3 QueryRunner exposes DataSource identity as connection.
|
|
334
|
-
queryRunner?.connection !== this.dataSource ||
|
|
335
|
-
queryRunner.manager !== ownerManager ||
|
|
336
|
-
!queryRunner.isTransactionActive ||
|
|
337
|
-
queryRunner.isReleased) {
|
|
338
|
-
throw new Error("Migration participation requires the active owner manager for this DataSource");
|
|
339
|
-
}
|
|
340
|
-
await nestjsCrudAutomator.ApiFunctionTransactionScope.runWithEntityManager(ownerManager, callback);
|
|
341
|
-
}
|
|
342
|
-
/**
|
|
343
|
-
* Validates migrations for duplicates and naming issues
|
|
344
|
-
* @param {Array<IConfigMigrationDefinition>} migrations - Array of migration definitions
|
|
345
|
-
*/
|
|
346
|
-
validateMigrations(migrations) {
|
|
347
|
-
// Check for duplicate names
|
|
348
|
-
const migrationNames = migrations.map((m) => m.name);
|
|
349
|
-
const duplicates = migrationNames.filter((name, index) => migrationNames.indexOf(name) !== index);
|
|
350
|
-
if (duplicates.length > 0) {
|
|
351
|
-
throw new Error(`Duplicate migration names found: ${duplicates.join(", ")}`);
|
|
352
|
-
}
|
|
353
|
-
// Check for invalid names (cannot be empty or contain only whitespace)
|
|
354
|
-
const invalidNames = migrationNames.filter((name) => !name?.trim());
|
|
355
|
-
if (invalidNames.length > 0) {
|
|
356
|
-
throw new Error("Migration names cannot be empty or contain only whitespace");
|
|
357
|
-
}
|
|
358
|
-
// Check for missing required methods
|
|
359
|
-
const invalidMigrations = migrations.filter((m) => !m.up || typeof m.up !== "function");
|
|
360
|
-
if (invalidMigrations.length > 0) {
|
|
361
|
-
throw new Error(`Migrations missing required 'up' method: ${invalidMigrations.map((m) => m.name).join(", ")}`);
|
|
362
|
-
}
|
|
363
|
-
// Check for names that are too long
|
|
364
|
-
const tooLongNames = migrationNames.filter((name) => name.length > migration_constant.CONFIG_MIGRATION_CONSTANT.MAX_NAME_LENGTH);
|
|
365
|
-
if (tooLongNames.length > 0) {
|
|
366
|
-
throw new Error(`Migration names too long (max ${migration_constant.CONFIG_MIGRATION_CONSTANT.MAX_NAME_LENGTH} characters): ${tooLongNames.join(", ")}`);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
};
|
|
370
|
-
exports.ConfigMigrationService = ConfigMigrationService_1 = tslib_es6.__decorate([
|
|
371
|
-
common.Injectable(),
|
|
372
|
-
tslib_es6.__param(0, common.Inject(typeorm.DataSource)),
|
|
373
|
-
tslib_es6.__param(1, common.Inject(token_constant.TOKEN_CONSTANT.CONFIG_OPTIONS)),
|
|
374
|
-
tslib_es6.__param(3, common.Inject(token_constant.TOKEN_CONSTANT.CONFIG_MIGRATION_SERVICE)),
|
|
375
|
-
tslib_es6.__metadata("design:paramtypes", [typeorm.DataSource, Object, config_service.CrudConfigService, Function])
|
|
376
|
-
], exports.ConfigMigrationService);
|
|
377
|
-
//# sourceMappingURL=migration.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migration.service.js","sources":["../../../../../../src/modules/config/migration/migration.service.ts"],"sourcesContent":[null],"names":["ConfigMigrationService","Logger","EConfigMigrationStatus","CONFIG_MIGRATION_CONSTANT","ApiFunctionTransactionScope","__decorate","Injectable","__param","Inject","DataSource","TOKEN_CONSTANT","__metadata","CrudConfigService"],"mappings":";;;;;;;;;;;;AAaA;;;;AAIG;AAEUA,8BAAsB,GAAA,wBAAA,GAA5B,MAAM,sBAAsB,CAAA;AAMI,IAAA,UAAA;AACmB,IAAA,OAAA;AACvC,IAAA,aAAA;IAPD,MAAM,GAAW,IAAIC,aAAM,CAAC,wBAAsB,CAAC,IAAI,CAAC;AAExD,IAAA,iBAAiB;AAElC,IAAA,WAAA,CACsC,UAAsB,EACH,OAAuB,EAC9D,aAAgC,EAEjD,gBAAkD,EAAA;QAJb,IAAA,CAAA,UAAU,GAAV,UAAU;QACS,IAAA,CAAA,OAAO,GAAP,OAAO;QAC9C,IAAA,CAAA,aAAa,GAAb,aAAa;AAI9B,QAAA,IAAI,CAAC,iBAAiB,GAAG,gBAAgB;IAC1C;AAEA;;;;AAIG;IACH,MAAM,uBAAuB,CAAC,aAAsB,EAAA;AACnD,QAAA,IAAI;YACH,MAAM,cAAc,GAAsD;kBACvE,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAEC,6BAAsB,CAAC,MAAM;kBAC5D,EAAE,MAAM,EAAEA,6BAAsB,CAAC,MAAM,EAAE;;AAG5C,YAAA,MAAM,MAAM,GACX,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,cAAc,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