coryd.dev/queries/functions/update_scheduled_on_watch.psql

12 lines
289 B
Text

CREATE OR REPLACE FUNCTION update_scheduled_on_watch()
RETURNS TRIGGER AS $$
BEGIN
UPDATE scheduled_episodes
SET status = 'watched'
WHERE show_id = NEW.show
AND season_number = NEW.season_number
AND episode_number = NEW.episode_number;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;