coryd.dev/queries/functions/update_scheduled_episode_status.psql

11 lines
242 B
Text

CREATE OR REPLACE FUNCTION update_scheduled_episode_status()
RETURNS TRIGGER AS $$
BEGIN
UPDATE scheduled_episodes
SET status = 'aired'
WHERE air_date < CURRENT_DATE
AND status = 'upcoming';
RETURN NEW;
END;
$$ LANGUAGE plpgsql;