From 00bfef0aee73b23fc2a70a88d985a6659528c5e9 Mon Sep 17 00:00:00 2001 From: Steve Cliff Date: Thu, 7 May 2026 18:39:44 +0100 Subject: [PATCH] store: migration 0023 host_repo_stats_history --- .../0023_host_repo_stats_history.sql | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 internal/store/migrations/0023_host_repo_stats_history.sql diff --git a/internal/store/migrations/0023_host_repo_stats_history.sql b/internal/store/migrations/0023_host_repo_stats_history.sql new file mode 100644 index 0000000..e1f64d1 --- /dev/null +++ b/internal/store/migrations/0023_host_repo_stats_history.sql @@ -0,0 +1,19 @@ +-- 0023_host_repo_stats_history.sql +-- +-- Daily time-series of per-host repo metrics, used by the P6-03 +-- trend sparkline + chart. One row per (host_id, UTC date), +-- last-write-wins per column. Population is best-effort and +-- piggy-backs on the existing repo.stats WS message — nothing +-- else writes here. + +CREATE TABLE host_repo_stats_history ( + host_id TEXT NOT NULL REFERENCES hosts(id) ON DELETE CASCADE, + day TEXT NOT NULL, -- 'YYYY-MM-DD' UTC + total_size_bytes INTEGER, -- nullable: partial patches preserve existing value + snapshot_count INTEGER, -- nullable + recorded_at TEXT NOT NULL, -- RFC3339Nano of latest write + PRIMARY KEY (host_id, day) +); + +CREATE INDEX host_repo_stats_history_host_day + ON host_repo_stats_history(host_id, day DESC);