Files
awoooi/apps/api/migrations/adr091_aider_events_schema.sql
2026-04-20 04:04:13 +08:00

23 lines
1.2 KiB
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- adr091: aider_events schema
-- 2026-04-20 @ Asia/Taipei
-- 紀錄統帥本機 aider CLI 活動,供 AI Router feedback + symptom_pattern 抽取
CREATE TABLE IF NOT EXISTS aider_events (
id BIGSERIAL PRIMARY KEY,
session_id TEXT NOT NULL,
ts TIMESTAMPTZ NOT NULL,
type TEXT NOT NULL, -- session_start|file_edit|error|commit|silent_timeout|session_end|raw
host TEXT DEFAULT 'ogt-mac',
payload JSONB NOT NULL,
incident_id TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS aider_events_session_idx ON aider_events(session_id);
CREATE INDEX IF NOT EXISTS aider_events_type_ts_idx ON aider_events(type, ts DESC);
CREATE INDEX IF NOT EXISTS aider_events_ts_idx ON aider_events(ts DESC);
CREATE INDEX IF NOT EXISTS aider_events_payload_gin ON aider_events USING GIN (payload);
COMMENT ON TABLE aider_events IS 'aider CLI 事件流Mac 端 aiderw wrapper 推入)';
COMMENT ON COLUMN aider_events.incident_id IS '若觸發建 incident記 FK 至 incidents.incident_id';
COMMENT ON COLUMN aider_events.payload IS 'Type-specific payload JSON見 src/models/aider.py schema';