d1692842b3
Adds a Store-method API for the RecordSpeedTest RPC (Task 8) and the
retention sweep (Task 14):
- SaveSpeedTest / ListRecentSpeedTests / DeleteSpeedTestsBefore
- SpeedTest struct (no json tags; that decision deferred to Task 10)
Schema lives in migrations/002_speedtests.sql to match the existing
embed.FS pattern (rather than inline in Go). The migrate() loop now
iterates every *.sql in lexical order, so future migrations drop in
without code changes. Both files use CREATE ... IF NOT EXISTS so the
existing 001 migration remains idempotent on already-initialised DBs.
CHECK constraints enforce node IN ('fl','pl1') and non-negative metric
values at the DB level. country has no DB CHECK — validation belongs
to the gRPC handler in Task 8.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
14 lines
528 B
SQL
14 lines
528 B
SQL
CREATE TABLE IF NOT EXISTS speedtests (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
timestamp INTEGER NOT NULL,
|
|
node TEXT NOT NULL CHECK(node IN ('fl', 'pl1')),
|
|
country TEXT NOT NULL,
|
|
dl_mbps REAL NOT NULL CHECK(dl_mbps >= 0),
|
|
ul_mbps REAL NOT NULL CHECK(ul_mbps >= 0),
|
|
ping_ms REAL NOT NULL CHECK(ping_ms >= 0),
|
|
jitter_ms REAL NOT NULL CHECK(jitter_ms >= 0)
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_speedtests_ts ON speedtests(timestamp);
|
|
CREATE INDEX IF NOT EXISTS idx_speedtests_node ON speedtests(node);
|