diff --git a/services/mam-api/src/db/migrations/031-cluster-nodes-last-seen.sql b/services/mam-api/src/db/migrations/031-cluster-nodes-last-seen.sql new file mode 100644 index 0000000..1dd0ab0 --- /dev/null +++ b/services/mam-api/src/db/migrations/031-cluster-nodes-last-seen.sql @@ -0,0 +1,10 @@ +-- Migration 031 — Add last_seen_at to cluster_nodes +-- +-- Playout failover (routes/playout.js restartChannel) queries cluster_nodes.last_seen_at +-- to find healthy nodes for channel re-placement. Column was missing from original +-- cluster schema; heartbeat endpoint updates it via /cluster/heartbeat. + +ALTER TABLE cluster_nodes ADD COLUMN IF NOT EXISTS last_seen_at TIMESTAMPTZ; + +-- Backfill existing nodes to NOW() so they're immediately eligible for failover +UPDATE cluster_nodes SET last_seen_at = NOW() WHERE last_seen_at IS NULL;