Upgrade changes
[civicrm-core.git] / sql / trigger.mysql
1 -- +--------------------------------------------------------------------+
2 -- | CiviCRM version 4.6 |
3 -- +--------------------------------------------------------------------+
4 -- | Copyright CiviCRM LLC (c) 2004-2015 |
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
25 DELIMITER |
26
27 CREATE TRIGGER civicrm_contact_ad
28 BEFORE DELETE ON civicrm_contact
29 FOR EACH ROW
30 BEGIN
31 -- we delete the corresponding entity_id/entity_table entries
32 -- from all the linked tables (note, log etc)
33 DELETE FROM civicrm_note
34 WHERE entity_id = OLD.id
35 AND entity_table = 'civicrm_contact';
36 DELETE FROM civicrm_log
37 WHERE entity_id = OLD.id
38 AND entity_table = 'civicrm_contact';
39 DELETE FROM civicrm_task_status
40 WHERE responsible_entity_id = OLD.id
41 AND responsible_entity_table = 'civicrm_contact';
42
43 END;
44
45 CREATE TRIGGER civicrm_contribution_ad
46 BEFORE DELETE ON civicrm_contribution
47 FOR EACH ROW
48 BEGIN
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';
52 END;
53
54 CREATE TRIGGER civicrm_participant_ad
55 BEFORE DELETE ON civicrm_participant
56 FOR EACH ROW
57 BEGIN
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';
62 END;
63
64 |
65
66 DELIMITER ;
67