Skip to content

The open alternative to Salesforce, designed for AI.

fix(workflow): skip orphan core workflows in the 2.42 published pointer check (#26458)

Thomas Trompette2f1fd83ef581
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-42/2-42-workspace-command-1789719131001-backfill-workflow-execution-core-ids.command.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-42/2-42-workspace-command-1789719131001-backfill-workflow-execution-core-ids.command.ts
index 9028d8ad359..d0c909153fc 100644
--- a/packages/twenty-server/src/database/commands/upgrade-version-command/2-42/2-42-workspace-command-1789719131001-backfill-workflow-execution-core-ids.command.ts
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-42/2-42-workspace-command-1789719131001-backfill-workflow-execution-core-ids.command.ts
@@ -199,6 +199,10 @@ export class BackfillWorkflowExecutionCoreIdsCommand extends ProvisionedWorkspac
LEFT JOIN core."workflowVersion" cv ON cv."workspaceId" = cw."workspaceId"
AND cv."workspaceWorkflowVersionId" = cw."lastPublishedVersionId"
WHERE cw."workspaceId" = $1 AND cw."lastPublishedVersionId" IS NOT NULL
+ AND EXISTS (
+ SELECT 1 FROM "${schema}"."workflow" w
+ WHERE (w."coreWorkflowId" = cw.id OR w.id = cw."workspaceWorkflowId") AND w."deletedAt" IS NULL
+ )
AND (cv.id IS NULL OR cv."coreWorkflowId" <> cw.id OR
(cw."lastPublishedCoreWorkflowVersionId" IS NOT NULL AND cw."lastPublishedCoreWorkflowVersionId" <> cv.id))
LIMIT 10`,