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.
| Model | Table | Holds |
|---|---|---|
Workflow | workflows | Each workflow's editable draft and a pointer to its published version. |
WorkflowVersion | workflow_versions | Immutable published snapshots. See Publishing & versions. |
WorkflowExecution | workflow_executions | One record per run. |
ExecutionLogEntry | workflow_execution_logs | Per-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
| Attribute | Type | Notes |
|---|---|---|
id | string | The primary key — a stable id you choose, e.g. send-welcome-email. |
name | string | |
trigger | array | { type, config } |
nodes | array | [{ id, type, config }, …] |
edges | array | [{ from, to, branch }, …] |
meta | array | Defaults to []. |
active | bool | Defaults 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.