Triggers

Creator: wbhauck

Related Items

Product: Project Useful

Project: Project Useful Version 1

Body:

delimiter ;

drop trigger issues_bi;
drop trigger issues_bu;

delimiter ;;

CREATE DEFINER=`useful`@`localhost` TRIGGER `issues_bi` BEFORE INSERT ON `issues` FOR EACH ROW begin
set new.vendor_response_due_at = new.reported_to_vendor_at + interval (select slas.response_due_at from slas where slas.id = new.slas_id) hour;
set new.vendor_workaround_due_at = new.reported_to_vendor_at + interval (select slas.workaround_due_at from slas where slas.id = new.slas_id) hour;
set new.vendor_solution_due_at = new.reported_to_vendor_at + interval (select slas.solution_due_at from slas where slas.id = new.slas_id) hour;
end
;;

CREATE DEFINER=`useful`@`localhost` TRIGGER `issues_bu` BEFORE UPDATE ON `issues` FOR EACH ROW begin
set new.vendor_response_due_at = new.reported_to_vendor_at + interval (select slas.response_due_at from slas where slas.id = new.slas_id) hour;
set new.vendor_workaround_due_at = new.reported_to_vendor_at + interval (select slas.workaround_due_at from slas where slas.id = new.slas_id) hour;
set new.vendor_solution_due_at = new.reported_to_vendor_at + interval (select slas.solution_due_at from slas where slas.id = new.slas_id) hour;
end
;;

delimiter ;