CREATE TABLE public.course_email_templates
(
    id integer NOT NULL DEFAULT nextval('course_email_templates_id_seq'::regclass),
    course_id integer NOT NULL,
    template_key character varying(50) NOT NULL,
    language character varying(5) NOT NULL,
    subject text NOT NULL,
    body_html text NOT NULL,
    body_text text NOT NULL DEFAULT ''::text,
    active boolean NOT NULL DEFAULT true,
    updated_at timestamp with time zone NOT NULL DEFAULT now(),
    CONSTRAINT course_email_templates_course_id_fkey FOREIGN KEY (course_id) REFERENCES courses(course_id) ON DELETE CASCADE,
    CONSTRAINT course_email_templates_pkey PRIMARY KEY (id),
    CONSTRAINT uq_course_email_template UNIQUE (course_id, template_key, language)
);
