22 lines
1.2 KiB
Plaintext
22 lines
1.2 KiB
Plaintext
|
|
-- Migration 009: Workflow State Persistence
|
||
|
|
-- Replaces DashMap (in-memory, lost on restart) with durable SurrealDB storage.
|
||
|
|
-- WorkflowInstance is stored as a JSON document; status is a tagged serde enum.
|
||
|
|
|
||
|
|
DEFINE TABLE workflow_instances SCHEMAFULL;
|
||
|
|
|
||
|
|
DEFINE FIELD id ON TABLE workflow_instances TYPE record<workflow_instances>;
|
||
|
|
DEFINE FIELD template_name ON TABLE workflow_instances TYPE string ASSERT $value != NONE;
|
||
|
|
DEFINE FIELD status ON TABLE workflow_instances FLEXIBLE TYPE any ASSERT $value != NONE;
|
||
|
|
DEFINE FIELD stages ON TABLE workflow_instances FLEXIBLE TYPE array;
|
||
|
|
DEFINE FIELD current_stage_idx ON TABLE workflow_instances TYPE int DEFAULT 0;
|
||
|
|
DEFINE FIELD initial_context ON TABLE workflow_instances FLEXIBLE TYPE object;
|
||
|
|
DEFINE FIELD accumulated_artifacts ON TABLE workflow_instances FLEXIBLE TYPE object DEFAULT {};
|
||
|
|
DEFINE FIELD created_at ON TABLE workflow_instances TYPE datetime DEFAULT time::now();
|
||
|
|
DEFINE FIELD updated_at ON TABLE workflow_instances TYPE datetime DEFAULT time::now() VALUE time::now();
|
||
|
|
|
||
|
|
DEFINE INDEX idx_workflow_instances_template
|
||
|
|
ON TABLE workflow_instances COLUMNS template_name;
|
||
|
|
|
||
|
|
DEFINE INDEX idx_workflow_instances_created_at
|
||
|
|
ON TABLE workflow_instances COLUMNS created_at;
|