Files
panel/controller/internal/db/migrations/004_event_triggers.sql
T
dbledeez 295eb22826 panel public release
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-15 01:26:41 -07:00

21 lines
910 B
SQL

-- 004_event_triggers.sql — event-driven schedule triggers.
--
-- Until now schedules only supported cron. This migration adds:
-- * trigger_kind = 'event' schedules, powered by a CEL expression over
-- the event bus. Example: players_online == 0
-- * optional sustained-state: fire only after the condition has been
-- continuously true for N seconds. Enables "idle shutdown if 0 players
-- for 30m" without firing every 60s when the polled player count is 0.
--
-- cron_spec becomes nullable so event triggers can exist with NULL there.
-- Exactly one of cron_spec / event_spec is populated; the application
-- enforces this.
ALTER TABLE schedules ALTER COLUMN cron_spec DROP NOT NULL;
ALTER TABLE schedules
ADD COLUMN event_spec TEXT,
ADD COLUMN event_sustained_seconds INTEGER NOT NULL DEFAULT 0;
CREATE INDEX idx_schedules_trigger_kind ON schedules(trigger_kind);