1 -- +--------------------------------------------------------------------+
2 -- | CiviCRM version 3.2 |
3 -- +--------------------------------------------------------------------+
4 -- | Copyright CiviCRM LLC (c) 2004-2010 |
5 -- +--------------------------------------------------------------------+
6 -- | This file is a part of CiviCRM. |
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. |
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. |
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 -- +--------------------------------------------------------------------+
25 -- /*******************************************************
27 -- * adding of new tables
29 -- *******************************************************/
32 -- /*******************************************************
34 -- * civicrm_accept_credit_card
36 -- *******************************************************/
37 CREATE TABLE civicrm_accept_credit_card (
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?',
45 is_active tinyint COMMENT 'Is this property active?'
51 FOREIGN KEY (domain_id) REFERENCES civicrm_domain(id)
53 ) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
58 -- /*******************************************************
60 -- * civicrm_contribtion_type
62 -- *******************************************************/
64 CREATE TABLE civicrm_contribution_type (
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?',
74 is_active tinyint COMMENT 'Is this property active?'
78 , UNIQUE INDEX UI_name_domain_id(
84 FOREIGN KEY (domain_id) REFERENCES civicrm_domain(id)
86 ) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
88 -- /*******************************************************
90 -- * civicrm_payment_instrument
94 -- *******************************************************/
96 CREATE TABLE civicrm_payment_instrument (
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?',
104 is_active tinyint COMMENT 'Is this property active?'
108 , UNIQUE INDEX UI_name_domain_id(
114 FOREIGN KEY (domain_id) REFERENCES civicrm_domain(id)
116 ) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
119 -- /*******************************************************
121 -- * civicrm_contribution
125 -- *******************************************************/
127 CREATE TABLE civicrm_contribution (
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',
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',
146 source varchar(255) COMMENT 'Origin of this Contribution.'
150 , UNIQUE INDEX UI_contrib_trxn_id_domain_id(
154 , UNIQUE INDEX UI_contrib_invoice_id_domain_id(
161 FOREIGN KEY (domain_id) REFERENCES civicrm_domain(id)
163 FOREIGN KEY (contact_id) REFERENCES civicrm_contact(id)
165 FOREIGN KEY (contribution_type_id) REFERENCES civicrm_contribution_type(id)
167 FOREIGN KEY (payment_instrument_id) REFERENCES civicrm_payment_instrument(id)
169 ) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
173 -- /*******************************************************
175 -- * civicrm_contribution_page
177 -- *******************************************************/
178 CREATE TABLE civicrm_contribution_page (
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',
200 is_active tinyint COMMENT 'Is this property active?'
206 FOREIGN KEY (domain_id) REFERENCES civicrm_domain(id)
208 FOREIGN KEY (contribution_type_id) REFERENCES civicrm_contribution_type(id)
210 ) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
216 -- /*******************************************************
218 -- * civicrm_dupe_match
222 -- *******************************************************/
223 CREATE TABLE civicrm_dupe_match (
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',
229 rule varchar(255) NOT NULL COMMENT 'String that can Contains valid civicrm core or custom field name,parenthesis,,AND,OR '
235 FOREIGN KEY (domain_id) REFERENCES civicrm_domain(id)
237 ) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
241 -- /*******************************************************
243 -- * civicrm_financial_trxn
247 -- *******************************************************/
249 CREATE TABLE civicrm_financial_trxn (
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',
264 trxn_result_code varchar(255) COMMENT 'processor result code'
268 , INDEX index_entity(
272 , UNIQUE INDEX UI_ft_trxn_id_domain_id(
278 FOREIGN KEY (domain_id) REFERENCES civicrm_domain(id)
280 ) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
283 -- /*******************************************************
285 -- * civicrm_module_profile
289 -- *******************************************************/
291 CREATE TABLE civicrm_module_profile (
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.',
300 weight int NOT NULL DEFAULT 1 COMMENT 'each internal or external module uses this to order multiple profiles associated with an entity_id'
304 , INDEX index_entity(
310 FOREIGN KEY (domain_id) REFERENCES civicrm_domain(id)
312 FOREIGN KEY (uf_group_id) REFERENCES civicrm_uf_group(id)
314 ) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
317 -- /*******************************************************
323 -- *******************************************************/
325 CREATE TABLE civicrm_uf_join (
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.',
334 uf_group_id int unsigned NOT NULL COMMENT 'Which form does this field belong to.'
338 , INDEX index_entity(
344 FOREIGN KEY (uf_group_id) REFERENCES civicrm_uf_group(id)
346 ) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
351 -- /*******************************************************
353 -- * Insert Default Data in newly created tables
355 -- *******************************************************/
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);
359 INSERT INTO `civicrm_contribution_type` VALUES (3, 1, 'Campaign Contribution', NULL, NULL, 0, 0, 1);
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);
364 INSERT INTO `civicrm_payment_instrument` VALUES (4, 1, 'Check', NULL, 1, 1);
365 INSERT INTO `civicrm_payment_instrument` VALUES (5, 1, 'EFT', NULL, 1, 1);
367 INSERT INTO `civicrm_dupe_match` VALUES (1, 1, 'contact_individual', 'first_name AND last_name AND email');
371 -- /*******************************************************
373 -- * Modify the civicrm_uf_group Table Structure
375 -- *******************************************************/
377 ALTER TABLE `civicrm_uf_group` DROP `weight` ;
380 -- /*******************************************************
382 -- * Modify the civicrm_uf_field Table Structure
384 -- *******************************************************/
386 ALTER TABLE `civicrm_uf_field` DROP `is_registration` ,
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`);
392 ALTER TABLE `civicrm_uf_field` ADD `phone_type` VARCHAR( 64 ) COMMENT 'Phone type, if required';
396 -- /*******************************************************
398 -- * Modify the civicrm_custom_option Table Structure
400 -- *******************************************************/
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' ;
405 ALTER TABLE `civicrm_custom_option` ADD `entity_id` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL;
406 UPDATE `civicrm_custom_option` SET entity_id = custom_field_id;
408 ALTER TABLE `civicrm_custom_option` DROP KEY `UI_label_custom_field_id`;
410 ALTER TABLE `civicrm_custom_option` DROP FOREIGN KEY `civicrm_custom_option_ibfk_1`;
412 ALTER TABLE `civicrm_custom_option` DROP `custom_field_id`;
414 ALTER TABLE `civicrm_custom_option` ADD INDEX `index_entity` ( `entity_table`, `entity_id` ) ;
418 -- /*******************************************************
420 -- * Insert Default data in to civicrm_accept_credit_card
422 -- *******************************************************/
424 INSERT INTO `civicrm_accept_credit_card` VALUES (1,1,'Visa','Visa',0,1),
425 (2,1,'MasterCard','Master Card',0,1),
426 (3,1,'Amex','American Express',0,1),
427 (4,1,'Discover','Discover',0,1);
430 -- /*******************************************************
432 -- * Modify the civicrm_custom_group Table Structure
434 -- *******************************************************/
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.).';
439 -- /*******************************************************
441 -- * Modify the civicrm_custom_field Table Structure
443 -- *******************************************************/
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.';
449 -- /*******************************************************
453 -- *******************************************************/
455 DROP TABLE IF EXISTS civicrm_donation_page;