-- Adds Adzuna, TheirStack and Eurostat as market-data sources alongside
-- Jooble, plus an AI reconciliation pass that flags cross-source false
-- positives before they feed salary percentiles. These columns record the
-- reconciliation's reasoning and the Eurostat country-level reference
-- figure it was given as context, so both are visible later, not just at
-- generation time.
ALTER TABLE market_statistics
    ADD COLUMN reconciliation_note TEXT NULL,
    ADD COLUMN eurostat_reference_value DECIMAL(12,2) NULL,
    ADD COLUMN eurostat_reference_period VARCHAR(20) NULL;

-- salary_statistics.source used to be Jooble-only ('jooble'); it's now any
-- combination of Jooble/Adzuna/TheirStack, so the enum value is renamed to
-- not misleadingly imply a single provider. The widen-update-narrow order
-- matters: the UPDATE must run while both 'jooble' and 'real_postings'
-- are valid enum values, otherwise MySQL rejects the new value (#1265).
ALTER TABLE salary_statistics
    MODIFY COLUMN source ENUM('jooble','real_postings','ai_estimate','none') NOT NULL DEFAULT 'none';
UPDATE salary_statistics SET source = 'real_postings' WHERE source = 'jooble';
ALTER TABLE salary_statistics
    MODIFY COLUMN source ENUM('real_postings','ai_estimate','none') NOT NULL DEFAULT 'none';
