Skip to main content

Storage

Workflows and execution records are stored in your application's database and exposed as Eloquent models. Query them the same way you query any other model.

ModelTableHolds
WorkflowworkflowsEach workflow's editable draft and a pointer to its published version.
WorkflowVersionworkflow_versionsImmutable published snapshots. See Publishing & versions.
WorkflowExecutionworkflow_executionsOne record per run.
ExecutionLogEntryworkflow_execution_logsPer-node log rows for an execution.

All four live under Qanna\WorkflowEngine\Models. The tables come from the published migration — see Installation.

Workflows​

use Qanna\WorkflowEngine\Models\Workflow;

$workflow = Workflow::create([
'id' => 'send-welcome-email',
'name' => 'Send Welcome Email',
'trigger' => ['type' => '@wf::trigger.manual', 'config' => []],
'nodes' => [/* ... */],
'edges' => [/* ... */],
]);

Workflow::find('send-welcome-email'); // ?Workflow
Workflow::active()->get(); // only workflows with active = true
$workflow->versions; // WorkflowVersion models
$workflow->publishedVersion; // ?WorkflowVersion
$workflow->executions; // WorkflowExecution models
$workflow->delete(); // also deletes its versions
AttributeTypeNotes
idstringThe primary key — a stable id you choose, e.g. send-welcome-email.
namestring
triggerarray{ type, config }
nodesarray[{ id, type, config }, …]
edgesarray[{ from, to, branch }, …]
metaarrayDefaults to [].
activeboolDefaults to true.

Saving a workflow saves its draft. It doesn't run until it's published — see Publishing & versions.

Executions​

The engine writes execution records itself as workflows run — you mostly read them (dashboards, cleanup jobs, debugging).

use Qanna\WorkflowEngine\Engine\Enums\ExecutionStatus;
use Qanna\WorkflowEngine\Models\WorkflowExecution;

$execution = WorkflowExecution::find($executionId);

WorkflowExecution::where('workflow_id', 'send-welcome-email')
->latest('started_at')
->limit(50)
->get();

WorkflowExecution::where('status', ExecutionStatus::Failed)->get();

$execution->logs; // ExecutionLogEntry models, in order
$execution->logs->where('node_id', 'greet');

// Cleanup — log rows are deleted with their execution.
WorkflowExecution::where('started_at', '<', now()->subMonths(3))->delete();

See Execution & modes for every attribute on an execution.

Execution records have no foreign key to workflows, so deleting a workflow keeps its execution history.

Sensitive fields​

Node and trigger config fields declared ->sensitive() (for example the Webhook trigger's secret) are encrypted with the app key before being written and decrypted when you read the model, transparently. This covers workflows, versions, and the definition snapshot stored on each execution. Rotating APP_KEY invalidates stored sensitive values.

Exported workflow files never contain sensitive values — see Exporting and importing.