Files
mailadmin/backend/migrations/004_domain_health_status.sql
2026-04-28 20:38:50 -05:00

20 lines
835 B
SQL

-- ============================================================
-- 004_domain_health_status.sql
-- Persistent storage of the most recent health check result per domain.
-- Updated whenever the user clicks "Check health".
--
-- The 'has_problems' boolean drives the banner in the mailbox view.
-- The 'details' JSONB column stores the full report so the modal can
-- show last-known state without re-running the checks.
-- ============================================================
CREATE TABLE IF NOT EXISTS domain_health_status (
domain TEXT PRIMARY KEY,
checked_at TIMESTAMPTZ NOT NULL DEFAULT now(),
has_problems BOOLEAN NOT NULL DEFAULT false,
details JSONB NOT NULL DEFAULT '{}'::jsonb
);
CREATE INDEX IF NOT EXISTS idx_domain_health_problems
ON domain_health_status(has_problems, checked_at DESC);