summaryrefslogtreecommitdiff
path: root/internal/storage/db.go
diff options
context:
space:
mode:
authorClaude <noreply@anthropic.com>2026-05-22 09:08:52 +0000
committerClaude <noreply@anthropic.com>2026-05-22 09:08:52 +0000
commit39cc108b5f0bf3d0238a1707d657a77b7a3df184 (patch)
tree84ee8bcc039b058a308a542f1e1f4a4d11f9e144 /internal/storage/db.go
parentc24fdaa9b6bce49f5c0a1c589fd064d46b62b88d (diff)
feat(event,storage): add events table substrate for OSS redesign
New internal/event package defines the Event type with canonical Kind and Actor constants. New events table is appended via additive migration (id, task_id, seq, ts, kind, actor, payload_json) with seq as per-task monotonic, assigned by the storage layer inside a transaction. CreateEvent + ListEvents support the future migration of question_json, interactions_json, summary, and elaboration_input off the tasks table into a unified, replayable event stream. No existing code paths are modified yet; this is pure substrate for Phase 1. https://claude.ai/code/session_01SESwn7kQ7oP62trWw6pc39
Diffstat (limited to 'internal/storage/db.go')
-rw-r--r--internal/storage/db.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/internal/storage/db.go b/internal/storage/db.go
index 4adc1ba..3a4f059 100644
--- a/internal/storage/db.go
+++ b/internal/storage/db.go
@@ -139,6 +139,20 @@ func (s *DB) migrate() error {
`ALTER TABLE tasks ADD COLUMN checker_report TEXT NOT NULL DEFAULT ''`,
`ALTER TABLE executions ADD COLUMN tokens_in INTEGER`,
`ALTER TABLE executions ADD COLUMN tokens_out INTEGER`,
+ `CREATE TABLE IF NOT EXISTS events (
+ id TEXT PRIMARY KEY,
+ task_id TEXT NOT NULL,
+ seq INTEGER NOT NULL,
+ ts DATETIME NOT NULL,
+ kind TEXT NOT NULL,
+ actor TEXT NOT NULL,
+ payload_json TEXT NOT NULL DEFAULT '{}',
+ UNIQUE(task_id, seq),
+ FOREIGN KEY (task_id) REFERENCES tasks(id)
+ )`,
+ `CREATE INDEX IF NOT EXISTS idx_events_task_id_seq ON events(task_id, seq)`,
+ `CREATE INDEX IF NOT EXISTS idx_events_ts ON events(ts)`,
+ `CREATE INDEX IF NOT EXISTS idx_events_kind ON events(kind)`,
}
for _, m := range migrations {
if _, err := s.db.Exec(m); err != nil {