From dea67a85a98bdd162aa5b5425d79c23f9969f1ca Mon Sep 17 00:00:00 2001 From: QuantumGhost Date: Fri, 6 Jun 2025 18:36:12 +0800 Subject: [PATCH] feat(api): Allow the `node_execution_id` field to be `NULL`. --- ...ee6_workflow_draft_varaibles_add_node_execution_id.py | 2 +- api/models/workflow.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/api/migrations/versions/2025_06_06_1424-4474872b0ee6_workflow_draft_varaibles_add_node_execution_id.py b/api/migrations/versions/2025_06_06_1424-4474872b0ee6_workflow_draft_varaibles_add_node_execution_id.py index 6289241ad0..d7a5d116c9 100644 --- a/api/migrations/versions/2025_06_06_1424-4474872b0ee6_workflow_draft_varaibles_add_node_execution_id.py +++ b/api/migrations/versions/2025_06_06_1424-4474872b0ee6_workflow_draft_varaibles_add_node_execution_id.py @@ -34,7 +34,7 @@ def upgrade(): ) with op.batch_alter_table('workflow_draft_variables', schema=None) as batch_op: - batch_op.add_column(sa.Column('node_execution_id', models.types.StringUUID(), nullable=False)) + batch_op.add_column(sa.Column('node_execution_id', models.types.StringUUID(), nullable=True)) # ### end Alembic commands ### diff --git a/api/models/workflow.py b/api/models/workflow.py index 61845fcb33..2fff045543 100644 --- a/api/models/workflow.py +++ b/api/models/workflow.py @@ -919,7 +919,14 @@ class WorkflowDraftVariable(Base): # The `node_execution_id` field identifies the workflow node execution that created this variable. # It corresponds to the `id` field in the `WorkflowNodeExecutionModel` model. - node_execution_id: Mapped[str] = mapped_column(StringUUID, nullable=False) + # + # This field is not `None` for system variables and node variables, and is `None` + # for conversation variables. + node_execution_id: Mapped[str | None] = mapped_column( + StringUUID, + nullable=True, + default=None, + ) def get_selector(self) -> list[str]: selector = json.loads(self.selector)