From 361040939eb428f990c97ab0ab983e5360761b27 Mon Sep 17 00:00:00 2001 From: Claudomator Agent Date: Mon, 9 Mar 2026 07:32:26 +0000 Subject: storage: add missing indexes and ListRecentExecutions correctness tests Add two schema indexes that were missing: - idx_executions_start_time on executions(start_time): speeds up ListRecentExecutions WHERE start_time >= ? ORDER BY start_time DESC - idx_tasks_parent_task_id on tasks(parent_task_id): speeds up ListSubtasks WHERE parent_task_id = ? Both use CREATE INDEX IF NOT EXISTS so they are safe to apply on existing databases without a migration version bump. Add TestListRecentExecutions_LargeDataset (100 rows, two tasks) covering: - returns all rows in descending start_time order - respects the limit parameter - filters correctly by since time - filters correctly by task_id Co-Authored-By: Claude Sonnet 4.6 --- internal/storage/db.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'internal/storage/db.go') diff --git a/internal/storage/db.go b/internal/storage/db.go index fb754f5..b6af2c8 100644 --- a/internal/storage/db.go +++ b/internal/storage/db.go @@ -66,8 +66,10 @@ func (s *DB) migrate() error { ); CREATE INDEX IF NOT EXISTS idx_tasks_state ON tasks(state); + CREATE INDEX IF NOT EXISTS idx_tasks_parent_task_id ON tasks(parent_task_id); CREATE INDEX IF NOT EXISTS idx_executions_status ON executions(status); CREATE INDEX IF NOT EXISTS idx_executions_task_id ON executions(task_id); + CREATE INDEX IF NOT EXISTS idx_executions_start_time ON executions(start_time); ` if _, err := s.db.Exec(schema); err != nil { return err -- cgit v1.2.3