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