-- 016_port_sync_status.sql
--
-- Single-row latest-status table for the Proton→qBittorrent port sync, so the
-- dashboard can show the current Proton port, qBit port, and whether they're in
-- sync. Written every run by the home-PC script via POST /api/portsync/status;
-- read by the dashboard via GET /api/portsync/. id is pinned to 1 (upsert).

CREATE TABLE IF NOT EXISTS port_sync_status (
    id           INTEGER PRIMARY KEY CHECK (id = 1),
    proton_port  INTEGER NOT NULL DEFAULT 0,
    qbit_port    INTEGER NOT NULL DEFAULT 0,
    in_sync      INTEGER NOT NULL DEFAULT 0,
    vpn_up       INTEGER NOT NULL DEFAULT 0,
    qbit_running INTEGER NOT NULL DEFAULT 0,
    note         TEXT,
    reported_at  INTEGER NOT NULL
);
