fix: add work around to handle bad data in Firestore UQI migration (#9966)
* add another migration for those Firestore actions that could not be migrated. * handle ClassCastException via try catch and assigning default empty value.
This commit is contained in:
parent
08364f61de
commit
4a075628d7
|
|
@ -3520,7 +3520,14 @@ public class DatabaseChangelog {
|
|||
uqiWhereMap.put(CONDITION_KEY, AND);
|
||||
uqiWhereMap.put(CHILDREN_KEY, new ArrayList<>());
|
||||
|
||||
List<Map<String, Object>> oldListOfConditions = (List<Map<String, Object>>) value;
|
||||
List<Map<String, Object>> oldListOfConditions;
|
||||
try {
|
||||
oldListOfConditions = (List<Map<String, Object>>) value;
|
||||
} catch (ClassCastException e) {
|
||||
System.out.println("value: " + value);
|
||||
oldListOfConditions = new ArrayList<>();
|
||||
}
|
||||
|
||||
oldListOfConditions.stream()
|
||||
.forEachOrdered(oldCondition -> {
|
||||
/* Map old values to keys in the new UQI format. */
|
||||
|
|
@ -4536,6 +4543,11 @@ public class DatabaseChangelog {
|
|||
continue;
|
||||
}
|
||||
|
||||
/* It means that earlier migration had succeeded on this action, hence current migration can be skipped. */
|
||||
if (!CollectionUtils.isEmpty(unpublishedAction.getActionConfiguration().getFormData())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<Property> pluginSpecifiedTemplates = unpublishedAction.getActionConfiguration().getPluginSpecifiedTemplates();
|
||||
UQIMigrationDataTransformer uqiMigrationDataTransformer = new UQIMigrationDataTransformer();
|
||||
|
||||
|
|
@ -4692,4 +4704,34 @@ public class DatabaseChangelog {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This migration was required because migration numbered 104 failed on prod due to ClassCastException on some
|
||||
* unexpected / bad older data.
|
||||
*/
|
||||
@ChangeSet(order = "107", id = "migrate-firestore-to-uqi-3", author = "")
|
||||
public void migrateFirestorePluginToUqi3(MongockTemplate mongockTemplate) {
|
||||
// Update Firestore plugin to indicate use of UQI schema
|
||||
Plugin firestorePlugin = mongockTemplate.findOne(
|
||||
query(where("packageName").is("firestore-plugin")),
|
||||
Plugin.class
|
||||
);
|
||||
firestorePlugin.setUiComponent("UQIDbEditorForm");
|
||||
|
||||
// Find all Firestore actions
|
||||
final Query firestoreActionQuery = query(
|
||||
where(fieldName(QNewAction.newAction.pluginId)).is(firestorePlugin.getId())
|
||||
.and(fieldName(QNewAction.newAction.deleted)).ne(true)); // setting `deleted` != `true`
|
||||
firestoreActionQuery.fields()
|
||||
.include(fieldName(QNewAction.newAction.id));
|
||||
|
||||
List<NewAction> firestoreActions = mongockTemplate.find(
|
||||
firestoreActionQuery,
|
||||
NewAction.class
|
||||
);
|
||||
|
||||
migrateFirestoreToUQI(mongockTemplate, firestoreActions);
|
||||
|
||||
// Update plugin data.
|
||||
mongockTemplate.save(firestorePlugin);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user