diff --git a/spiffworkflow-backend/bin/data_migrations/run_all.py b/spiffworkflow-backend/bin/data_migrations/run_all.py index 9770b5da..0e888b9a 100644 --- a/spiffworkflow-backend/bin/data_migrations/run_all.py +++ b/spiffworkflow-backend/bin/data_migrations/run_all.py @@ -61,6 +61,15 @@ def remove_duplicate_human_task_rows() -> None: db.session.commit() +@benchmark_log_func +def backfill_task_guid_for_human_tasks() -> None: + update_query = ( + update(HumanTaskModel).where(HumanTaskModel.task_guid == None).values(task_guid=HumanTaskModel.task_id) # noqa: E711 + ) + db.session.execute(update_query) + db.session.commit() + + def all_potentially_relevant_process_instances() -> list[ProcessInstanceModel]: return ProcessInstanceModel.query.filter( ProcessInstanceModel.spiff_serializer_version < Version2.version(), @@ -88,6 +97,7 @@ def main() -> None: start_time = time.time() put_serializer_version_onto_numeric_track() remove_duplicate_human_task_rows() + backfill_task_guid_for_human_tasks() process_instances = all_potentially_relevant_process_instances() potentially_relevant_instance_count = len(process_instances) current_app.logger.debug(f"Found potentially relevant process_instances: {potentially_relevant_instance_count}") diff --git a/spiffworkflow-backend/bin/data_migrations/version_1_3.py b/spiffworkflow-backend/bin/data_migrations/version_1_3.py deleted file mode 100644 index 1806db10..00000000 --- a/spiffworkflow-backend/bin/data_migrations/version_1_3.py +++ /dev/null @@ -1,21 +0,0 @@ -import time - -from spiffworkflow_backend import create_app -from spiffworkflow_backend.data_migrations.version_1_3 import VersionOneThree - - -def main() -> None: - app = create_app() - start_time = time.time() - - with app.app_context(): - VersionOneThree().run() - - end_time = time.time() - app.logger.debug( - f"done running data migration from ./bin/data_migrations/version_1_3.py. took {end_time - start_time} seconds" - ) - - -if __name__ == "__main__": - main() diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py index 218acf85..f10b5cb5 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py @@ -925,9 +925,15 @@ def _task_submit_shared( human_task=human_task, ) + # currently task_model has the potential to be None. This should be removable once + # we backfill the human_task table for task_guid and make that column not nullable + task_model: TaskModel | None = human_task.task_model + if task_model is None: + task_model = TaskModel.query.filter_by(guid=human_task.task_id).first() + # delete draft data when we submit a task to ensure cycling back to the task contains the # most up-to-date data - task_draft_data = TaskService.task_draft_data_from_task_model(human_task.task_model) + task_draft_data = TaskService.task_draft_data_from_task_model(task_model) if task_draft_data is not None: db.session.delete(task_draft_data) db.session.commit()