tracksolid_timescale_grafan.../db_audit/checks/enum_drift.sql
David Kiania 20d3ddb841 feat: add db_audit health checks, runner, and scheduled Forgejo workflow
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-12 21:40:29 +03:00

34 lines
823 B
SQL

-- 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;