-- Promote ~30 more ADIF 3.1.7 fields to dedicated columns so they are
-- editable, queryable and exported as proper tags (rather than living only
-- in extras_json). The long tail of rarely-used fields still rides in
-- extras_json and is reachable via the generic "ADIF fields" editor.
-- SQLite ADD COLUMN is metadata-only — fast even on large logbooks.

-- --- Special-activity group (POTA/SOTA/WWFF/SIG) ---
ALTER TABLE qso ADD COLUMN sig          TEXT;  -- e.g. "POTA", "WWFF"
ALTER TABLE qso ADD COLUMN sig_info     TEXT;  -- the reference for SIG
ALTER TABLE qso ADD COLUMN my_sig       TEXT;
ALTER TABLE qso ADD COLUMN my_sig_info  TEXT;
ALTER TABLE qso ADD COLUMN wwff_ref     TEXT;  -- contacted WWFF reference
ALTER TABLE qso ADD COLUMN my_wwff_ref  TEXT;  -- my WWFF activation

-- --- Distance / power / space weather ---
ALTER TABLE qso ADD COLUMN distance     REAL;  -- km
ALTER TABLE qso ADD COLUMN rx_pwr       REAL;  -- contacted station power (W)
ALTER TABLE qso ADD COLUMN a_index      REAL;
ALTER TABLE qso ADD COLUMN k_index      REAL;
ALTER TABLE qso ADD COLUMN sfi          REAL;  -- solar flux index

-- --- Club memberships ---
ALTER TABLE qso ADD COLUMN skcc         TEXT;  -- can carry suffix letters
ALTER TABLE qso ADD COLUMN fists        TEXT;
ALTER TABLE qso ADD COLUMN ten_ten      TEXT;

-- --- Contacted / station identity ---
ALTER TABLE qso ADD COLUMN contacted_op TEXT;  -- the actual operator worked
ALTER TABLE qso ADD COLUMN eq_call      TEXT;  -- former / alternate callsign
ALTER TABLE qso ADD COLUMN pfx          TEXT;  -- WPX prefix
ALTER TABLE qso ADD COLUMN my_name      TEXT;
ALTER TABLE qso ADD COLUMN class        TEXT;  -- Field Day class

-- --- German DOK / region ---
ALTER TABLE qso ADD COLUMN darc_dok     TEXT;
ALTER TABLE qso ADD COLUMN my_darc_dok  TEXT;
ALTER TABLE qso ADD COLUMN region       TEXT;

-- --- Flags ---
ALTER TABLE qso ADD COLUMN silent_key   TEXT;  -- Y/N
ALTER TABLE qso ADD COLUMN swl          TEXT;  -- Y/N (SWL report)
ALTER TABLE qso ADD COLUMN qso_complete TEXT;  -- Y/N/NIL/?
ALTER TABLE qso ADD COLUMN qso_random   TEXT;  -- Y/N

-- --- Award credits ---
ALTER TABLE qso ADD COLUMN credit_granted   TEXT;
ALTER TABLE qso ADD COLUMN credit_submitted TEXT;

-- --- My station extras ---
ALTER TABLE qso ADD COLUMN my_arrl_sect  TEXT;
ALTER TABLE qso ADD COLUMN my_vucc_grids TEXT;

CREATE INDEX IF NOT EXISTS idx_qso_sig      ON qso(sig);
CREATE INDEX IF NOT EXISTS idx_qso_wwff_ref ON qso(wwff_ref);
CREATE INDEX IF NOT EXISTS idx_qso_skcc     ON qso(skcc);
