grantprograms_uninstall.sql 5.41 KB
Newer Older
Pradeep Nayak's avatar
Pradeep Nayak committed
1
/**
2
 * Grant Programs extension improves grant allocation
3 4
 * in CiviGrant
 *
Pradeep Nayak's avatar
Pradeep Nayak committed
5 6 7 8 9 10
 * Copyright (C) 2012 JMA Consulting
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
11
 *
Pradeep Nayak's avatar
Pradeep Nayak committed
12 13 14 15
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
16
 *
Pradeep Nayak's avatar
Pradeep Nayak committed
17 18
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 *
Pradeep Nayak's avatar
Pradeep Nayak committed
20
 * Support: https://github.com/JMAConsulting/biz.jmaconsulting.grantprograms/issues
21
 *
Pradeep Nayak's avatar
Pradeep Nayak committed
22 23 24
 * Contact: info@jmaconsulting.biz
 *          JMA Consulting
 *          215 Spadina Ave, Ste 400
25
 *          Toronto, ON
Pradeep Nayak's avatar
Pradeep Nayak committed
26 27
 *          Canada   M5T 2C7
 */
Pradeep Nayak's avatar
Pradeep Nayak committed
28 29 30 31

-- Accounting integration
SELECT @option_group_id_arel := max(id) from civicrm_option_group where name = 'account_relationship';

32 33 34
DELETE FROM civicrm_option_value WHERE option_group_id = @option_group_id_arel AND name = 'Accounts Payable Account is';

DELETE ci, ceft, ceft1, cft FROM `civicrm_entity_financial_trxn` ceft
35
LEFT JOIN civicrm_financial_trxn  cft ON cft.id = ceft.financial_trxn_id
36 37 38
LEFT JOIN civicrm_entity_financial_trxn ceft1 ON cft.id = ceft1.financial_trxn_id  AND ceft1.entity_table = 'civicrm_financial_item'
LEFT JOIN civicrm_financial_item ci ON ci.id = ceft1.entity_id
WHERE ceft.entity_table = 'civicrm_grant';
Pradeep Nayak's avatar
Pradeep Nayak committed
39

40 41 42
-- RG-149
DELETE cg, cv FROM civicrm_option_group cg
INNER JOIN civicrm_option_value cv ON cg.id = cv.option_group_id
43 44 45 46 47 48 49 50
WHERE cg.name = 'grant_info_too_late';

-- RG-181
DROP TABLE IF EXISTS civicrm_entity_payment;
DROP TABLE IF EXISTS civicrm_payment;

ALTER TABLE civicrm_grant_program DROP FOREIGN KEY FK_civicrm_grant_program_status_id, DROP INDEX FK_civicrm_grant_program_status_id;
ALTER TABLE civicrm_grant_program DROP FOREIGN KEY FK_civicrm_grant_program_grant_type_id, DROP INDEX FK_civicrm_grant_program_grant_type_id;
51

52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
ALTER TABLE civicrm_grant DROP FOREIGN KEY FK_civicrm_grant_grant_program_id, DROP INDEX FK_civicrm_grant_grant_program_id;

ALTER TABLE `civicrm_grant` DROP `grant_program_id`, DROP `grant_rejected_reason_id`, DROP `assessment`;

TRUNCATE TABLE civicrm_grant;

DROP TABLE IF EXISTS civicrm_grant_program;

DELETE FROM civicrm_option_group WHERE name = 'grant_payment_status';

DELETE FROM civicrm_option_group WHERE name = 'grant_program_status';

DELETE FROM civicrm_option_group WHERE name = 'allocation_algorithm';

DELETE FROM civicrm_option_group WHERE name = 'grant_thresholds';

DELETE FROM civicrm_option_group WHERE name = 'reason_grant_ineligible';

DELETE FROM civicrm_option_group WHERE name = 'reason_grant_incomplete';

DELETE FROM civicrm_option_group WHERE name = 'msg_tpl_workflow_grant';

SELECT @grantStatus := id FROM  civicrm_option_group WHERE name = 'grant_status';

UPDATE civicrm_option_value SET label = 'Approved', name = 'Approved', weight = 2 WHERE option_group_id = @grantStatus AND label = 'Eligible';
UPDATE civicrm_option_value SET label = 'Rejected', name = 'Rejected', weight = 3 WHERE option_group_id = @grantStatus AND label = 'Ineligible';
UPDATE civicrm_option_value SET weight = 4 WHERE option_group_id = @grantStatus AND label = 'Paid';
UPDATE civicrm_option_value SET weight = 5 WHERE option_group_id = @grantStatus AND label = 'Awaiting Information';
UPDATE civicrm_option_value SET weight = 6 WHERE option_group_id = @grantStatus AND label = 'Withdrawn';

DELETE FROM civicrm_option_value WHERE label = 'Approved for Payment' AND option_group_id = @grantStatus;

SELECT @parentId1 := id FROM civicrm_navigation WHERE name = 'CiviGrant';
SELECT @parentId2 := id FROM civicrm_navigation WHERE name = 'Grants';

DELETE FROM civicrm_navigation WHERE parent_id = @parentId2 AND label = 'Find Grant Payments' AND name = 'Find Grant Payments' AND url = 'civicrm/grant/payment/search&reset=1';
DELETE FROM civicrm_navigation WHERE parent_id = @parentId2 AND label = 'New Grant Program' AND name = 'New Grant Program' AND url = 'civicrm/grant_program?action=add&reset=1';
DELETE FROM civicrm_navigation WHERE parent_id = @parentId1 AND label = 'Grant Programs' AND name = 'Grant Programs' AND url = 'civicrm/grant_program&reset=1';

91 92 93 94 95 96 97 98 99
DELETE FROM civicrm_msg_template WHERE msg_title = 'Trial Allocation of Funds';
DELETE FROM civicrm_msg_template WHERE msg_title = 'Grants Eligible Receipt';
DELETE FROM civicrm_msg_template WHERE msg_title = 'Grants Awaiting Information Receipt';
DELETE FROM civicrm_msg_template WHERE msg_title = 'Grants Ineligible Receipt';
DELETE FROM civicrm_msg_template WHERE msg_title = 'Grants Paid Receipt';
DELETE FROM civicrm_msg_template WHERE msg_title = 'Grants Approved for Payment Receipt';
DELETE FROM civicrm_msg_template WHERE msg_title = 'Grants Submitted Receipt';
DELETE FROM civicrm_msg_template WHERE msg_title = 'Grants Withdrawn Receipt';
DELETE FROM civicrm_msg_template WHERE msg_title = 'Grant Payment Check';
Pradeep Nayak's avatar
Pradeep Nayak committed
100 101
DELETE FROM civicrm_msg_template WHERE msg_title = 'Grant Payment Report';

Stan Dragnev's avatar
Stan Dragnev committed
102
ALTER table civicrm_grant DROP column grant_incomplete_reason_id;
103

104
-- RG-212
105
DELETE cov FROM civicrm_option_group cog INNER JOIN civicrm_option_value cov ON cov.option_group_id = cog.id WHERE  cog.name = 'activity_type' AND cov.name IN ('grant_status_change', 'grant_payment');