Merge pull request #6418 from eileenmcnaughton/CRM-15815-46
[civicrm-core.git] / sql / trigger.mysql
CommitLineData
6a488035 1-- +--------------------------------------------------------------------+
9242538c 2-- | CiviCRM version 4.6 |
6a488035 3-- +--------------------------------------------------------------------+
e7112fa7 4-- | Copyright CiviCRM LLC (c) 2004-2015 |
6a488035
TO
5-- +--------------------------------------------------------------------+
6-- | This file is a part of CiviCRM. |
7-- | |
8-- | CiviCRM is free software; you can copy, modify, and distribute it |
9-- | under the terms of the GNU Affero General Public License |
10-- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
11-- | |
12-- | CiviCRM is distributed in the hope that it will be useful, but |
13-- | WITHOUT ANY WARRANTY; without even the implied warranty of |
14-- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
15-- | See the GNU Affero General Public License for more details. |
16-- | |
17-- | You should have received a copy of the GNU Affero General Public |
18-- | License and the CiviCRM Licensing Exception along |
19-- | with this program; if not, contact CiviCRM LLC |
20-- | at info[AT]civicrm[DOT]org. If you have questions about the |
21-- | GNU Affero General Public License or the licensing of CiviCRM, |
22-- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
23-- +--------------------------------------------------------------------+
24
25DELIMITER |
26
27CREATE TRIGGER civicrm_contact_ad
28BEFORE DELETE ON civicrm_contact
29FOR EACH ROW
30BEGIN
31 -- we delete the corresponding entity_id/entity_table entries
32 -- from all the linked tables (note, log etc)
33 DELETE FROM civicrm_note
c213dee5 34 WHERE entity_id = OLD.id
6a488035
TO
35 AND entity_table = 'civicrm_contact';
36 DELETE FROM civicrm_log
37 WHERE entity_id = OLD.id
38 AND entity_table = 'civicrm_contact';
c213dee5 39 DELETE FROM civicrm_task_status
6a488035
TO
40 WHERE responsible_entity_id = OLD.id
41 AND responsible_entity_table = 'civicrm_contact';
42
43END;
44
45CREATE TRIGGER civicrm_contribution_ad
46BEFORE DELETE ON civicrm_contribution
47FOR EACH ROW
48BEGIN
49 -- we delete the corresponding entity_id/entity_table entries
50 -- from all the linked tables (note, log etc)
51 DELETE FROM civicrm_note WHERE entity_id = OLD.id AND entity_table = 'civicrm_contribution';
52END;
53
54CREATE TRIGGER civicrm_participant_ad
55BEFORE DELETE ON civicrm_participant
56FOR EACH ROW
57BEGIN
58 -- we delete the corresponding entity_id/entity_table entries
59 -- from all the linked tables (note, log etc)
60 DELETE FROM civicrm_note WHERE entity_id = OLD.id AND entity_table = 'civicrm_participant';
61 DELETE FROM civicrm_log WHERE entity_id = OLD.id AND entity_table = 'civicrm_participant';
62END;
63
64|
65
66DELIMITER ;
67