@@ -8,8 +8,9 @@ class Workflow(Base):
88 __tablename__ = "workflow"
99
1010 id = Column (Integer , primary_key = True , index = True )
11- name = Column (String , index = True )
12- description = Column (String , index = True , nullable = True )
11+ name = Column (String (32 ), index = True )
12+
13+ description = Column (String (512 ), index = True , nullable = True )
1314 owner_id = Column (Integer , ForeignKey ("user.id" , ondelete = "CASCADE" ))
1415
1516 nodes = relationship (
@@ -30,6 +31,8 @@ class WorkflowNode(Base):
3031 Integer , ForeignKey ("workflow.id" , ondelete = "CASCADE" )
3132 )
3233
34+ interaction_id = Column (Integer , ForeignKey ("interaction.id" ))
35+
3336 config = relationship (
3437 "WorkflowNodeConfig" ,
3538 back_populates = "node" ,
@@ -66,37 +69,15 @@ class WorkflowNodeConfig(Base):
6669 node_id = Column (
6770 Integer , ForeignKey ("workflow_node.id" , ondelete = "CASCADE" )
6871 )
69- key = Column (String , index = True )
70- value = Column (String , index = True )
72+
73+ key = Column (String (32 ), index = True )
74+ value = Column (String (128 ), index = True )
7175
7276 node = relationship ("WorkflowNode" , back_populates = "config" )
7377
7478
7579class WorkflowEdge (Base ):
76- """
77- Represents a directed connection between two WorkflowNode entities in the workflow graph.
78-
79- This SQLAlchemy ORM model stores edges that originate from one node and point to another.
80- A uniqueness constraint on `to_node_id` guarantees that a node can have at most one
81- incoming edge, while a single node may emit multiple outgoing edges. Deleting a node
82- cascades to its associated edges.
83-
84- Attributes:
85- id (int): Primary key identifier of the edge.
86- from_node_id (int): Foreign key to the source WorkflowNode (workflow_node.id), cascades on delete.
87- to_node_id (int): Foreign key to the target WorkflowNode (workflow_node.id), cascades on delete.
88- Uniquely constrained to enforce at most one incoming edge per node.
89-
90- Relationships:
91- from_node (WorkflowNode): Source node; back-populates 'outgoing_edges'.
92- to_node (WorkflowNode): Target node; back-populates 'incoming_edge'.
93-
94- Constraints and behavior:
95- - Directed edge: from_node -> to_node.
96- - ondelete="CASCADE" ensures edges are removed when their associated nodes are deleted.
97- - Unique to_node_id enforces in-degree <= 1, enabling a one-to-many (source->edges) and
98- one-to-one (target<-edge) structure.
99- """
80+ """Represents a directed connection between two WorkflowNode its graph."""
10081
10182 __tablename__ = "workflow_edge"
10283
0 commit comments