diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/data_migrations/version_2.py b/spiffworkflow-backend/src/spiffworkflow_backend/data_migrations/version_2.py index 58bc85d4..308e65e6 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/data_migrations/version_2.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/data_migrations/version_2.py @@ -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)}" diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/task_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/task_service.py index f6e896b9..0a6d3a39 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/task_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/task_service.py @@ -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(