Vapora/migrations/007_a2a_tasks_schema.surql

23 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

-- Migration 007: A2A Tasks Schema
-- Creates a2a_tasks table for Agent-to-Agent protocol task persistence
-- Replaces in-memory HashMap with durable storage
-- A2A Tasks table
DEFINE TABLE a2a_tasks SCHEMAFULL;
DEFINE FIELD id ON TABLE a2a_tasks TYPE record<a2a_tasks>;
DEFINE FIELD task_id ON TABLE a2a_tasks TYPE string ASSERT $value != NONE;
DEFINE FIELD state ON TABLE a2a_tasks TYPE string ASSERT $value INSIDE ["waiting", "working", "completed", "failed"] DEFAULT "waiting";
DEFINE FIELD message ON TABLE a2a_tasks TYPE option<object>;
DEFINE FIELD result ON TABLE a2a_tasks TYPE option<object>;
DEFINE FIELD error ON TABLE a2a_tasks TYPE option<object>;
DEFINE FIELD metadata ON TABLE a2a_tasks TYPE option<object>;
DEFINE FIELD created_at ON TABLE a2a_tasks TYPE datetime DEFAULT time::now();
DEFINE FIELD updated_at ON TABLE a2a_tasks TYPE datetime DEFAULT time::now() VALUE time::now();
-- Indexes for efficient queries
DEFINE INDEX idx_a2a_tasks_task_id ON TABLE a2a_tasks COLUMNS task_id UNIQUE;
DEFINE INDEX idx_a2a_tasks_state ON TABLE a2a_tasks COLUMNS state;
DEFINE INDEX idx_a2a_tasks_created_at ON TABLE a2a_tasks COLUMNS created_at;
DEFINE INDEX idx_a2a_tasks_state_created ON TABLE a2a_tasks COLUMNS state, created_at;