From d689aad90efc432fc58369353b6465246a8b6c11 Mon Sep 17 00:00:00 2001 From: jasquat Date: Thu, 22 Sep 2022 17:23:30 -0400 Subject: [PATCH] cascade process instance delete to message instances w/ burnettk --- src/spiffworkflow_backend/models/message_correlation.py | 4 ++++ src/spiffworkflow_backend/models/message_instance.py | 1 + src/spiffworkflow_backend/models/process_instance.py | 2 ++ 3 files changed, 7 insertions(+) diff --git a/src/spiffworkflow_backend/models/message_correlation.py b/src/spiffworkflow_backend/models/message_correlation.py index ec97200b..8ab9f920 100644 --- a/src/spiffworkflow_backend/models/message_correlation.py +++ b/src/spiffworkflow_backend/models/message_correlation.py @@ -1,6 +1,8 @@ """Message_correlation.""" from dataclasses import dataclass +from sqlalchemy.orm import relationship + from flask_bpmn.models.db import db from flask_bpmn.models.db import SpiffworkflowBaseDBModel from sqlalchemy import ForeignKey @@ -36,3 +38,5 @@ class MessageCorrelationModel(SpiffworkflowBaseDBModel): value = db.Column(db.String(255), nullable=False, index=True) updated_at_in_seconds: int = db.Column(db.Integer) created_at_in_seconds: int = db.Column(db.Integer) + + message_correlations_message_instances = relationship("MessageCorrelationMessageInstanceModel", cascade="delete") diff --git a/src/spiffworkflow_backend/models/message_instance.py b/src/spiffworkflow_backend/models/message_instance.py index 99556502..bac4eb17 100644 --- a/src/spiffworkflow_backend/models/message_instance.py +++ b/src/spiffworkflow_backend/models/message_instance.py @@ -42,6 +42,7 @@ class MessageInstanceModel(SpiffworkflowBaseDBModel): process_instance_id: int = db.Column(ForeignKey(ProcessInstanceModel.id), nullable=False) # type: ignore message_model_id: int = db.Column(ForeignKey(MessageModel.id), nullable=False) message_model = relationship("MessageModel") + message_correlations_message_instances = relationship("MessageCorrelationMessageInstanceModel", cascade="delete") message_type: str = db.Column(db.String(20), nullable=False) payload: str = db.Column(db.JSON) diff --git a/src/spiffworkflow_backend/models/process_instance.py b/src/spiffworkflow_backend/models/process_instance.py index ea9fa615..ac0bb315 100644 --- a/src/spiffworkflow_backend/models/process_instance.py +++ b/src/spiffworkflow_backend/models/process_instance.py @@ -95,6 +95,8 @@ class ProcessInstanceModel(SpiffworkflowBaseDBModel): active_tasks = relationship("ActiveTaskModel", cascade="delete") # type: ignore task_events = relationship("TaskEventModel", cascade="delete") # type: ignore spiff_logs = relationship("SpiffLoggingModel", cascade="delete") # type: ignore + message_instances = relationship("MessageInstanceModel", cascade="delete") # type: ignore + message_correlations = relationship("MessageCorrelationModel", cascade="delete") # type: ignore bpmn_json: str | None = deferred(db.Column(db.JSON)) # type: ignore start_in_seconds: int | None = db.Column(db.Integer)