-- Key/value app settings (lookup credentials, preferences, …)
CREATE TABLE IF NOT EXISTS settings (
    key        TEXT PRIMARY KEY,
    value      TEXT NOT NULL,
    updated_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
);

-- Local cache of QRZ/HamQTH lookups to avoid re-querying for the same call.
CREATE TABLE IF NOT EXISTS callsign_cache (
    callsign   TEXT PRIMARY KEY,
    name       TEXT,
    qth        TEXT,
    country    TEXT,
    grid       TEXT,
    dxcc       INTEGER,
    cqz        INTEGER,
    ituz       INTEGER,
    cont       TEXT,
    source     TEXT NOT NULL,            -- 'qrz' | 'hamqth'
    fetched_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
);
