Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor: use EnumText for WorkflowAppLog.created_from and WorkflowArchiveLog columns (#33954)
tmimmanuel20fc69ae7fe9
diff --git a/api/core/app/apps/workflow/generate_task_pipeline.py b/api/core/app/apps/workflow/generate_task_pipeline.pyindex 96dd8c5445f..bd6e2a0302e 100644--- a/api/core/app/apps/workflow/generate_task_pipeline.py+++ b/api/core/app/apps/workflow/generate_task_pipeline.py@@ -705,7 +705,7 @@ class WorkflowAppGenerateTaskPipeline(GraphRuntimeStateSupport):app_id=self._application_generate_entity.app_config.app_id,workflow_id=self._workflow.id,workflow_run_id=workflow_run_id,- created_from=created_from.value,+ created_from=created_from,created_by_role=self._created_by_role,created_by=self._user_id,)diff --git a/api/models/workflow.py b/api/models/workflow.pyindex 6e8dda429db..334ec420587 100644--- a/api/models/workflow.py+++ b/api/models/workflow.py@@ -1221,7 +1221,9 @@ class WorkflowAppLog(TypeBase):app_id: Mapped[str] = mapped_column(StringUUID)workflow_id: Mapped[str] = mapped_column(StringUUID, nullable=False)workflow_run_id: Mapped[str] = mapped_column(StringUUID)- created_from: Mapped[str] = mapped_column(String(255), nullable=False)+ created_from: Mapped[WorkflowAppLogCreatedFrom] = mapped_column(+ EnumText(WorkflowAppLogCreatedFrom, length=255), nullable=False+ )created_by_role: Mapped[CreatorUserRole] = mapped_column(EnumText(CreatorUserRole, length=255), nullable=False)created_by: Mapped[str] = mapped_column(StringUUID, nullable=False)created_at: Mapped[datetime] = mapped_column(@@ -1301,10 +1303,14 @@ class WorkflowArchiveLog(TypeBase):log_id: Mapped[str | None] = mapped_column(StringUUID, nullable=True)log_created_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)- log_created_from: Mapped[str | None] = mapped_column(String(255), nullable=True)+ log_created_from: Mapped[WorkflowAppLogCreatedFrom | None] = mapped_column(+ EnumText(WorkflowAppLogCreatedFrom, length=255), nullable=True+ )run_version: Mapped[str] = mapped_column(String(255), nullable=False)- run_status: Mapped[str] = mapped_column(String(255), nullable=False)+ run_status: Mapped[WorkflowExecutionStatus] = mapped_column(+ EnumText(WorkflowExecutionStatus, length=255), nullable=False+ )run_triggered_from: Mapped[WorkflowRunTriggeredFrom] = mapped_column(EnumText(WorkflowRunTriggeredFrom, length=255), nullable=False)diff --git a/api/tasks/trigger_processing_tasks.py b/api/tasks/trigger_processing_tasks.pyindex 75ae1f63169..f8c79648053 100644--- a/api/tasks/trigger_processing_tasks.py+++ b/api/tasks/trigger_processing_tasks.py@@ -179,7 +179,7 @@ def _record_trigger_failure_log(app_id=workflow.app_id,workflow_id=workflow.id,workflow_run_id=workflow_run.id,- created_from=WorkflowAppLogCreatedFrom.SERVICE_API.value,+ created_from=WorkflowAppLogCreatedFrom.SERVICE_API,created_by_role=created_by_role,created_by=created_by,)diff --git a/api/tests/test_containers_integration_tests/repositories/test_sqlalchemy_api_workflow_run_repository.py b/api/tests/test_containers_integration_tests/repositories/test_sqlalchemy_api_workflow_run_repository.pyindex c3ed79656ff..49b370990aa 100644--- a/api/tests/test_containers_integration_tests/repositories/test_sqlalchemy_api_workflow_run_repository.py+++ b/api/tests/test_containers_integration_tests/repositories/test_sqlalchemy_api_workflow_run_repository.py@@ -27,7 +27,7 @@ from models.human_input import (HumanInputFormRecipient,RecipientType,)-from models.workflow import WorkflowAppLog, WorkflowPause, WorkflowPauseReason, WorkflowRun+from models.workflow import WorkflowAppLog, WorkflowAppLogCreatedFrom, WorkflowPause, WorkflowPauseReason, WorkflowRunfrom repositories.entities.workflow_pause import WorkflowPauseEntityfrom repositories.sqlalchemy_api_workflow_run_repository import (DifyAPISQLAlchemyWorkflowRunRepository,@@ -218,7 +218,7 @@ class TestDeleteRunsWithRelated:app_id=test_scope.app_id,workflow_id=test_scope.workflow_id,workflow_run_id=workflow_run.id,- created_from="service-api",+ created_from=WorkflowAppLogCreatedFrom.SERVICE_API,created_by_role=CreatorUserRole.ACCOUNT,created_by=test_scope.user_id,)@@ -278,7 +278,7 @@ class TestCountRunsWithRelated:app_id=test_scope.app_id,workflow_id=test_scope.workflow_id,workflow_run_id=workflow_run.id,- created_from="service-api",+ created_from=WorkflowAppLogCreatedFrom.SERVICE_API,created_by_role=CreatorUserRole.ACCOUNT,created_by=test_scope.user_id,)diff --git a/api/tests/test_containers_integration_tests/services/test_workflow_app_service.py b/api/tests/test_containers_integration_tests/services/test_workflow_app_service.pyindex 8ab8df2a5a8..84ce6364df0 100644--- a/api/tests/test_containers_integration_tests/services/test_workflow_app_service.py+++ b/api/tests/test_containers_integration_tests/services/test_workflow_app_service.py@@ -10,6 +10,7 @@ from sqlalchemy.orm import Sessionfrom dify_graph.entities.workflow_execution import WorkflowExecutionStatusfrom models import EndUser, Workflow, WorkflowAppLog, WorkflowRunfrom models.enums import CreatorUserRole+from models.workflow import WorkflowAppLogCreatedFromfrom services.account_service import AccountService, TenantService# Delay import of AppService to avoid circular dependency@@ -221,7 +222,7 @@ class TestWorkflowAppService:app_id=app.id,workflow_id=workflow.id,workflow_run_id=workflow_run.id,- created_from="service-api",+ created_from=WorkflowAppLogCreatedFrom.SERVICE_API,created_by_role=CreatorUserRole.ACCOUNT,created_by=account.id,)@@ -357,7 +358,7 @@ class TestWorkflowAppService:app_id=app.id,workflow_id=workflow.id,workflow_run_id=workflow_run_1.id,- created_from="service-api",+ created_from=WorkflowAppLogCreatedFrom.SERVICE_API,created_by_role=CreatorUserRole.ACCOUNT,created_by=account.id,)@@ -399,7 +400,7 @@ class TestWorkflowAppService:app_id=app.id,workflow_id=workflow.id,workflow_run_id=workflow_run_2.id,- created_from="service-api",+ created_from=WorkflowAppLogCreatedFrom.SERVICE_API,created_by_role=CreatorUserRole.ACCOUNT,created_by=account.id,)@@ -441,7 +442,7 @@ class TestWorkflowAppService:app_id=app.id,workflow_id=workflow.id,workflow_run_id=workflow_run_4.id,- created_from="service-api",+ created_from=WorkflowAppLogCreatedFrom.SERVICE_API,created_by_role=CreatorUserRole.ACCOUNT,created_by=account.id,)@@ -521,7 +522,7 @@ class TestWorkflowAppService:app_id=app.id,workflow_id=workflow.id,workflow_run_id=workflow_run.id,- created_from="service-api",+ created_from=WorkflowAppLogCreatedFrom.SERVICE_API,created_by_role=CreatorUserRole.ACCOUNT,created_by=account.id,)@@ -627,7 +628,7 @@ class TestWorkflowAppService:app_id=app.id,workflow_id=workflow.id,workflow_run_id=workflow_run.id,- created_from="service-api",+ created_from=WorkflowAppLogCreatedFrom.SERVICE_API,created_by_role=CreatorUserRole.ACCOUNT,created_by=account.id,)@@ -732,7 +733,7 @@ class TestWorkflowAppService:app_id=app.id,workflow_id=workflow.id,workflow_run_id=workflow_run.id,- created_from="service-api",+ created_from=WorkflowAppLogCreatedFrom.SERVICE_API,created_by_role=CreatorUserRole.ACCOUNT,created_by=account.id,)@@ -860,7 +861,7 @@ class TestWorkflowAppService:app_id=app.id,workflow_id=workflow.id,workflow_run_id=workflow_run.id,- created_from="service-api",+ created_from=WorkflowAppLogCreatedFrom.SERVICE_API,created_by_role=CreatorUserRole.ACCOUNT,created_by=account.id,)@@ -902,7 +903,7 @@ class TestWorkflowAppService:app_id=app.id,workflow_id=workflow.id,workflow_run_id=workflow_run.id,- created_from="web-app",+ created_from=WorkflowAppLogCreatedFrom.WEB_APP,created_by_role=CreatorUserRole.END_USER,created_by=end_user.id,)@@ -1037,7 +1038,7 @@ class TestWorkflowAppService:app_id=app.id,workflow_id=workflow.id,workflow_run_id=workflow_run.id,- created_from="service-api",+ created_from=WorkflowAppLogCreatedFrom.SERVICE_API,created_by_role=CreatorUserRole.ACCOUNT,created_by=account.id,)@@ -1125,7 +1126,7 @@ class TestWorkflowAppService:app_id=app.id,workflow_id=workflow.id,workflow_run_id=workflow_run.id,- created_from="service-api",+ created_from=WorkflowAppLogCreatedFrom.SERVICE_API,created_by_role=CreatorUserRole.ACCOUNT,created_by=account.id,)@@ -1279,7 +1280,7 @@ class TestWorkflowAppService:app_id=app.id,workflow_id=workflow.id,workflow_run_id=workflow_run.id,- created_from="service-api",+ created_from=WorkflowAppLogCreatedFrom.SERVICE_API,created_by_role=CreatorUserRole.ACCOUNT,created_by=account.id,)@@ -1379,7 +1380,7 @@ class TestWorkflowAppService:app_id=app.id,workflow_id=workflow.id,workflow_run_id=workflow_run.id,- created_from="service-api",+ created_from=WorkflowAppLogCreatedFrom.SERVICE_API,created_by_role=CreatorUserRole.ACCOUNT,created_by=account.id,)@@ -1481,7 +1482,7 @@ class TestWorkflowAppService:app_id=app.id,workflow_id=workflow.id,workflow_run_id=workflow_run.id,- created_from="service-api",+ created_from=WorkflowAppLogCreatedFrom.SERVICE_API,created_by_role=CreatorUserRole.ACCOUNT,created_by=account.id,)