-- station_profiles: one row per operating configuration (home, portable,
-- SOTA, /MM, contest…). The user picks one as active; every QSO stamps
-- the active profile's MY_* fields. Place reserved for per-profile creds
-- (LoTW, Clublog, QRZ.com) in a later migration once those exports land.
CREATE TABLE station_profiles (
    id              INTEGER PRIMARY KEY AUTOINCREMENT,
    name            TEXT NOT NULL,                    -- "Home", "Portable", "SOTA"…
    callsign        TEXT NOT NULL DEFAULT '',
    operator        TEXT NOT NULL DEFAULT '',
    my_grid         TEXT NOT NULL DEFAULT '',
    my_country      TEXT NOT NULL DEFAULT '',
    my_state        TEXT NOT NULL DEFAULT '',
    my_cnty         TEXT NOT NULL DEFAULT '',
    my_street       TEXT NOT NULL DEFAULT '',
    my_city         TEXT NOT NULL DEFAULT '',
    my_postal_code  TEXT NOT NULL DEFAULT '',
    my_sota_ref     TEXT NOT NULL DEFAULT '',
    my_pota_ref     TEXT NOT NULL DEFAULT '',
    my_rig          TEXT NOT NULL DEFAULT '',
    my_antenna      TEXT NOT NULL DEFAULT '',
    tx_pwr          REAL,                              -- nullable: not always known
    is_active       INTEGER NOT NULL DEFAULT 0,        -- 1 for the currently-selected profile
    sort_order      INTEGER NOT NULL DEFAULT 0,
    created_at      TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')),
    updated_at      TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now'))
);

-- Only one profile can be active at a time. Enforced lazily — the Go side
-- clears all then sets one before each switch.
CREATE INDEX idx_station_profiles_active ON station_profiles(is_active);
