summaryrefslogtreecommitdiff
path: root/internal/storage/db.go
diff options
context:
space:
mode:
authorClaudomator Agent <agent@claudomator>2026-03-09 07:32:26 +0000
committerClaudomator Agent <agent@claudomator>2026-03-09 07:32:26 +0000
commit361040939eb428f990c97ab0ab983e5360761b27 (patch)
tree2ba86e7e1081db54022a331be4ea2cfef841dc37 /internal/storage/db.go
parent933af819ae3ee7ea0cf6b750815ab185043e19fc (diff)
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 <noreply@anthropic.com>
Diffstat (limited to 'internal/storage/db.go')
-rw-r--r--internal/storage/db.go2
1 files changed, 2 insertions, 0 deletions
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