-- Enum drift: unexpected values in source and other constrained columns
-- position_history.source should be: poll, push, track_list
SELECT
    'position_history.source'   AS check_column,
    source                      AS unexpected_value,
    COUNT(*)                    AS occurrences
FROM tracksolid.position_history
WHERE source NOT IN ('poll', 'push', 'track_list')
  AND source IS NOT NULL
GROUP BY source

UNION ALL

-- trips.source should be: poll, push
SELECT
    'trips.source',
    source,
    COUNT(*)
FROM tracksolid.trips
WHERE source NOT IN ('poll', 'push')
  AND source IS NOT NULL
GROUP BY source

UNION ALL

-- alarms.source should be: poll, push
SELECT
    'alarms.source',
    source,
    COUNT(*)
FROM tracksolid.alarms
WHERE source NOT IN ('poll', 'push')
  AND source IS NOT NULL
GROUP BY source;
