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);
