Merge pull request #6368 from colemanw/gender
[civicrm-core.git] / sql / civicrm_upgradedb_v1.2_v1.3_41.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
25-- /*******************************************************
26-- *
27-- * adding of new tables
28-- *
29-- *******************************************************/
30
31
32-- /*******************************************************
33-- *
34-- * civicrm_accept_credit_card
35-- *
36-- *******************************************************/
37CREATE TABLE civicrm_accept_credit_card (
38
39
40 id int unsigned NOT NULL AUTO_INCREMENT COMMENT ' Accept Credit Card ID',
41 domain_id int unsigned NOT NULL COMMENT 'Which Domain owns this credit card.',
42 name varchar(64) COMMENT ' Credit Card Type as defined by the payment processor.',
43 title varchar(64) COMMENT 'Descriptive Credit Card Name.',
44 is_reserved tinyint COMMENT 'Is this a predefined system object?',
66cae705 45 is_active tinyint COMMENT 'Is this property active?'
6a488035
TO
46,
47 PRIMARY KEY ( id )
66cae705
EM
48
49
50,
6a488035 51 FOREIGN KEY (domain_id) REFERENCES civicrm_domain(id)
66cae705 52
6a488035
TO
53) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
54
55
56
57
58-- /*******************************************************
59-- *
60-- * civicrm_contribtion_type
61-- *
62-- *******************************************************/
63
64CREATE TABLE civicrm_contribution_type (
65
66
67 id int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Contribution Type ID',
68 domain_id int unsigned NOT NULL COMMENT 'Which Domain owns this contribution type.',
69 name varchar(64) COMMENT 'Contribution Type Name.',
70 accounting_code varchar(64) COMMENT 'Optional value for mapping contributions to accounting system codes for each type/category of contribution.',
71 description varchar(255) COMMENT 'Contribution Type Description.',
72 is_deductible tinyint DEFAULT 1 COMMENT 'Is this contribution type tax-deductible? If true, contributions of this type may be fully OR partially deductible - non-deductible amount is stored in the Contribution record.',
73 is_reserved tinyint COMMENT 'Is this a predefined system object?',
66cae705 74 is_active tinyint COMMENT 'Is this property active?'
6a488035
TO
75,
76 PRIMARY KEY ( id )
66cae705 77
6a488035
TO
78 , UNIQUE INDEX UI_name_domain_id(
79 name
80 , domain_id
81 )
66cae705
EM
82
83,
6a488035 84 FOREIGN KEY (domain_id) REFERENCES civicrm_domain(id)
66cae705 85
6a488035
TO
86) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
87
88-- /*******************************************************
89-- *
90-- * civicrm_payment_instrument
91-- *
66cae705 92-- *
6a488035
TO
93-- *
94-- *******************************************************/
95
96CREATE TABLE civicrm_payment_instrument (
97
98
99 id int unsigned NOT NULL AUTO_INCREMENT COMMENT ' Payment Instrument ID',
100 domain_id int unsigned NOT NULL COMMENT 'Which Domain owns this payment instrument.',
101 name varchar(64) COMMENT ' Payment Instrument Name.',
102 description varchar(255) COMMENT ' Payment Instrument Description.',
103 is_reserved tinyint COMMENT 'Is this a predefined system object?',
66cae705 104 is_active tinyint COMMENT 'Is this property active?'
6a488035
TO
105,
106 PRIMARY KEY ( id )
66cae705 107
6a488035
TO
108 , UNIQUE INDEX UI_name_domain_id(
109 name
110 , domain_id
111 )
66cae705
EM
112
113,
6a488035 114 FOREIGN KEY (domain_id) REFERENCES civicrm_domain(id)
66cae705 115
6a488035
TO
116) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
117
118
119-- /*******************************************************
120-- *
121-- * civicrm_contribution
122-- *
123-- *
124-- *
125-- *******************************************************/
66cae705 126
6a488035
TO
127CREATE TABLE civicrm_contribution (
128
129 id int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Contribution ID',
130 domain_id int unsigned NOT NULL COMMENT 'Which Domain owns this contribution class.',
131 contact_id int unsigned NOT NULL COMMENT 'FK to Contact ID',
132 contribution_type_id int unsigned COMMENT 'FK to Contribution Type',
133 payment_instrument_id int unsigned COMMENT 'FK to Payment Instrument',
134 receive_date datetime NOT NULL COMMENT 'when was gift received',
135 non_deductible_amount decimal(20,2) DEFAULT 0 COMMENT 'Portion of total amount which is NOT tax deductible. Equal to total_amount for non-deductible contribution types.',
136 total_amount decimal(20,2) NOT NULL COMMENT 'Total amount of this contribution. Use market value for non-monetary gifts.',
137 fee_amount decimal(20,2) COMMENT 'actual processor fee if known - may be 0.',
138 net_amount decimal(20,2) COMMENT 'actual funds transfer amount; total less fees; if processor does not report actual fee during transaction, this is set to total_amount.',
139 trxn_id varchar(255) COMMENT 'unique transaction id; may be processor id, bank id + trans id, or account number + check number... depending on payment_method',
140 invoice_id varchar(255) COMMENT 'unique invoice id, system generated or passed in',
141 currency varchar(64) NOT NULL COMMENT '3 character string, value derived from payment processor config setting.',
142 cancel_date datetime COMMENT 'when was gift cancelled',
143 cancel_reason text ,
144 receipt_date datetime COMMENT 'when (if) receipt was sent; populated automatically for online donations w/ automatic receipting',
145 thankyou_date datetime COMMENT 'when (if) was donor thanked',
66cae705 146 source varchar(255) COMMENT 'Origin of this Contribution.'
6a488035
TO
147,
148 PRIMARY KEY ( id )
66cae705 149
6a488035
TO
150 , UNIQUE INDEX UI_contrib_trxn_id_domain_id(
151 trxn_id
152 , domain_id
153 )
154 , UNIQUE INDEX UI_contrib_invoice_id_domain_id(
155 invoice_id
156 , domain_id
157 )
66cae705
EM
158
159
160,
6a488035 161 FOREIGN KEY (domain_id) REFERENCES civicrm_domain(id)
66cae705 162,
6a488035 163 FOREIGN KEY (contact_id) REFERENCES civicrm_contact(id)
66cae705 164,
6a488035 165 FOREIGN KEY (contribution_type_id) REFERENCES civicrm_contribution_type(id)
66cae705 166,
6a488035 167 FOREIGN KEY (payment_instrument_id) REFERENCES civicrm_payment_instrument(id)
66cae705 168
6a488035
TO
169) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
170
171
172
173-- /*******************************************************
174-- *
175-- * civicrm_contribution_page
176-- *
177-- *******************************************************/
178 CREATE TABLE civicrm_contribution_page (
179
180
181 id int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Contribution Id',
182 domain_id int unsigned NOT NULL COMMENT 'Which Domain owns this page',
183 title varchar(255) COMMENT 'Contribution Page title. For top of page display',
184 intro_text text COMMENT 'Text and html allowed. Displayed below title.',
185 contribution_type_id int unsigned NOT NULL COMMENT 'default Contribution type assigned to contributions submitted via this page, e.g. Contribution, Campaign Contribution',
186 is_credit_card_only tinyint DEFAULT 0 COMMENT 'if true - processing logic must reject transaction at confirmation stage if pay method != credit card',
187 is_allow_other_amount tinyint DEFAULT 0 COMMENT 'if true, page will include an input text field where user can enter their own amount',
188 default_amount decimal(20,2) COMMENT 'the default amount allowed.',
189 min_amount decimal(20,2) COMMENT 'if other amounts allowed, user can configure minimum allowed.',
190 max_amount decimal(20,2) COMMENT 'if other amounts allowed, user can configure maximum allowed.',
191 thankyou_title varchar(255) COMMENT 'Title for Thank-you page (header title tag, and display at the top of the page).',
192 thankyou_text text COMMENT 'text and html allowed; displayed above result on success page',
193 thankyou_footer text COMMENT 'Text and html allowed; displayed at the bottom of the success page. Common usage is to include link(s) to other pages such as tell-a-friend, etc.',
194 is_email_receipt tinyint DEFAULT 1 COMMENT 'if true, receipt is automatically emailed to contact on success',
195 receipt_from_name varchar(255) COMMENT 'FROM email name used for receipts generated by contributions to this contribution page.',
196 receipt_from_email varchar(255) COMMENT 'FROM email address used for receipts generated by contributions to this contribution page.',
197 cc_receipt varchar(255) COMMENT 'comma-separated list of email addresses to cc each time a receipt is sent',
198 bcc_receipt varchar(255) COMMENT 'comma-separated list of email addresses to bcc each time a receipt is sent',
199 receipt_text text COMMENT 'text to include above standard receipt info on receipt email; emails are text-only, so do not allow html for now',
66cae705 200 is_active tinyint COMMENT 'Is this property active?'
6a488035
TO
201,
202 PRIMARY KEY ( id )
66cae705
EM
203
204
205,
6a488035 206 FOREIGN KEY (domain_id) REFERENCES civicrm_domain(id)
66cae705 207,
6a488035 208 FOREIGN KEY (contribution_type_id) REFERENCES civicrm_contribution_type(id)
66cae705 209
6a488035
TO
210) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
211
66cae705 212
6a488035
TO
213
214
215
216-- /*******************************************************
217-- *
218-- * civicrm_dupe_match
219-- *
66cae705 220-- *
6a488035
TO
221-- *
222-- *******************************************************/
223 CREATE TABLE civicrm_dupe_match (
224
225
226 id int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Unique DupeMatch ID',
227 domain_id int unsigned NOT NULL COMMENT 'Which Domain owns this contact',
228 entity_table varchar(64) NOT NULL COMMENT 'Name Of Entity Table',
66cae705 229 rule varchar(255) NOT NULL COMMENT 'String that can Contains valid civicrm core or custom field name,parenthesis,,AND,OR '
6a488035
TO
230,
231 PRIMARY KEY ( id )
66cae705
EM
232
233
234,
6a488035 235 FOREIGN KEY (domain_id) REFERENCES civicrm_domain(id)
66cae705 236
6a488035 237) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
66cae705 238
6a488035
TO
239
240
241-- /*******************************************************
242-- *
243-- * civicrm_financial_trxn
244-- *
66cae705 245-- *
6a488035
TO
246-- *
247-- *******************************************************/
66cae705 248
6a488035
TO
249 CREATE TABLE civicrm_financial_trxn (
250
251
252 id int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Gift ID',
253 domain_id int unsigned NOT NULL COMMENT 'Which Domain owns this gift class.',
254 entity_table varchar(64) COMMENT 'physical tablename for entity being extended by this data, e.g. civicrm_contact',
255 entity_id int unsigned NOT NULL COMMENT 'FK to record in the entity table specified by entity_table column.',
256 trxn_date datetime NOT NULL ,
257 trxn_type enum('Debit', 'Credit') NOT NULL ,
258 total_amount decimal(20,2) NOT NULL COMMENT 'amount of transaction',
259 fee_amount decimal(20,2) COMMENT 'actual processor fee if known - may be 0.',
260 net_amount decimal(20,2) COMMENT 'actual funds transfer amount; total less fees; if processor does not report actual fee during transaction, this is set to total_amount.',
261 currency varchar(64) NOT NULL COMMENT '3 character string, value derived from payment processor config setting.',
262 payment_processor varchar(64) NOT NULL COMMENT 'derived from Processor setting in civicrm.settings.php.',
263 trxn_id varchar(255) NOT NULL COMMENT 'unique processor transaction id, bank id + trans id,... depending on payment_method',
66cae705 264 trxn_result_code varchar(255) COMMENT 'processor result code'
6a488035
TO
265,
266 PRIMARY KEY ( id )
66cae705 267
6a488035
TO
268 , INDEX index_entity(
269 entity_table
270 , entity_id
271 )
272 , UNIQUE INDEX UI_ft_trxn_id_domain_id(
273 trxn_id
274 , domain_id
275 )
66cae705
EM
276
277,
6a488035 278 FOREIGN KEY (domain_id) REFERENCES civicrm_domain(id)
66cae705 279
6a488035
TO
280) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
281
282
283-- /*******************************************************
284-- *
285-- * civicrm_module_profile
286-- *
66cae705 287-- *
6a488035
TO
288-- *
289-- *******************************************************/
290
291 CREATE TABLE civicrm_module_profile (
292
293
294 id int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Unique ID',
295 domain_id int unsigned NOT NULL COMMENT 'Which Domain owns this module profile entry.',
296 module varchar(255) COMMENT 'Module Name.',
297 entity_table varchar(64) COMMENT 'physical tablename for entity being extended by this data, e.g. civicrm_contact',
298 entity_id int unsigned NOT NULL COMMENT 'FK to record in the entity table specified by entity_table column.',
299 uf_group_id int unsigned NOT NULL COMMENT 'Which form does this field belong to.',
66cae705 300 weight int NOT NULL DEFAULT 1 COMMENT 'each internal or external module uses this to order multiple profiles associated with an entity_id'
6a488035
TO
301,
302 PRIMARY KEY ( id )
66cae705 303
6a488035
TO
304 , INDEX index_entity(
305 entity_table
306 , entity_id
307 )
66cae705
EM
308
309,
6a488035 310 FOREIGN KEY (domain_id) REFERENCES civicrm_domain(id)
66cae705 311,
6a488035 312 FOREIGN KEY (uf_group_id) REFERENCES civicrm_uf_group(id)
66cae705 313
6a488035 314) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
66cae705 315
6a488035
TO
316
317-- /*******************************************************
318-- *
319-- * civicrm_uf_join
320-- *
66cae705 321-- *
6a488035
TO
322-- *
323-- *******************************************************/
66cae705 324
6a488035
TO
325 CREATE TABLE civicrm_uf_join (
326
327
328 id int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Unique table ID',
329 is_active tinyint DEFAULT 1 COMMENT 'Is this join currently active?',
330 module varchar(64) NOT NULL COMMENT 'Module which owns this uf_join instance, e.g. User Registration, CiviDonate, etc.',
331 entity_table varchar(64) COMMENT 'Name of table where item being referenced is stored. Modules which only need a single collection of uf_join instances may choose not to populate entity_table and entity_id.',
332 entity_id int unsigned COMMENT 'Foreign key to the referenced item.',
333 weight int NOT NULL DEFAULT 1 COMMENT 'Controls display order when multiple user framework groups are setup for concurrent display.',
66cae705 334 uf_group_id int unsigned NOT NULL COMMENT 'Which form does this field belong to.'
6a488035
TO
335,
336 PRIMARY KEY ( id )
66cae705 337
6a488035
TO
338 , INDEX index_entity(
339 entity_table
340 , entity_id
341 )
66cae705
EM
342
343,
6a488035 344 FOREIGN KEY (uf_group_id) REFERENCES civicrm_uf_group(id)
66cae705 345
6a488035
TO
346) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
347
348
349
350
351-- /*******************************************************
352-- *
353-- * Insert Default Data in newly created tables
354-- *
355-- *******************************************************/
356
357 INSERT INTO `civicrm_contribution_type` VALUES (1, 1, 'Donation', NULL, NULL, 1, 0, 1);
358 INSERT INTO `civicrm_contribution_type` VALUES (2, 1, 'Member Dues', NULL, NULL, 1, 0, 1);
66cae705 359 INSERT INTO `civicrm_contribution_type` VALUES (3, 1, 'Campaign Contribution', NULL, NULL, 0, 0, 1);
6a488035
TO
360
361 INSERT INTO `civicrm_payment_instrument` VALUES (1, 1, 'Credit Card', NULL, 1, 1);
362 INSERT INTO `civicrm_payment_instrument` VALUES (2, 1, 'Debit Card', NULL, 1, 1);
363 INSERT INTO `civicrm_payment_instrument` VALUES (3, 1, 'Cash', NULL, 1, 1);
66cae705 364 INSERT INTO `civicrm_payment_instrument` VALUES (4, 1, 'Check', NULL, 1, 1);
6a488035
TO
365 INSERT INTO `civicrm_payment_instrument` VALUES (5, 1, 'EFT', NULL, 1, 1);
366
367 INSERT INTO `civicrm_dupe_match` VALUES (1, 1, 'contact_individual', 'first_name AND last_name AND email');
66cae705 368
6a488035
TO
369
370
371-- /*******************************************************
372-- *
373-- * Modify the civicrm_uf_group Table Structure
374-- *
375-- *******************************************************/
66cae705 376
6a488035
TO
377 ALTER TABLE `civicrm_uf_group` DROP `weight` ;
378
379
380-- /*******************************************************
381-- *
382-- * Modify the civicrm_uf_field Table Structure
383-- *
384-- *******************************************************/
385
386 ALTER TABLE `civicrm_uf_field` DROP `is_registration` ,
387 DROP `is_match` ;
66cae705 388
6a488035
TO
389 ALTER TABLE `civicrm_uf_field` ADD `location_type_id` INT UNSIGNED COMMENT 'Location type of this mapping, if required';
390 ALTER TABLE `civicrm_uf_field` ADD FOREIGN KEY (`location_type_id`) REFERENCES `civicrm_location_type` (`id`);
391
392 ALTER TABLE `civicrm_uf_field` ADD `phone_type` VARCHAR( 64 ) COMMENT 'Phone type, if required';
66cae705
EM
393
394
6a488035
TO
395
396-- /*******************************************************
397-- *
398-- * Modify the civicrm_custom_option Table Structure
399-- *
400-- *******************************************************/
401
402 ALTER TABLE `civicrm_custom_option` ADD `entity_table` VARCHAR( 64 ) COMMENT 'Name of table where item being referenced is stored.' ;
403 UPDATE `civicrm_custom_option` SET `entity_table` = 'civicrm_custom_field' ;
404
66cae705 405 ALTER TABLE `civicrm_custom_option` ADD `entity_id` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL;
6a488035
TO
406 UPDATE `civicrm_custom_option` SET entity_id = custom_field_id;
407
408 ALTER TABLE `civicrm_custom_option` DROP KEY `UI_label_custom_field_id`;
409
410 ALTER TABLE `civicrm_custom_option` DROP FOREIGN KEY `civicrm_custom_option_ibfk_1`;
411
412 ALTER TABLE `civicrm_custom_option` DROP `custom_field_id`;
413
414 ALTER TABLE `civicrm_custom_option` ADD INDEX `index_entity` ( `entity_table`, `entity_id` ) ;
415
416
417
418-- /*******************************************************
419-- *
420-- * Insert Default data in to civicrm_accept_credit_card
421-- *
422-- *******************************************************/
423
424 INSERT INTO `civicrm_accept_credit_card` VALUES (1,1,'Visa','Visa',0,1),
c213dee5 425 (2,1,'MasterCard','Master Card',0,1),
426 (3,1,'Amex','American Express',0,1),
427 (4,1,'Discover','Discover',0,1);
6a488035
TO
428
429
430-- /*******************************************************
431-- *
432-- * Modify the civicrm_custom_group Table Structure
433-- *
434-- *******************************************************/
435
436 ALTER TABLE `civicrm_custom_group` CHANGE `extends` `extends` ENUM( 'Contact', 'Individual', 'Household', 'Organization', 'Location', 'Address', 'Contribution', 'Activity', 'Phonecall', 'Meeting', 'Group' ) DEFAULT 'Contact' COMMENT 'Type of object this group extends (can add other options later e.g. contact_address, etc.).';
437
438
439-- /*******************************************************
440-- *
441-- * Modify the civicrm_custom_field Table Structure
442-- *
443-- *******************************************************/
66cae705 444
6a488035
TO
445 ALTER TABLE `civicrm_custom_field` CHANGE `html_type` `html_type` ENUM( 'Text', 'TextArea', 'Select', 'Multi-Select', 'Radio', 'CheckBox', 'Select Date', 'Select State/Province', 'Select Country' ) DEFAULT NULL COMMENT 'HTML types plus several built-in extended types.';
446
447
448
449-- /*******************************************************
450-- *
451-- * Drop Old Tables
452-- *
453-- *******************************************************/
66cae705 454
6a488035
TO
455 DROP TABLE IF EXISTS civicrm_donation_page;
456
457