diff --git a/spiffworkflow-backend/migrations/versions/907bcf0c3d75_.py b/spiffworkflow-backend/migrations/versions/22212a7d6505_.py similarity index 98% rename from spiffworkflow-backend/migrations/versions/907bcf0c3d75_.py rename to spiffworkflow-backend/migrations/versions/22212a7d6505_.py index 552afe48..f662f583 100644 --- a/spiffworkflow-backend/migrations/versions/907bcf0c3d75_.py +++ b/spiffworkflow-backend/migrations/versions/22212a7d6505_.py @@ -1,8 +1,8 @@ """empty message -Revision ID: 907bcf0c3d75 +Revision ID: 22212a7d6505 Revises: -Create Date: 2022-12-28 13:52:13.030028 +Create Date: 2023-01-23 10:59:17.365694 """ from alembic import op @@ -10,7 +10,7 @@ import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = '907bcf0c3d75' +revision = '22212a7d6505' down_revision = None branch_labels = None depends_on = None @@ -269,7 +269,8 @@ def upgrade(): sa.Column('task_json', sa.JSON(), nullable=False), sa.Column('timestamp', sa.DECIMAL(precision=17, scale=6), nullable=False), sa.ForeignKeyConstraint(['process_instance_id'], ['process_instance.id'], ), - sa.PrimaryKeyConstraint('id') + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('process_instance_id', 'spiff_step', name='process_instance_id_spiff_step') ) op.create_table('human_task_user', sa.Column('id', sa.Integer(), nullable=False), 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 50bf4520..0d0e7b44 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/spiff_step_details.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/spiff_step_details.py @@ -2,6 +2,7 @@ from dataclasses import dataclass from sqlalchemy import ForeignKey +from sqlalchemy import UniqueConstraint from sqlalchemy.orm import deferred from spiffworkflow_backend.models.db import db @@ -14,17 +15,16 @@ class SpiffStepDetailsModel(SpiffworkflowBaseDBModel): """SpiffStepDetailsModel.""" __tablename__ = "spiff_step_details" + __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 ) - # human_task_id: int = db.Column( - # ForeignKey(HumanTaskModel.id) # type: ignore - # ) spiff_step: int = db.Column(db.Integer, nullable=False) task_json: dict = deferred(db.Column(db.JSON, nullable=False)) # type: ignore timestamp: float = db.Column(db.DECIMAL(17, 6), nullable=False) - # completed_by_user_id: int = db.Column(db.Integer, nullable=True) - # lane_assignment_id: Optional[int] = db.Column( - # ForeignKey(GroupModel.id), nullable=True - # )