diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/bpmn_process.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/bpmn_process.py index 24ccbe286..3d6a74dab 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/bpmn_process.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/bpmn_process.py @@ -20,11 +20,11 @@ class BpmnProcessModel(SpiffworkflowBaseDBModel): guid: str | None = db.Column(db.String(36), nullable=True, unique=True, index=True) bpmn_process_definition_id: int = db.Column( - ForeignKey(BpmnProcessDefinitionModel.id), nullable=False # type: ignore + ForeignKey(BpmnProcessDefinitionModel.id), nullable=False, index=True # type: ignore ) bpmn_process_definition = relationship(BpmnProcessDefinitionModel) - parent_process_id: int | None = db.Column(ForeignKey("bpmn_process.id"), nullable=True) + parent_process_id: int | None = db.Column(ForeignKey("bpmn_process.id"), nullable=True, index=True) properties_json: dict = db.Column(db.JSON, nullable=False) json_data_hash: str = db.Column(db.String(255), nullable=False, index=True) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/bpmn_process_definition_relationship.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/bpmn_process_definition_relationship.py index 5ab4a7a21..096570d84 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/bpmn_process_definition_relationship.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/bpmn_process_definition_relationship.py @@ -22,8 +22,8 @@ class BpmnProcessDefinitionRelationshipModel(SpiffworkflowBaseDBModel): id: int = db.Column(db.Integer, primary_key=True) bpmn_process_definition_parent_id: int = db.Column( - ForeignKey(BpmnProcessDefinitionModel.id), nullable=False # type: ignore + ForeignKey(BpmnProcessDefinitionModel.id), nullable=False, index=True # type: ignore ) bpmn_process_definition_child_id: int = db.Column( - ForeignKey(BpmnProcessDefinitionModel.id), nullable=False # type: ignore + ForeignKey(BpmnProcessDefinitionModel.id), nullable=False, index=True # type: ignore ) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/human_task.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/human_task.py index c747930db..4e0d2ffcb 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/human_task.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/human_task.py @@ -29,13 +29,13 @@ class HumanTaskModel(SpiffworkflowBaseDBModel): __tablename__ = "human_task" id: int = db.Column(db.Integer, primary_key=True) - process_instance_id: int = db.Column(ForeignKey(ProcessInstanceModel.id), nullable=False) # type: ignore - lane_assignment_id: int | None = db.Column(ForeignKey(GroupModel.id)) - completed_by_user_id: int = db.Column(ForeignKey(UserModel.id), nullable=True) # type: ignore + process_instance_id: int = db.Column(ForeignKey(ProcessInstanceModel.id), nullable=False, index=True) # type: ignore + lane_assignment_id: int | None = db.Column(ForeignKey(GroupModel.id), index=True) + completed_by_user_id: int = db.Column(ForeignKey(UserModel.id), nullable=True, index=True) # type: ignore completed_by_user = relationship("UserModel", foreign_keys=[completed_by_user_id], viewonly=True) - actual_owner_id: int = db.Column(ForeignKey(UserModel.id)) # type: ignore + actual_owner_id: int = db.Column(ForeignKey(UserModel.id), index=True) # type: ignore # actual_owner: RelationshipProperty[UserModel] = relationship(UserModel) form_file_name: str | None = db.Column(db.String(50)) @@ -45,7 +45,7 @@ class HumanTaskModel(SpiffworkflowBaseDBModel): created_at_in_seconds: int = db.Column(db.Integer) # task_id came first which is why it's a string and task_model_id is the int and foreignkey - task_model_id: int = db.Column(ForeignKey(TaskModel.id), nullable=True) # type: ignore + task_model_id: int = db.Column(ForeignKey(TaskModel.id), nullable=True, index=True) # type: ignore task_id: str = db.Column(db.String(50)) task_name: str = db.Column(db.String(255)) task_title: str = db.Column(db.String(50)) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/message_instance.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/message_instance.py index 31de7cd4e..3a4735acb 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/message_instance.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/message_instance.py @@ -47,7 +47,7 @@ class MessageInstanceModel(SpiffworkflowBaseDBModel): __tablename__ = "message_instance" id: int = db.Column(db.Integer, primary_key=True) - process_instance_id: int = db.Column(ForeignKey(ProcessInstanceModel.id), nullable=True) # type: ignore + process_instance_id: int = db.Column(ForeignKey(ProcessInstanceModel.id), nullable=True, index=True) # type: ignore name: str = db.Column(db.String(255)) message_type: str = db.Column(db.String(20), nullable=False) # Only Send Messages have a payload @@ -55,7 +55,7 @@ class MessageInstanceModel(SpiffworkflowBaseDBModel): # The correlation keys of the process at the time the message was created. correlation_keys: dict = db.Column(db.JSON) status: str = db.Column(db.String(20), nullable=False, default="ready") - user_id: int = db.Column(ForeignKey(UserModel.id), nullable=True) # type: ignore + user_id: int = db.Column(ForeignKey(UserModel.id), nullable=True, index=True) # type: ignore user = relationship("UserModel") counterpart_id: int = db.Column( db.Integer diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/permission_assignment.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/permission_assignment.py index 01d4b9354..f77e0c0e6 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/permission_assignment.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/permission_assignment.py @@ -46,8 +46,8 @@ class PermissionAssignmentModel(SpiffworkflowBaseDBModel): ), ) id = db.Column(db.Integer, primary_key=True) - principal_id = db.Column(ForeignKey(PrincipalModel.id), nullable=False) - permission_target_id = db.Column(ForeignKey(PermissionTargetModel.id), nullable=False) # type: ignore + principal_id = db.Column(ForeignKey(PrincipalModel.id), nullable=False, index=True) + permission_target_id = db.Column(ForeignKey(PermissionTargetModel.id), nullable=False, index=True) # type: ignore grant_type = db.Column(db.String(50), nullable=False) permission = db.Column(db.String(50), nullable=False) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance.py index 138aac26f..e312d2cda 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance.py @@ -57,14 +57,14 @@ class ProcessInstanceModel(SpiffworkflowBaseDBModel): id: int = db.Column(db.Integer, primary_key=True) process_model_identifier: str = db.Column(db.String(255), nullable=False, index=True) process_model_display_name: str = db.Column(db.String(255), nullable=False, index=True) - process_initiator_id: int = db.Column(ForeignKey(UserModel.id), nullable=False) # type: ignore + process_initiator_id: int = db.Column(ForeignKey(UserModel.id), nullable=False, index=True) # type: ignore process_initiator = relationship("UserModel") bpmn_process_definition_id: int | None = db.Column( ForeignKey(BpmnProcessDefinitionModel.id), nullable=True, index=True # type: ignore ) bpmn_process_definition = relationship(BpmnProcessDefinitionModel) - bpmn_process_id: int | None = db.Column(ForeignKey(BpmnProcessModel.id), nullable=True) # type: ignore + bpmn_process_id: int | None = db.Column(ForeignKey(BpmnProcessModel.id), nullable=True, index=True) # type: ignore bpmn_process = relationship(BpmnProcessModel, cascade="delete") tasks = relationship("TaskModel", cascade="delete") # type: ignore process_instance_events = relationship("ProcessInstanceEventModel", cascade="delete") # type: ignore diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_event.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_event.py index 560abffd2..fe920b57e 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_event.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_event.py @@ -30,7 +30,7 @@ class ProcessInstanceEventModel(SpiffworkflowBaseDBModel): # use task guid so we can bulk insert without worrying about whether or not the task has an id yet task_guid: str | None = db.Column(db.String(36), nullable=True, index=True) - process_instance_id: int = db.Column(ForeignKey("process_instance.id"), nullable=False) + process_instance_id: int = db.Column(ForeignKey("process_instance.id"), nullable=False, index=True) event_type: str = db.Column(db.String(50), nullable=False, index=True) timestamp: float = db.Column(db.DECIMAL(17, 6), nullable=False, index=True) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_file_data.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_file_data.py index 5d3567ad6..08cc40488 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_file_data.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_file_data.py @@ -17,7 +17,7 @@ class ProcessInstanceFileDataModel(SpiffworkflowBaseDBModel): __tablename__ = "process_instance_file_data" id: int = db.Column(db.Integer, primary_key=True) - process_instance_id: int = db.Column(ForeignKey(ProcessInstanceModel.id), nullable=False) # type: ignore + process_instance_id: int = db.Column(ForeignKey(ProcessInstanceModel.id), nullable=False, index=True) # type: ignore identifier: str = db.Column(db.String(255), nullable=False) list_index: Optional[int] = db.Column(db.Integer, nullable=True) mimetype: str = db.Column(db.String(255), nullable=False) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_metadata.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_metadata.py index b5e88ff88..1bd3c436b 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_metadata.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_metadata.py @@ -16,7 +16,7 @@ class ProcessInstanceMetadataModel(SpiffworkflowBaseDBModel): __table_args__ = (db.UniqueConstraint("process_instance_id", "key", name="process_instance_metadata_unique"),) id: int = db.Column(db.Integer, primary_key=True) - process_instance_id: int = db.Column(ForeignKey(ProcessInstanceModel.id), nullable=False) # type: ignore + process_instance_id: int = db.Column(ForeignKey(ProcessInstanceModel.id), nullable=False, index=True) # type: ignore key: str = db.Column(db.String(255), nullable=False, index=True) value: str = db.Column(db.String(255), nullable=False) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_queue.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_queue.py index c0cb9f273..9bf63c001 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_queue.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_queue.py @@ -17,7 +17,7 @@ class ProcessInstanceQueueModel(SpiffworkflowBaseDBModel): id: int = db.Column(db.Integer, primary_key=True) process_instance_id: int = db.Column( - ForeignKey(ProcessInstanceModel.id), index=True, unique=True, nullable=False # type: ignore + ForeignKey(ProcessInstanceModel.id), index=True, unique=True, nullable=False, index=True # type: ignore ) run_at_in_seconds: int = db.Column(db.Integer) priority: int = db.Column(db.Integer) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/secret_model.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/secret_model.py index 026831eda..41f72e1b1 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/secret_model.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/secret_model.py @@ -17,7 +17,7 @@ class SecretModel(SpiffworkflowBaseDBModel): id: int = db.Column(db.Integer, primary_key=True) key: str = db.Column(db.String(50), unique=True, nullable=False) value: str = db.Column(db.Text(), nullable=False) - user_id: int = db.Column(ForeignKey(UserModel.id), nullable=False) # type: ignore + user_id: int = db.Column(ForeignKey(UserModel.id), nullable=False, index=True) # type: ignore updated_at_in_seconds: int = db.Column(db.Integer) created_at_in_seconds: int = db.Column(db.Integer) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/spiff_step_details.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/spiff_step_details.py index beed8da77..2568d7424 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/spiff_step_details.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/spiff_step_details.py @@ -19,7 +19,7 @@ class SpiffStepDetailsModel(SpiffworkflowBaseDBModel): __table_args__ = (UniqueConstraint("process_instance_id", "spiff_step", name="process_instance_id_spiff_step"),) id: int = db.Column(db.Integer, primary_key=True) - process_instance_id: int = db.Column(ForeignKey(ProcessInstanceModel.id), nullable=False) # type: ignore + process_instance_id: int = db.Column(ForeignKey(ProcessInstanceModel.id), nullable=False, index=True) # type: ignore spiff_step: int = db.Column(db.Integer, nullable=False) task_json: dict = deferred(db.Column(db.JSON, nullable=False)) # type: ignore task_id: str = db.Column(db.String(50), nullable=False) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/task.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/task.py index 980580716..cbd1ec65d 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/task.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/task.py @@ -49,12 +49,12 @@ class TaskModel(SpiffworkflowBaseDBModel): __tablename__ = "task" id: int = db.Column(db.Integer, primary_key=True) guid: str = db.Column(db.String(36), nullable=False, unique=True, index=True) - bpmn_process_id: int = db.Column(ForeignKey(BpmnProcessModel.id), nullable=False) # type: ignore + bpmn_process_id: int = db.Column(ForeignKey(BpmnProcessModel.id), nullable=False, index=True) # type: ignore bpmn_process = relationship(BpmnProcessModel, back_populates="tasks") - process_instance_id: int = db.Column(ForeignKey("process_instance.id"), nullable=False) + process_instance_id: int = db.Column(ForeignKey("process_instance.id"), nullable=False, index=True) # find this by looking up the "workflow_name" and "task_spec" from the properties_json - task_definition_id: int = db.Column(ForeignKey(TaskDefinitionModel.id), nullable=False) # type: ignore + task_definition_id: int = db.Column(ForeignKey(TaskDefinitionModel.id), nullable=False, index=True) # type: ignore task_definition = relationship("TaskDefinitionModel") state: str = db.Column(db.String(10), nullable=False) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/task_definition.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/task_definition.py index 893331a8f..791e1deab 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/task_definition.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/task_definition.py @@ -23,7 +23,7 @@ class TaskDefinitionModel(SpiffworkflowBaseDBModel): id: int = db.Column(db.Integer, primary_key=True) bpmn_process_definition_id: int = db.Column( - ForeignKey(BpmnProcessDefinitionModel.id), nullable=False # type: ignore + ForeignKey(BpmnProcessDefinitionModel.id), nullable=False, index=True # type: ignore ) bpmn_process_definition = relationship(BpmnProcessDefinitionModel) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/user_group_assignment.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/user_group_assignment.py index 45467a81f..83ceb0674 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/user_group_assignment.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/user_group_assignment.py @@ -15,8 +15,8 @@ class UserGroupAssignmentModel(SpiffworkflowBaseDBModel): __table_args__ = (db.UniqueConstraint("user_id", "group_id", name="user_group_assignment_unique"),) id = db.Column(db.Integer, primary_key=True) - user_id = db.Column(ForeignKey(UserModel.id), nullable=False) # type: ignore - group_id = db.Column(ForeignKey(GroupModel.id), nullable=False) + user_id = db.Column(ForeignKey(UserModel.id), nullable=False, index=True) # type: ignore + group_id = db.Column(ForeignKey(GroupModel.id), nullable=False, index=True) group = relationship("GroupModel", overlaps="groups,user_group_assignments,users") # type: ignore user = relationship("UserModel", overlaps="groups,user_group_assignments,users") # type: ignore diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/user_group_assignment_waiting.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/user_group_assignment_waiting.py index 5616728bd..9b0193915 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/user_group_assignment_waiting.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/user_group_assignment_waiting.py @@ -19,7 +19,7 @@ class UserGroupAssignmentWaitingModel(SpiffworkflowBaseDBModel): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(255), nullable=False) - group_id = db.Column(ForeignKey(GroupModel.id), nullable=False) + group_id = db.Column(ForeignKey(GroupModel.id), nullable=False, index=True) group = relationship("GroupModel", overlaps="groups,user_group_assignments_waiting,users") # type: ignore