commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / CRM / Upgrade / Incremental / sql / 4.6.3.mysql.tpl
1 {* file to handle db changes in 4.6.3 during upgrade *}
2 -- CRM-16307 fix CRM-15578 typo - Require access CiviMail permission for A/B Testing feature
3 UPDATE civicrm_navigation
4 SET permission = 'access CiviMail', permission_operator = ''
5 WHERE name = 'New A/B Test' OR name = 'Manage A/B Tests';
6
7 --CRM-16320
8 {include file='../CRM/Upgrade/4.6.3.msg_template/civicrm_msg_template.tpl'}
9
10 -- CRM-16452 Missing administrative divisions for Georgia
11 SELECT @country_id := id from civicrm_country where name = 'Georgia' AND iso_code = 'GE';
12 INSERT INTO civicrm_state_province (country_id, abbreviation, name)
13 VALUES
14 (@country_id, "AB", "Abkhazia"),
15 (@country_id, "AJ", "Adjara"),
16 (@country_id, "TB", "Tbilisi"),
17 (@country_id, "GU", "Guria"),
18 (@country_id, "IM", "Imereti"),
19 (@country_id, "KA", "Kakheti"),
20 (@country_id, "KK", "Kvemo Kartli"),
21 (@country_id, "MM", "Mtskheta-Mtianeti"),
22 (@country_id, "RL", "Racha-Lechkhumi and Kvemo Svaneti"),
23 (@country_id, "SZ", "Samegrelo-Zemo Svaneti"),
24 (@country_id, "SJ", "Samtskhe-Javakheti"),
25 (@country_id, "SK", "Shida Kartli");
26
27 --CRM-16391 and CRM-16392
28 UPDATE civicrm_uf_field
29 SET {localize field="label"}label = '{ts escape="sql"}Financial Type{/ts}'{/localize}
30 WHERE field_type = 'Contribution' AND field_name='financial_type';
31
32 UPDATE civicrm_uf_field
33 SET {localize field="label"}label = '{ts escape="sql"}Membership Type{/ts}'{/localize}
34 WHERE field_type = 'Membership' AND field_name='membership_type';
35
36 -- CRM-16367: adding the shared payment token table
37 CREATE TABLE IF NOT EXISTS `civicrm_payment_token` (
38 `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Payment Token ID',
39 `contact_id` int unsigned NOT NULL COMMENT 'FK to Contact ID for the owner of the token',
40 `payment_processor_id` int unsigned NOT NULL ,
41 `token` varchar(255) NOT NULL COMMENT 'Externally provided token string',
42 `created_date` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT 'Date created',
43 `created_id` int unsigned COMMENT 'Contact ID of token creator',
44 `expiry_date` datetime COMMENT 'Date this token expires',
45 `email` varchar(255) COMMENT 'Email at the time of token creation. Useful for fraud forensics',
46 `billing_first_name` varchar(255) COMMENT 'Billing first name at the time of token creation. Useful for fraud forensics',
47 `billing_middle_name` varchar(255) COMMENT 'Billing middle name at the time of token creation. Useful for fraud forensics',
48 `billing_last_name` varchar(255) COMMENT 'Billing last name at the time of token creation. Useful for fraud forensics',
49 `masked_account_number` varchar(255) COMMENT 'Holds the part of the card number or account details that may be retained or displayed',
50 `ip_address` varchar(255) COMMENT 'IP used when creating the token. Useful for fraud forensics' ,
51 PRIMARY KEY ( `id` ),
52 CONSTRAINT FK_civicrm_payment_token_contact_id FOREIGN KEY (`contact_id`)
53 REFERENCES `civicrm_contact`(`id`) ON DELETE CASCADE,
54 CONSTRAINT FK_civicrm_payment_token_payment_processor_id FOREIGN KEY (`payment_processor_id`)
55 REFERENCES `civicrm_payment_processor`(`id`) ON DELETE RESTRICT,
56 CONSTRAINT FK_civicrm_payment_token_created_id FOREIGN KEY (`created_id`)
57 REFERENCES `civicrm_contact`(`id`) ON DELETE SET NULL
58 )
59 ENGINE=InnoDB DEFAULT
60 CHARACTER SET utf8
61 COLLATE utf8_unicode_ci;
62
63 -- CRM-16367: adding a reference to the token table to the recurring contributions table.
64 ALTER TABLE civicrm_contribution_recur
65 ADD COLUMN `payment_token_id` int(10) unsigned DEFAULT NULL COMMENT 'Optionally used to store a link to a payment token used for this recurring contribution.',
66 ADD CONSTRAINT `FK_civicrm_contribution_recur_payment_token_id` FOREIGN KEY (`payment_token_id`) REFERENCES `civicrm_payment_token` (`id`) ON DELETE SET NULL;
67
68 --CRM-16480: set total_amount and financial_type fields 'is_required' to null
69 SELECT @uf_group_id_contribution := max(id) from civicrm_uf_group where name = 'contribution_batch_entry';
70 SELECT @uf_group_id_membership := max(id) from civicrm_uf_group where name = 'membership_batch_entry';
71
72 UPDATE civicrm_uf_field
73 SET is_required = 0 WHERE uf_group_id IN (@uf_group_id_contribution, @uf_group_id_membership) AND field_name IN ('financial_type', 'total_amount');