feat(api): auto-delete WorkflowDraftVariable when app is deleted (#23737)

This commit introduces a background task that automatically deletes `WorkflowDraftVariable` records when
their associated workflow apps are deleted.

Additionally, it adds a new cleanup script
`cleanup-orphaned-draft-variables` to remove existing orphaned draft variables from the database.
This commit is contained in:
QuantumGhost
2025-08-13 11:13:08 +08:00
committed by GitHub
parent 854c1aa37d
commit e600070a61
7 changed files with 665 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ from dify_app import DifyApp
def init_app(app: DifyApp):
from commands import (
add_qdrant_index,
cleanup_orphaned_draft_variables,
clear_free_plan_tenant_expired_logs,
clear_orphaned_file_records,
convert_to_agent_apps,
@@ -42,6 +43,7 @@ def init_app(app: DifyApp):
clear_orphaned_file_records,
remove_orphaned_files_on_storage,
setup_system_tool_oauth_client,
cleanup_orphaned_draft_variables,
]
for cmd in cmds_to_register:
app.cli.add_command(cmd)