File indexing completed on 2024-04-21 06:00:35

0001 /**
0002  * If a comment will be deleted (hidden) then update num of 
0003  * active comments in project (viewd in explore list).
0004  */
0005 CREATE TRIGGER `comment_update`
0006     BEFORE UPDATE
0007     ON `comments`
0008     FOR EACH ROW
0009 BEGIN
0010 
0011     IF `NEW`.`comment_active` = 0 AND `OLD`.`comment_active` = 1 THEN
0012 
0013         UPDATE `project` `p`
0014         SET `p`.`count_comments` = (`p`.`count_comments` - 1)
0015         WHERE `p`.`project_id` = `NEW`.`comment_target_id`;
0016 
0017     END IF;
0018 END