Renaming + add issuer flag
MODIFY
src/migration/MigrationHandler.ts
src/migration/MigrationHandler.ts
import AddActivePropertyToTagsTask from './tasks/AddActivePropertyToTagsTask';
import AddConsumptionAmpsToConsumptionsTask from './tasks/AddConsumptionAmpsToConsumptionsTask';
-import AddCreatedPropertiesToBadgeTask from './tasks/AddCreatedPropertiesToBadgeTask';
+import AddCreatedPropertiesToTagTask from './tasks/AddCreatedPropertiesToTagTask';
import AddDescriptionToTagsTask from './tasks/AddDescriptionToTagsTask';
import AddInactivityStatusInTransactionsTask from './tasks/AddInactivityStatusInTransactionsTask';
import AddIssuerFieldTask from './tasks/AddIssuerFieldTask';
@@ -16,11 +16,11 @@ import CleanupMeterValuesTask from './tasks/CleanupMeterValuesTask';
import CleanupOrphanBadgeTask from './tasks/CleanupOrphanBadgeTask';
import CleanupSiteAreasTask from './tasks/CleanupSiteAreasTask';
import Constants from '../utils/Constants';
-import DeleteTagsForDeletedUsersTask from './tasks/DeleteTagsForDeletedUsersTask';
import InitialCarImportTask from './tasks/InitialCarImportTask';
import { LockEntity } from '../types/Locking';
import LockingManager from '../locking/LockingManager';
import Logging from '../utils/Logging';
+import LogicallyDeleteTagsOfDeletedUsersTask from './tasks/LogicallyDeleteTagsOfDeletedUsersTask';
import MigrateCoordinatesTask from './tasks/MigrateCoordinatesTask';
import MigrateOcpiSettingTask from './tasks/MigrateOcpiSettingTask';
import MigrateOcpiTransactionsTask from './tasks/MigrateOcpiTransactionsTask';
@@ -73,7 +73,6 @@ export default class MigrationHandler {
currentMigrationTasks.push(new AddInactivityStatusInTransactionsTask());
currentMigrationTasks.push(new AddIssuerFieldTask());
currentMigrationTasks.push(new CleanupOrphanBadgeTask());
- currentMigrationTasks.push(new AddLastChangePropertiesToBadgeTask());
currentMigrationTasks.push(new AddActivePropertyToTagsTask());
currentMigrationTasks.push(new InitialCarImportTask());
currentMigrationTasks.push(new UpdateConsumptionsToObjectIDsTask());
@@ -89,9 +88,10 @@ export default class MigrationHandler {
currentMigrationTasks.push(new UnmarkTransactionExtraInactivitiesTask());
currentMigrationTasks.push(new RecomputeAllTransactionsConsumptionsTask());
currentMigrationTasks.push(new AddUserInTransactionsTask());
- currentMigrationTasks.push(new DeleteTagsForDeletedUsersTask());
currentMigrationTasks.push(new AlignTagsWithUsersIssuerTask());
- currentMigrationTasks.push(new AddCreatedPropertiesToBadgeTask());
+ currentMigrationTasks.push(new AddLastChangePropertiesToBadgeTask());
+ currentMigrationTasks.push(new LogicallyDeleteTagsOfDeletedUsersTask());
+ currentMigrationTasks.push(new AddCreatedPropertiesToTagTask());
currentMigrationTasks.push(new AddDescriptionToTagsTask());
// Get the already done migrations from the DB
const migrationTasksDone = await MigrationStorage.getMigrations();

RENAME
src/migration/tasks/AddCreatedPropertiesToBadgeTask.ts
src/migration/tasks/AddCreatedPropertiesToTagTask.ts
@@ -8,9 +8,9 @@ import UserStorage from '../../storage/mongodb/UserStorage';
import Utils from '../../utils/Utils';
import global from '../../types/GlobalType';
-const MODULE_NAME = 'AddCreatedPropertiesToBadgeTask';
+const MODULE_NAME = 'AddCreatedPropertiesToTagTask';
-export default class AddCreatedPropertiesToBadgeTask extends MigrationTask {
+export default class AddCreatedPropertiesToTagTask extends MigrationTask {
async migrate(): Promise<void> {
const tenants = await TenantStorage.getTenants({}, Constants.DB_PARAMS_MAX_LIMIT);
for (const tenant of tenants.result) {
@@ -64,7 +64,7 @@ export default class AddCreatedPropertiesToBadgeTask extends MigrationTask {
}
getName(): string {
- return 'AddCreatedPropertiesToBadgeTask';
+ return 'AddCreatedPropertiesToTagTask';
}
isAsynchronous(): boolean {

MODIFY
src/migration/tasks/AlignTagsWithUsersIssuerTask.ts
src/migration/tasks/AlignTagsWithUsersIssuerTask.ts
@@ -22,8 +22,9 @@ export default class AlignTagsWithUsersIssuerTask extends MigrationTask {
let updated = 0;
let result: UpdateWriteOpResult;
// Get users
- const usersMDB = await global.database.getCollection<any>(tenant.id, 'users')
- .find({}).toArray();
+ const usersMDB = await global.database.getCollection<any>(tenant.id, 'users').find({
+ issuer: true,
+ }).toArray();
if (!Utils.isEmptyArray(usersMDB)) {
// Update tags
for (const userMDB of usersMDB) {
@@ -43,7 +44,7 @@ export default class AlignTagsWithUsersIssuerTask extends MigrationTask {
tenantID: Constants.DEFAULT_TENANT,
action: ServerAction.MIGRATION,
module: MODULE_NAME, method: 'migrateTenant',
- message: `${updated} Tag(s) have been updated in Tenant '${tenant.name}'`,
+ message: `${updated} Tag's issuer properties have been updated in Tenant '${tenant.name}'`,
});
}
}

RENAME
src/migration/tasks/DeleteTagsForDeletedUsersTask.ts
src/migration/tasks/LogicallyDeleteTagsOfDeletedUsersTask.ts
@@ -8,9 +8,9 @@ import { UpdateWriteOpResult } from 'mongodb';
import Utils from '../../utils/Utils';
import global from '../../types/GlobalType';
-const MODULE_NAME = 'DeleteTagsForDeletedUsersTask';
+const MODULE_NAME = 'LogicallyDeleteTagsOfDeletedUsersTask';
-export default class DeleteTagsForDeletedUsersTask extends MigrationTask {
+export default class LogicallyDeleteTagsOfDeletedUsersTask extends MigrationTask {
async migrate(): Promise<void> {
const tenants = await TenantStorage.getTenants({}, Constants.DB_PARAMS_MAX_LIMIT);
for (const tenant of tenants.result) {
@@ -21,8 +21,9 @@ export default class DeleteTagsForDeletedUsersTask extends MigrationTask {
async migrateTenant(tenant: Tenant): Promise<void> {
let updated = 0;
let result: UpdateWriteOpResult;
+ // Get deleted Users
const users = await global.database.getCollection<any>(tenant.id, 'users').find({
- 'deleted': true
+ deleted: true
}).toArray();
if (!Utils.isEmptyArray(users)) {
for (const user of users) {
@@ -46,7 +47,7 @@ export default class DeleteTagsForDeletedUsersTask extends MigrationTask {
tenantID: Constants.DEFAULT_TENANT,
action: ServerAction.MIGRATION,
module: MODULE_NAME, method: 'migrateTenant',
- message: `${updated} Tags(s) have been updated in Tenant '${tenant.name}'`
+ message: `${updated} Tag(s) have been marked logically deleted in Tenant '${tenant.name}'`
});
}
}
@@ -56,7 +57,7 @@ export default class DeleteTagsForDeletedUsersTask extends MigrationTask {
}
getName(): string {
- return 'DeleteTagsForDeletedUsersTask';
+ return 'LogicallyDeleteTagsOfDeletedUsersTask';
}
isAsynchronous(): boolean {
@@ -64,4 +65,3 @@ export default class DeleteTagsForDeletedUsersTask extends MigrationTask {
}
}
-

Renaming + add issuer flag