CREATE OR REPLACE FUNCTION public.fn_admin_set_course_email_rule(p_course_id integer, p_event_type text, p_active boolean)
 RETURNS void
 LANGUAGE sql
AS $function$
  INSERT INTO public.course_email_rules (course_id, event_type, active)
  VALUES (p_course_id, p_event_type, p_active)
  ON CONFLICT (course_id, event_type) DO UPDATE SET active = EXCLUDED.active;
$function$
;
