19 lines
450 B
MySQL
19 lines
450 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticket_beforeDelete`
|
||
|
BEFORE DELETE ON `ticket`
|
||
|
FOR EACH ROW
|
||
|
BEGIN
|
||
|
INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`)
|
||
|
SELECT r.id
|
||
|
FROM vn.route r
|
||
|
WHERE r.isOk = FALSE
|
||
|
AND r.id = OLD.routeFk
|
||
|
AND r.created >= util.VN_CURDATE()
|
||
|
GROUP BY r.id;
|
||
|
|
||
|
DELETE FROM sale WHERE ticketFk = OLD.id;
|
||
|
|
||
|
DELETE FROM ticketDms WHERE ticketFk = OLD.id;
|
||
|
END$$
|
||
|
DELIMITER ;
|