feature/fix-task-last-state-change (#452)
* added a migration function to fix tasks with null last state changes * pyl --------- Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
parent
56c1823646
commit
8160d174bc
|
@ -37,6 +37,9 @@ class VersionOneThree:
|
||||||
for tdwe in task_definitions_with_events:
|
for tdwe in task_definitions_with_events:
|
||||||
self.update_event_definitions(tdwe)
|
self.update_event_definitions(tdwe)
|
||||||
|
|
||||||
|
# TODO: remove this once this gets out to prod
|
||||||
|
self.update_tasks_where_last_change_is_null()
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
print("end VersionOneThree.run")
|
print("end VersionOneThree.run")
|
||||||
|
|
||||||
|
@ -210,3 +213,12 @@ class VersionOneThree:
|
||||||
task_definition.properties_json = properties_json
|
task_definition.properties_json = properties_json
|
||||||
flag_modified(task_definition, "properties_json") # type: ignore
|
flag_modified(task_definition, "properties_json") # type: ignore
|
||||||
db.session.add(task_definition)
|
db.session.add(task_definition)
|
||||||
|
|
||||||
|
def update_tasks_where_last_change_is_null(self) -> None:
|
||||||
|
task_models = TaskModel.query.filter(TaskModel.properties_json.like('%last_state_change": null%')).all() # type: ignore
|
||||||
|
for task_model in task_models:
|
||||||
|
parent_task_model = task_model.parent_task_model()
|
||||||
|
task_model.properties_json["last_state_change"] = parent_task_model.properties_json["last_state_change"]
|
||||||
|
task_model.properties_json["task_spec"] = task_model.task_definition.bpmn_identifier
|
||||||
|
flag_modified(task_model, "properties_json") # type: ignore
|
||||||
|
db.session.bulk_save_objects(task_models)
|
||||||
|
|
Loading…
Reference in New Issue