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;