alter table hx_rel_learning_task_schedule_course
add constraint `hx_rel_learning_task_schedule_course_uniq`
unique (learning_task_id, schedule_id, course_id);

alter table hx_rel_learning_task_schedule_course
    add foreign key (learning_task_id) references hx_learning_task(id),
    add foreign key (schedule_id) references hx_course_schedule(id),
    add foreign key (course_id) references kg_course(id);

alter table hx_rel_learning_task_department_employee
add constraint `hx_rel_learning_task_department_employee_uniq`
unique (learning_task_id, department_id, employee_id);

alter table hx_rel_learning_task_department_employee
    add foreign key (learning_task_id) references hx_learning_task(id),
    add foreign key (department_id) references hx_department(id),
    add foreign key (employee_id) references hx_employee(id);


alter table hx_user_learning_task_custom
    add constraint hx_user_learning_task_custom_uniq
        unique (user_id, tenant_id, learning_task_id);
