-- A stable identity per contact, for folder-based synchronisation.
--
-- Two PCs exchanging changes through a shared folder need to name the SAME
-- contact in both logs. "the QSO with M0ABC at 14:32" is a guess, and the two
-- machines can disagree about which row that is — so an edit or a deletion
-- cannot be addressed at all without an identity that travels with the record.
--
-- A REAL COLUMN, indexed, rather than a key inside extras_json. The identity is
-- looked up once per incoming change, and on a 120 000-QSO logbook scanning
-- JSON for it would turn every sync into a full table read. A column costs one
-- migration; the JSON would cost a scan every time.
--
-- sync_uid is listed in varcharColumns (internal/db/mysql.go): MySQL cannot
-- index a TEXT column without a prefix length, and a migration that tries dies
-- with error 1170 on every startup thereafter, with no way out from the UI.
--
-- Empty on every existing row, and it STAYS empty on most of them. The change
-- log starts empty too, so contacts logged before synchronisation was switched
-- on are never exchanged: nothing has to be copied across, and an identity is
-- stamped only on a contact that is actually logged, edited or deleted from
-- then on. Seeding a second machine with the existing log is a one-time copy of
-- the database or an ADIF import, not something synchronisation does.
ALTER TABLE qso ADD COLUMN sync_uid TEXT NOT NULL DEFAULT '';
CREATE INDEX IF NOT EXISTS idx_qso_sync_uid ON qso (sync_uid);
