Skip to main content

Workflow Automation

Overview

This domain has 2 tables: workflow stores the current workflow definition as JSONB in the definition column, along with compiled reference data in compiled_refs, and workflow_version stores a snapshot of the definition on every change so earlier versions can be inspected or restored

Table workflow

ColumnTypeNullableDefaultDescription
idSERIALNOnextval(...)Primary key
nameVARCHAR(255)NO-Workflow name
descriptionTEXTYES-Workflow description
statusVARCHAR(20)NO'draft'Workflow status
definitionJSONBNO-Full workflow definition (nodes and connections)
compiled_refsJSONBYES-References compiled from the definition for runtime use
line_oa_idINTEGERNO-LINE OA the workflow belongs to
organization_idINTEGERNO-Organization that owns the workflow
created_byINTEGERYES-Creator (user id)
updated_byINTEGERYES-Last updater (user id)
created_dateTIMESTAMPTZ(3)NOnow()Creation timestamp
updated_dateTIMESTAMPTZ(3)YES-Last update timestamp
deleted_dateTIMESTAMPTZ(3)YES-Deletion timestamp (soft delete)

Table workflow_version

ColumnTypeNullableDefaultDescription
idSERIALNOnextval(...)Primary key
workflow_idINTEGERNO-Workflow this snapshot belongs to (FK to workflow.id)
versionINTEGERNO-Snapshot version number
definitionJSONBNO-Snapshot of the workflow definition at that version
eventVARCHAR(20)NO-Event that produced this version
created_byINTEGERYES-User who produced this version (user id)
created_dateTIMESTAMPTZ(3)NOnow()Timestamp the version was recorded

Notes

  • workflow_version.workflow_id is a FK to workflow.id, with an index on (workflow_id, version DESC) so the latest version can be fetched quickly
  • workflow is indexed on (line_oa_id, organization_id) for per-tenant queries and on deleted_date for filtering soft-deleted rows
  • trigger_rule references workflow.id through trigger_rule.workflow_id and pins the node it belongs to via workflow_node_path (see Trigger Rules and Scheduled Jobs)
  • scheduled_action also carries workflow_id and workflow_node_path, so a scheduled action can be traced back to the workflow node that created it
  • There is no schema-level unique constraint on (workflow_id, version) — version uniqueness is enforced by the application