This page documents the workflow deployment system, versioning strategy, and the technical implementation of draft vs. deployed states. It covers how Sim Studio ensures execution stability by separating mutable development environments from immutable production snapshots.
Workflows in Sim Studio exist in two primary states: draft (the mutable working version) and deployed (an immutable published snapshot). The deployment system ensures production triggers (API calls, webhooks, schedules) run against stable versions, while interactive development uses the latest draft state.
Key Concepts:
workflow_blocks, workflow_edges, etc.) apps/sim/lib/workflows/persistence/utils.ts11workflow_deployment_version table apps/sim/app/api/workflows/[id]/deploy/route.ts:6-12.isActive = true for a given workflow apps/sim/app/api/workflows/[id]/deploy/route.ts:33-42.The deployment process transitions a workflow from a draft state to a live, executable version. This involves state normalization, trigger synchronization, and versioning.
Sources: apps/sim/app/api/workflows/[id]/deploy/route.ts:63-114, apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/components/deploy-modal/deploy-modal.tsx:174-176, apps/sim/lib/workflows/utils.ts1-11
The system uses different loading strategies depending on whether the execution context requires the "Live" version or the "Draft" version.
| Context | Function | Source Table |
|---|---|---|
| Draft | loadWorkflowFromNormalizedTables | workflow_blocks, workflow_edges, workflow_loops, workflow_parallels |
| Deployed | loadDeployedWorkflowState | workflow_deployment_version (where isActive = true) |
Sources: apps/sim/app/api/workflows/[id]/deployed/route.ts:19-57, apps/sim/app/api/workflows/[id]/deploy/route.ts:19-61, apps/sim/hooks/queries/deployments.ts99-112
The UI provides visual indicators when the draft state has diverged from the deployed state, prompting the user to redeploy.
The hasWorkflowChanged function compares the current WorkflowState against the deployedState using deep normalization and comparison logic apps/sim/lib/workflows/comparison/compare.ts25-30 This comparison includes:
subBlocks values apps/sim/lib/workflows/comparison/compare.ts143-174The DeployModal component manages the version history and deployment actions apps/sim/app/workspace/[workspaceId]/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/components/deploy-modal/deploy-modal.tsx:78-86.
useDeploymentVersions apps/sim/hooks/queries/deployments.ts161-169useActivateDeploymentVersion apps/sim/hooks/queries/deployments.ts29-35performFullUndeploy apps/sim/app/api/workflows/[id]/deploy/route.ts:159-192.Sources: apps/sim/lib/workflows/comparison/compare.ts25-285 apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/components/deploy-modal/deploy-modal.tsx:78-176, apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/hooks/use-change-detection.ts:21-74
To ensure debuggability and auditability, Sim Studio captures a state snapshot for every execution.
The SnapshotService manages these snapshots with deduplication to save storage apps/sim/lib/logs/execution/snapshot/service.ts18-30
computeStateHash generates a SHA-256 hash of the normalized workflow state apps/sim/lib/logs/execution/snapshot/service.ts85-89workflow_execution_snapshots and linked to logs via stateSnapshotId apps/sim/lib/logs/execution/snapshot/service.ts3-6cleanupOrphanedSnapshots removes old snapshots that are no longer referenced by execution logs apps/sim/lib/logs/execution/snapshot/service.ts91-114Sources: apps/sim/lib/logs/execution/snapshot/service.ts1-117 apps/sim/lib/workflows/comparison/normalize.ts1-92
/api/workflows/[id]/deployReturns deployment metadata, including isDeployed, deployedAt, and the needsRedeployment flag computed by checkNeedsRedeployment apps/sim/app/api/workflows/[id]/deploy/route.ts:19-61.
/api/workflows/[id]/deployTriggers a new deployment. This function performs validation, snapshots the state, creates the version record, and synchronizes triggers via performFullDeploy apps/sim/app/api/workflows/[id]/deploy/route.ts:63-114.
/api/workflows/[id]/deployedFetches the full state snapshot of the currently active deployment apps/sim/app/api/workflows/[id]/deployed/route.ts:19-63.
/api/workflows/[id]/deployRemoves the deployment. This calls performFullUndeploy to clean up schedules and webhooks apps/sim/app/api/workflows/[id]/deploy/route.ts:159-192.
Sources: apps/sim/app/api/workflows/[id]/deploy/route.ts:1-192, apps/sim/app/api/workflows/[id]/deployed/route.ts:1-63, apps/sim/hooks/queries/deployments.ts1-169
Refresh this wiki