feat(store): keep check evidence apart from results

Refs #79

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 12:09:42 +01:00
1 parent 78cd911008
commit 8f5eb5d075
5 files changed
+238

No files matched your search

@@ -0,0 +1,29 @@
-- +goose Up
-- What checkers saw of HTTP exchanges (see check.Evidence). Kept apart
-- from check_results, which is compressed and holds one small row per
-- check; evidence is sampled and large. Per monitor and region the API
-- keeps the latest success and failures at most every few minutes.
CREATE TABLE check_evidence (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
org_id uuid NOT NULL,
monitor_id uuid NOT NULL,
region text NOT NULL,
checker_id uuid NOT NULL,
time timestamptz NOT NULL,
ok boolean NOT NULL,
status_code integer,
error text,
evidence jsonb NOT NULL,
FOREIGN KEY (monitor_id, org_id) REFERENCES monitors (id, org_id) ON DELETE CASCADE
);
CREATE INDEX check_evidence_monitor_idx ON check_evidence (monitor_id, region, time DESC);
CREATE INDEX check_evidence_time_idx ON check_evidence (time);
ALTER TABLE check_evidence ENABLE ROW LEVEL SECURITY;
ALTER TABLE check_evidence FORCE ROW LEVEL SECURITY;
CREATE POLICY check_evidence_tenant ON check_evidence FOR ALL
USING (app_scope_system() OR org_id = app_org_id())
WITH CHECK (app_scope_system() OR org_id = app_org_id());
-- +goose Down
DROP TABLE check_evidence;