-- 022_monitored_services_external.sql
-- Optional external/domain URL for a service, used by the dashboard tile when the
-- owner is browsing remotely. LAN `url` stays the source of truth for health checks.
ALTER TABLE monitored_services ADD COLUMN external text;

-- Backfill curated domains by id (the live instance is already seeded, so adding the
-- column alone wouldn't populate them). No-op for ids that don't exist.
UPDATE monitored_services SET external = 'https://void.hynesy.com'      WHERE id = 'void-server';
UPDATE monitored_services SET external = 'https://gramps.hynesy.com'    WHERE id = 'gramps';
UPDATE monitored_services SET external = 'https://plex.hynesy.com'      WHERE id = 'plex';
UPDATE monitored_services SET external = 'https://tdarr.hynesy.com'     WHERE id = 'tdarr';
UPDATE monitored_services SET external = 'https://sonarr.hynesy.com'    WHERE id = 'sonarr';
UPDATE monitored_services SET external = 'https://radarr.hynesy.com'    WHERE id = 'radarr';
UPDATE monitored_services SET external = 'https://bookstack.hynesy.com' WHERE id = 'bookstack';
-- Two services previously stored their domain in `url`; normalise to LAN url + external.
UPDATE monitored_services SET url = 'http://192.168.1.230:8096', external = 'https://jellyfin.hynesy.com' WHERE id = 'jellyfin';
UPDATE monitored_services SET url = 'http://192.168.1.230:8789', external = 'https://chaptarr.hynesy.com'  WHERE id = 'chaptarr';
