do not save events to db when running data migrations w/ burnettk

This commit is contained in:
jasquat 2023-10-16 15:02:19 -04:00
parent abf87a5aa3
commit 4d7347c131
2 changed files with 4 additions and 3 deletions

View File

@ -29,7 +29,7 @@ class Version2(DataMigrationBase):
for spiff_task in spiff_tasks:
cls.update_spiff_task_parents(spiff_task, task_service)
task_service.save_objects_to_database()
task_service.save_objects_to_database(save_process_instance_events=False)
except Exception as ex:
current_app.logger.warning(
f"Failed to migrate process_instance '{process_instance.id}'. The error was {str(ex)}"

View File

@ -117,10 +117,11 @@ class TaskService:
self.json_data_dicts: dict[str, JsonDataDict] = {}
self.process_instance_events: dict[str, ProcessInstanceEventModel] = {}
def save_objects_to_database(self) -> None:
def save_objects_to_database(self, save_process_instance_events: bool = True) -> None:
db.session.bulk_save_objects(self.bpmn_processes.values())
db.session.bulk_save_objects(self.task_models.values())
db.session.bulk_save_objects(self.process_instance_events.values())
if save_process_instance_events:
db.session.bulk_save_objects(self.process_instance_events.values())
JsonDataModel.insert_or_update_json_data_records(self.json_data_dicts)
def process_parents_and_children_and_save_to_database(