Merge pull request #4054 from eileenmcnaughton/CRM-15237
[civicrm-core.git] / CRM / Upgrade / Incremental / sql / 3.1.beta2.mysql.tpl
CommitLineData
6a488035
TO
1-- CRM-3507: upgrade message templates (if changed)
2{include file='../CRM/Upgrade/3.1.beta2.msg_template/civicrm_msg_template.tpl'}
3
4-- CRM-5496
5 SELECT @option_group_id_report := max(id) from civicrm_option_group where name = 'report_template';
6 SELECT @caseCompId := max(id) FROM civicrm_component where name = 'CiviCase';
10824d34 7 INSERT INTO
8 `civicrm_option_value` (`option_group_id`, {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, {localize field='description'}description{/localize}, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
6a488035
TO
9 VALUES
10 (@option_group_id_report , {localize}'Case Summary Report'{/localize} , 'case/summary' , 'CRM_Report_Form_Case_Summary' , NULL, 0, NULL, 24, {localize}'Provides a summary of cases and their duration by date range, status, staff member and / or case role.'{/localize} , 0, 0, 1, @caseCompId, NULL),
11 (@option_group_id_report , {localize}'Case Time Spent Report'{/localize} , 'case/timespent' , 'CRM_Report_Form_Case_TimeSpent' , NULL, 0, NULL, 25, {localize}'Aggregates time spent on case and / or or non-case activities by activity type and contact.'{/localize} , 0, 0, 1, @caseCompId, NULL),
12 (@option_group_id_report , {localize}'Contact Demographics Report'{/localize}, 'case/demographics', 'CRM_Report_Form_Case_Demographics', NULL, 0, NULL, 26, {localize}'Demographic breakdown for case clients (and or non-case contacts) in your database. Includes custom contact fields.'{/localize}, 0, 0, 1, @caseCompId, NULL),
13 (@option_group_id_report , {localize}'Database Log Report'{/localize} , 'contact/log' , 'CRM_Report_Form_Contact_Log' , NULL, 0, NULL, 27, {localize}'Log of contact and activity records created or updated in a given date range.'{/localize} , 0, 0, 1, NULL , NULL);
14-- CRM-5438
15UPDATE civicrm_navigation SET permission ='access CiviCRM', permission_operator ='' WHERE civicrm_navigation.name= 'Manage Groups';
16
17-- CRM-5450
10824d34 18
6a488035
TO
19SELECT @option_group_id_address_options := max(id) from civicrm_option_group where name = 'address_options';
20SELECT @adOpt_max_val := MAX(ROUND(op.value)) FROM civicrm_option_value op WHERE op.option_group_id = @option_group_id_address_options;
21SELECT @adOpt_max_wt := MAX(ROUND(val.weight)) FROM civicrm_option_value val where val.option_group_id = @option_group_id_address_options;
22
10824d34 23INSERT INTO
24 civicrm_option_value(`option_group_id`, {localize field='label'}`label`{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
6a488035
TO
25VALUES(@option_group_id_address_options, {localize}'Street Address Parsing'{/localize}, (SELECT @adOpt_max_val := @adOpt_max_val+1), 'street_address_parsing', NULL, 0, NULL, (SELECT @adOpt_max_wt := @adOpt_max_wt + 1 ), 0, 0, 1, NULL, NULL);
26
27--fix broken default address options.
28SELECT @domain_id := min(id) FROM civicrm_domain;
29
30UPDATE `civicrm_preferences`
31 SET `address_options` = REPLACE( `address_options`, '\ 113\ 114', '' )
10824d34 32 WHERE `domain_id` = @domain_id
6a488035
TO
33 AND `contact_id` IS NULL;
34
35-- CRM-5528
36
37SELECT @option_group_id_cdt := max(id) from civicrm_option_group where name = 'custom_data_type';
38
10824d34 39INSERT INTO
40 `civicrm_option_value` (`option_group_id`, {localize field='label'}`label`{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `is_optgroup`, `is_reserved`, `is_active`)
6a488035
TO
41VALUES(@option_group_id_cdt, {localize}'Participant Event Type'{/localize}, '3', 'ParticipantEventType', NULL, 0, NULL, 3, 0, 0, 1);
42
10824d34 43-- add table dashboard and dashboard contact
6a488035
TO
44-- CRM-5423
45
46 CREATE TABLE civicrm_dashboard (
47 id int(10) unsigned NOT NULL auto_increment,
48 domain_id int(10) unsigned NOT NULL COMMENT 'Domain for dashboard',
49 {localize field='label'}label varchar(255) COMMENT 'Widget Title' default NULL{/localize},
50 url varchar(255) default NULL COMMENT 'url in case of external widget',
51 content text COMMENT 'widget content',
52 permission varchar(255) default NULL COMMENT 'Permission for the widget',
53 permission_operator varchar(3) default NULL COMMENT 'Permission Operator',
54 column_no tinyint(4) default '0' COMMENT 'column no for this widget',
55 is_minimized tinyint(4) default '0' COMMENT 'Is Minimized?',
56 is_fullscreen tinyint(4) default '1' COMMENT 'Is Fullscreen?',
57 is_active tinyint(4) default '0' COMMENT 'Is this widget active?',
58 weight int(11) default '0' COMMENT 'Ordering of the widgets.',
59 created_date datetime default NULL COMMENT 'When was content populated',
60 PRIMARY KEY (`id`),
61 KEY `FK_civicrm_dashboard_domain_id` (`domain_id`)
62 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
63
10824d34 64 INSERT INTO civicrm_dashboard
65 ( domain_id, {localize field='label'}`label`{/localize}, url, content, permission, permission_operator, column_no, is_minimized, is_fullscreen, is_active, weight, created_date )
6a488035
TO
66 VALUES
67 ( @domain_id, {localize }'Activities'{/localize}, 'civicrm/dashlet/activity&reset=1&snippet=4', NULL, NULL, NULL, 0, 0,'1', '1', NULL, NULL );
68
69 CREATE TABLE civicrm_dashboard_contact (
70 id int(10) unsigned NOT NULL auto_increment,
71 dashboard_id int(10) unsigned NOT NULL COMMENT 'Dashboard ID',
72 contact_id int(10) unsigned NOT NULL COMMENT 'Contact ID',
73 column_no tinyint(4) default '0' COMMENT 'column no for this widget',
74 is_minimized tinyint(4) default '0' COMMENT 'Is Minimized?',
75 is_fullscreen tinyint(4) default '1' COMMENT 'Is Fullscreen?',
76 is_active tinyint(4) default '0' COMMENT 'Is this widget active?',
77 weight int(11) default '0' COMMENT 'Ordering of the widgets.',
78 PRIMARY KEY (`id`),
79 KEY `FK_civicrm_dashboard_contact_dashboard_id` (`dashboard_id`),
80 KEY `FK_civicrm_dashboard_contact_contact_id` (`contact_id`)
81 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
82
83-- CRM-5549
84
85ALTER TABLE `civicrm_report_instance`
86 ADD `domain_id` INT(10) UNSIGNED NOT NULL COMMENT 'Which Domain is this instance for' AFTER `id`;
87
88UPDATE `civicrm_report_instance` SET domain_id = @domain_id;
89
90ALTER TABLE `civicrm_report_instance`
91 ADD CONSTRAINT `FK_civicrm_report_instance_domain_id` FOREIGN KEY (`domain_id`) REFERENCES `civicrm_domain` (`id`);
92
93-- CRM-5546
94
95ALTER TABLE `civicrm_price_set`
96 ADD `domain_id` INT(10) UNSIGNED DEFAULT NULL COMMENT 'Which Domain is this price-set for' AFTER `id`;
97ALTER TABLE `civicrm_price_set`
98 ADD CONSTRAINT `FK_civicrm_price_set_domain_id` FOREIGN KEY (`domain_id`) REFERENCES `civicrm_domain` (`id`);
99
100ALTER TABLE `civicrm_option_value`
101 ADD `domain_id` INT(10) UNSIGNED DEFAULT NULL COMMENT 'Which Domain is this option value for' AFTER `component_id`;
102
103ALTER TABLE `civicrm_option_value`
104 ADD CONSTRAINT `FK_civicrm_option_value_domain_id` FOREIGN KEY (`domain_id`) REFERENCES `civicrm_domain` (`id`);
105
106SELECT @option_group_id_grant := id from civicrm_option_group where name = 'grant_type';
107SELECT @option_group_id_email := id from civicrm_option_group where name = 'from_email_address';
108
109UPDATE `civicrm_option_value` SET domain_id = @domain_id WHERE option_group_id IN (@option_group_id_grant,@option_group_id_email );