Merge remote-tracking branch 'upstream/4.3' into 4.3-master-2013-10-02-11-18-44
[civicrm-core.git] / xml / schema / Contact / Contact.xml
1 <?xml version="1.0" encoding="iso-8859-1" ?>
2
3 <table>
4 <base>CRM/Contact</base>
5 <class>Contact</class>
6 <name>civicrm_contact</name>
7 <comment>Contact objects are defined by a civicrm_contact record plus a related civicrm_contact_type record.</comment>
8 <add>1.1</add>
9 <log>true</log>
10 <field>
11 <name>id</name>
12 <type>int unsigned</type>
13 <title>Internal Contact ID</title>
14 <import>true</import>
15 <headerPattern>/internal|contact?|id$/i</headerPattern>
16 <required>true</required>
17 <comment>Unique Contact ID</comment>
18 <add>1.1</add>
19 </field>
20 <primaryKey>
21 <name>id</name>
22 <autoincrement>true</autoincrement>
23 </primaryKey>
24 <field>
25 <name>contact_type</name>
26 <title>Contact Type</title>
27 <type>varchar</type>
28 <length>64</length>
29 <comment>Type of Contact.</comment>
30 <export>true</export>
31 <pseudoconstant>
32 <table>civicrm_contact_type</table>
33 <keyColumn>name</keyColumn>
34 <labelColumn>label</labelColumn>
35 <condition>parent_id IS NULL</condition>
36 </pseudoconstant>
37 <add>1.1</add>
38 <change>3.1</change>
39 </field>
40 <index>
41 <name>index_contact_type</name>
42 <fieldName>contact_type</fieldName>
43 <add>2.1</add>
44 </index>
45 <field>
46 <name>contact_sub_type</name>
47 <title>Contact Subtype</title>
48 <type>varchar</type>
49 <length>255</length>
50 <export>true</export>
51 <import>true</import>
52 <headerPattern>/C(ontact )?(subtype|sub-type|sub type)/i</headerPattern>
53 <comment>May be used to over-ride contact view and edit templates.</comment>
54 <pseudoconstant>
55 <table>civicrm_contact_type</table>
56 <keyColumn>name</keyColumn>
57 <labelColumn>label</labelColumn>
58 <condition>parent_id IS NOT NULL</condition>
59 </pseudoconstant>
60 <add>1.5</add>
61 </field>
62 <index>
63 <name>index_contact_sub_type</name>
64 <fieldName>contact_sub_type</fieldName>
65 <add>2.1</add>
66 </index>
67 <field>
68 <name>do_not_email</name>
69 <type>boolean</type>
70 <import>true</import>
71 <headerPattern>/d(o )?(not )?(email)/i</headerPattern>
72 <dataPattern>/^\d{1,}$/</dataPattern>
73 <default>0</default>
74 <add>1.1</add>
75 </field>
76 <field>
77 <name>do_not_phone</name>
78 <type>boolean</type>
79 <default>0</default>
80 <import>true</import>
81 <headerPattern>/d(o )?(not )?(call|phone)/i</headerPattern>
82 <dataPattern>/^\d{1,}$/</dataPattern>
83 <add>1.1</add>
84 </field>
85 <field>
86 <name>do_not_mail</name>
87 <type>boolean</type>
88 <import>true</import>
89 <headerPattern>/^(d(o\s)?n(ot\s)?mail)|(\w*)?bulk\s?(\w*)$/i</headerPattern>
90 <dataPattern>/^\d{1,}$/</dataPattern>
91 <default>0</default>
92 <add>1.1</add>
93 </field>
94 <field>
95 <name>do_not_sms</name>
96 <type>boolean</type>
97 <import>true</import>
98 <headerPattern>/d(o )?(not )?(sms)/i</headerPattern>
99 <dataPattern>/^\d{1,}$/</dataPattern>
100 <default>0</default>
101 <add>3.0</add>
102 </field>
103 <field>
104 <name>do_not_trade</name>
105 <type>boolean</type>
106 <import>true</import>
107 <headerPattern>/d(o )?(not )?(trade)/i</headerPattern>
108 <dataPattern>/^\d{1,}$/</dataPattern>
109 <default>0</default>
110 <add>1.1</add>
111 </field>
112 <field>
113 <name>is_opt_out</name>
114 <type>boolean</type>
115 <title>No Bulk Emails (User Opt Out)</title>
116 <default>0</default>
117 <import>true</import>
118 <required>true</required>
119 <comment>Has the contact opted out from receiving all bulk email from the organization or site domain?</comment>
120 <add>1.1</add>
121 </field>
122 <field>
123 <name>legal_identifier</name>
124 <type>varchar</type>
125 <length>32</length>
126 <import>true</import>
127 <headerPattern>/legal\s?id/i</headerPattern>
128 <dataPattern>/\w+?\d{5,}/</dataPattern>
129 <comment>May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.</comment>
130 <add>1.1</add>
131 </field>
132 <field>
133 <name>external_identifier</name>
134 <type>varchar</type>
135 <length>32</length>
136 <size>EIGHT</size>
137 <import>true</import>
138 <headerPattern>/external\s?id/i</headerPattern>
139 <dataPattern>/^\d{11,}$/</dataPattern>
140 <comment>Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.</comment>
141 <add>1.1</add>
142 </field>
143 <index>
144 <name>UI_external_identifier</name>
145 <unique>true</unique>
146 <fieldName>external_identifier</fieldName>
147 <add>1.7</add>
148 </index>
149 <field>
150 <name>sort_name</name>
151 <title>Sort Name</title>
152 <type>varchar</type>
153 <length>128</length>
154 <size>BIG</size>
155 <export>true</export>
156 <comment>Name used for sorting different contact types</comment>
157 <add>1.1</add>
158 </field>
159 <index>
160 <name>index_sort_name</name>
161 <fieldName>sort_name</fieldName>
162 <add>2.1</add>
163 </index>
164 <field>
165 <name>display_name</name>
166 <title>Display Name</title>
167 <type>varchar</type>
168 <length>128</length>
169 <size>BIG</size>
170 <export>true</export>
171 <comment>Formatted name representing preferred format for display/print/other output.</comment>
172 <add>1.1</add>
173 </field>
174 <field>
175 <name>nick_name</name>
176 <title>Nickname</title>
177 <type>varchar</type>
178 <length>128</length>
179 <size>BIG</size>
180 <import>true</import>
181 <headerPattern>/n(ick\s)name|nick$/i</headerPattern>
182 <dataPattern>/^\w+$/</dataPattern>
183 <comment>Nickname.</comment>
184 <fulltext/>
185 <add>1.1</add>
186 </field>
187 <field>
188 <name>legal_name</name>
189 <type>varchar</type>
190 <length>128</length>
191 <size>BIG</size>
192 <import>true</import>
193 <headerPattern>/^legal|(l(egal\s)?name)$/i</headerPattern>
194 <comment>Legal Name.</comment>
195 <fulltext/>
196 <add>1.1</add>
197 </field>
198 <field>
199 <name>home_URL</name>
200 <rule>url</rule>
201 <title>Website</title>
202 <type>varchar</type>
203 <length>128</length>
204 <size>BIG</size>
205 <import>true</import>
206 <headerPattern>/^(home\sURL)|URL|web|site/i</headerPattern>
207 <dataPattern>/^[\w\/\:\.]+$/</dataPattern>
208 <comment>optional "home page" URL for this contact.</comment>
209 <add>1.1</add>
210 <drop>3.2</drop>
211 </field>
212 <field>
213 <name>image_URL</name>
214 <type>varchar</type>
215 <length>255</length>
216 <import>true</import>
217 <comment>optional URL for preferred image (photo, logo, etc.) to display for this contact.</comment>
218 <add>1.1</add>
219 </field>
220 <field>
221 <name>preferred_communication_method</name>
222 <title>Preferred Communication Method</title>
223 <type>varchar</type>
224 <length>255</length>
225 <import>true</import>
226 <headerPattern>/^p(ref\w*\s)?c(omm\w*)|( meth\w*)$/i</headerPattern>
227 <dataPattern>/^\w+$/</dataPattern>
228 <comment>What is the preferred mode of communication.</comment>
229 <add>1.1</add>
230 <pseudoconstant>
231 <optionGroupName>preferred_communication_method</optionGroupName>
232 </pseudoconstant>
233 </field>
234 <index>
235 <name>index_preferred_communication_method</name>
236 <fieldName>preferred_communication_method</fieldName>
237 <add>1.6</add>
238 </index>
239 <field>
240 <name>preferred_language</name>
241 <title>Preferred Language</title>
242 <type>varchar</type>
243 <length>5</length>
244 <comment>Which language is preferred for communication. FK to languages in civicrm_option_value.</comment>
245 <headerPattern>/^lang/i</headerPattern>
246 <import>true</import>
247 <pseudoconstant>
248 <optionGroupName>languages</optionGroupName>
249 <keyColumn>name</keyColumn>
250 </pseudoconstant>
251 <add>3.2</add>
252 </field>
253 <field>
254 <name>preferred_mail_format</name>
255 <type>enum</type>
256 <values>Text, HTML, Both</values>
257 <default>"Both"</default>
258 <import>true</import>
259 <headerPattern>/^p(ref\w*\s)?m(ail\s)?f(orm\w*)$/i</headerPattern>
260 <comment>What is the preferred mode of sending an email.</comment>
261 <add>1.1</add>
262 </field>
263 <field>
264 <name>hash</name>
265 <title>Contact Hash</title>
266 <type>varchar</type>
267 <length>32</length>
268 <comment>Key for validating requests related to this contact.</comment>
269 <add>1.1</add>
270 <change>1.5</change>
271 <export>true</export>
272 </field>
273 <index>
274 <name>index_hash</name>
275 <fieldName>hash</fieldName>
276 <add>2.1</add>
277 </index>
278 <field>
279 <name>api_key</name>
280 <type>varchar</type>
281 <length>32</length>
282 <comment>API Key for validating requests related to this contact.</comment>
283 <add>2.2</add>
284 </field>
285 <index>
286 <name>index_api_key</name>
287 <fieldName>api_key</fieldName>
288 <add>2.1</add>
289 </index>
290 <field>
291 <name>source</name>
292 <title>Source of Contact Data</title>
293 <uniqueName>contact_source</uniqueName>
294 <type>varchar</type>
295 <length>255</length>
296 <size>BIG</size>
297 <import>true</import>
298 <headerPattern>/(S(ource\s)?o(f\s)?C(ontact\s)?Data)$/i</headerPattern>
299 <comment>where contact come from, e.g. import, donate module insert...</comment>
300 <add>1.1</add>
301 </field>
302 <field>
303 <name>first_name</name>
304 <type>varchar</type>
305 <length>64</length>
306 <size>BIG</size>
307 <import>true</import>
308 <headerPattern>/^first|(f(irst\s)?name)$/i</headerPattern>
309 <dataPattern>/^\w+$/</dataPattern>
310 <fulltext/>
311 <comment>First Name.</comment>
312 <add>1.1</add>
313 </field>
314 <index>
315 <name>index_first_name</name>
316 <fieldName>first_name</fieldName>
317 <add>1.8</add>
318 </index>
319 <field>
320 <name>middle_name</name>
321 <type>varchar</type>
322 <length>64</length>
323 <size>MEDIUM</size>
324 <import>true</import>
325 <headerPattern>/^middle|(m(iddle\s)?name)$/i</headerPattern>
326 <dataPattern>/^\w+$/</dataPattern>
327 <fulltext/>
328 <comment>Middle Name.</comment>
329 <add>1.1</add>
330 </field>
331 <field>
332 <name>last_name</name>
333 <type>varchar</type>
334 <length>64</length>
335 <size>BIG</size>
336 <import>true</import>
337 <headerPattern>/^last|(l(ast\s)?name)$/i</headerPattern>
338 <dataPattern>/^\w+(\s\w+)?+$/</dataPattern>
339 <comment>Last Name.</comment>
340 <fulltext/>
341 <add>1.1</add>
342 </field>
343 <index>
344 <name>index_last_name</name>
345 <fieldName>last_name</fieldName>
346 <add>1.8</add>
347 </index>
348 <field>
349 <name>prefix_id</name>
350 <title>Individual Prefix</title>
351 <type>int unsigned</type>
352 <comment>Prefix or Title for name (Ms, Mr...). FK to prefix ID</comment>
353 <pseudoconstant>
354 <optionGroupName>individual_prefix</optionGroupName>
355 </pseudoconstant>
356 <headerPattern>/^(prefix|title)/i</headerPattern>
357 <dataPattern>/^(mr|ms|mrs|sir|dr)\.?$/i</dataPattern>
358 <import>true</import>
359 <add>1.2</add>
360 </field>
361 <index>
362 <name>UI_prefix</name>
363 <fieldName>prefix_id</fieldName>
364 <add>1.6</add>
365 </index>
366 <field>
367 <name>suffix_id</name>
368 <title>Individual Suffix</title>
369 <type>int unsigned</type>
370 <pseudoconstant>
371 <optionGroupName>individual_suffix</optionGroupName>
372 </pseudoconstant>
373 <import>true</import>
374 <comment>Suffix for name (Jr, Sr...). FK to suffix ID</comment>
375 <headerPattern>/^suffix$/i</headerPattern>
376 <dataPattern>/^(sr|jr)\.?|i{2,}$/</dataPattern>
377 <add>1.2</add>
378 </field>
379 <index>
380 <name>UI_suffix</name>
381 <fieldName>suffix_id</fieldName>
382 <add>1.6</add>
383 </index>
384 <field>
385 <name>greeting_type</name>
386 <type>varchar</type>
387 <length>128</length>
388 <import>true</import>
389 <comment>Preferred greeting format.</comment>
390 <add>1.1</add>
391 <drop>2.2</drop>
392 </field>
393 <field>
394 <name>greeting_type_id</name>
395 <title>Greeting Type</title>
396 <type>int unsigned</type>
397 <comment>FK to civicrm_option_value.id, that has to be valid, registered Greeting type.</comment>
398 <add>2.2</add>
399 <drop>3.0</drop>
400 </field>
401 <field>
402 <name>custom_greeting</name>
403 <type>varchar</type>
404 <length>128</length>
405 <import>true</import>
406 <comment>Custom greeting message.</comment>
407 <add>1.1</add>
408 <drop>3.0</drop>
409 </field>
410 <field>
411 <name>email_greeting_id</name>
412 <type>int unsigned</type>
413 <title>Email Greeting ID</title>
414 <comment>FK to civicrm_option_value.id, that has to be valid registered Email Greeting.</comment>
415 <add>3.0</add>
416 </field>
417 <field>
418 <name>email_greeting_custom</name>
419 <type>varchar</type>
420 <length>128</length>
421 <import>true</import>
422 <export>false</export>
423 <comment>Custom Email Greeting.</comment>
424 <add>3.0</add>
425 </field>
426 <field>
427 <name>email_greeting_display</name>
428 <title>Email Greeting</title>
429 <type>varchar</type>
430 <length>255</length>
431 <comment>Cache Email Greeting.</comment>
432 <add>3.0</add>
433 </field>
434 <field>
435 <name>postal_greeting_id</name>
436 <type>int unsigned</type>
437 <title>Postal Greeting ID</title>
438 <comment>FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.</comment>
439 <add>3.0</add>
440 </field>
441 <field>
442 <name>postal_greeting_custom</name>
443 <type>varchar</type>
444 <length>128</length>
445 <import>true</import>
446 <export>false</export>
447 <comment>Custom Postal greeting.</comment>
448 <add>3.0</add>
449 </field>
450 <field>
451 <name>postal_greeting_display</name>
452 <title>Postal Greeting</title>
453 <type>varchar</type>
454 <length>255</length>
455 <comment>Cache Postal greeting.</comment>
456 <add>3.0</add>
457 </field>
458 <field>
459 <name>addressee_id</name>
460 <type>int unsigned</type>
461 <title>Addressee ID</title>
462 <comment>FK to civicrm_option_value.id, that has to be valid registered Addressee.</comment>
463 <add>3.0</add>
464 </field>
465 <field>
466 <name>addressee_custom</name>
467 <type>varchar</type>
468 <length>128</length>
469 <import>true</import>
470 <export>false</export>
471 <comment>Custom Addressee.</comment>
472 <add>3.0</add>
473 </field>
474 <field>
475 <name>addressee_display</name>
476 <title>Addressee</title>
477 <type>varchar</type>
478 <length>255</length>
479 <comment>Cache Addressee.</comment>
480 <add>3.0</add>
481 </field>
482 <field>
483 <name>job_title</name>
484 <type>varchar</type>
485 <length>255</length>
486 <size>MEDIUM</size>
487 <import>true</import>
488 <headerPattern>/^job|(j(ob\s)?title)$/i</headerPattern>
489 <dataPattern>//</dataPattern>
490 <comment>Job Title</comment>
491 <add>1.1</add>
492 </field>
493 <field>
494 <name>gender_id</name>
495 <title>Gender</title>
496 <type>int unsigned</type>
497 <pseudoconstant>
498 <optionGroupName>gender</optionGroupName>
499 </pseudoconstant>
500 <headerPattern>/^gender$/i</headerPattern>
501 <comment>FK to gender ID</comment>
502 <import>true</import>
503 <add>1.2</add>
504 </field>
505 <index>
506 <name>UI_gender</name>
507 <fieldName>gender_id</fieldName>
508 <add>1.6</add>
509 </index>
510 <field>
511 <name>birth_date</name>
512 <type>date</type>
513 <import>true</import>
514 <headerPattern>/^birth|(b(irth\s)?date)|D(\W*)O(\W*)B(\W*)$/i</headerPattern>
515 <dataPattern>/\d{4}-?\d{2}-?\d{2}/</dataPattern>
516 <comment>Date of birth</comment>
517 <add>1.1</add>
518 </field>
519 <field>
520 <name>is_deceased</name>
521 <title>Is Deceased</title>
522 <import>true</import>
523 <export>true</export>
524 <headerPattern>/i(s\s)?d(eceased)$/i</headerPattern>
525 <type>boolean</type>
526 <default>0</default>
527 <add>1.1</add>
528 </field>
529 <field>
530 <name>deceased_date</name>
531 <type>date</type>
532 <import>true</import>
533 <export>true</export>
534 <headerPattern>/^deceased|(d(eceased\s)?date)$/i</headerPattern>
535 <comment>Date of deceased</comment>
536 <add>1.5</add>
537 </field>
538 <field>
539 <name>mail_to_household_id</name>
540 <title>Mail to Household ID</title>
541 <type>int unsigned</type>
542 <comment>OPTIONAL FK to civicrm_contact_household record. If NOT NULL, direct mail communications to household rather than individual location.</comment>
543 <export>true</export>
544 <add>1.1</add>
545 <drop>3.3</drop>
546 </field>
547 <foreignKey>
548 <name>mail_to_household_id</name>
549 <table>civicrm_contact</table>
550 <key>id</key>
551 <add>2.1</add>
552 <onDelete>SET NULL</onDelete>
553 <drop>3.3</drop>
554 </foreignKey>
555 <field>
556 <name>household_name</name>
557 <type>varchar</type>
558 <length>128</length>
559 <size>BIG</size>
560 <import>true</import>
561 <headerPattern>/^household|(h(ousehold\s)?name)$/i</headerPattern>
562 <dataPattern>/^\w+$/</dataPattern>
563 <comment>Household Name.</comment>
564 <fulltext/>
565 <add>1.1</add>
566 </field>
567 <index>
568 <name>index_household_name</name>
569 <fieldName>household_name</fieldName>
570 <add>1.8</add>
571 </index>
572 <field>
573 <name>primary_contact_id</name>
574 <type>int unsigned</type>
575 <title>Household Primary Contact ID</title>
576 <comment>Optional FK to Primary Contact for this household.</comment>
577 <add>1.1</add>
578 </field>
579 <foreignKey>
580 <name>primary_contact_id</name>
581 <table>civicrm_contact</table>
582 <key>id</key>
583 <add>1.1</add>
584 <onDelete>SET NULL</onDelete>
585 </foreignKey>
586 <field>
587 <name>organization_name</name>
588 <type>varchar</type>
589 <length>128</length>
590 <size>BIG</size>
591 <import>true</import>
592 <headerPattern>/^organization|(o(rganization\s)?name)$/i</headerPattern>
593 <dataPattern>/^\w+$/</dataPattern>
594 <comment>Organization Name.</comment>
595 <fulltext/>
596 <add>1.1</add>
597 </field>
598 <index>
599 <name>index_organization_name</name>
600 <fieldName>organization_name</fieldName>
601 <add>1.8</add>
602 </index>
603 <field>
604 <name>sic_code</name>
605 <type>varchar</type>
606 <length>8</length>
607 <import>true</import>
608 <headerPattern>/^sic|(s(ic\s)?code)$/i</headerPattern>
609 <comment>Standard Industry Classification Code.</comment>
610 <add>1.1</add>
611 </field>
612 <field>
613 <name>user_unique_id</name>
614 <rule>url</rule>
615 <title>Unique ID (OpenID)</title>
616 <type>varchar</type>
617 <length>255</length>
618 <import>true</import>
619 <headerPattern>/^Open\s?ID|u(niq\w*)?\s?ID/i</headerPattern>
620 <dataPattern>/^[\w\/\:\.]+$/</dataPattern>
621 <comment>the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM</comment>
622 <add>2.0</add>
623 </field>
624 <field>
625 <name>employer_id</name>
626 <title>Current Employer ID</title>
627 <uniqueName>current_employer_id</uniqueName>
628 <type>int unsigned</type>
629 <comment>OPTIONAL FK to civicrm_contact record.</comment>
630 <export>true</export>
631 <add>2.1</add>
632 </field>
633 <foreignKey>
634 <name>employer_id</name>
635 <table>civicrm_contact</table>
636 <key>id</key>
637 <add>2.1</add>
638 <onDelete>SET NULL</onDelete>
639 </foreignKey>
640 <field>
641 <name>is_deleted</name>
642 <title>Contact is in Trash</title>
643 <uniqueName>contact_is_deleted</uniqueName>
644 <type>boolean</type>
645 <default>0</default>
646 <required>true</required>
647 <export>true</export>
648 <add>3.2</add>
649 </field>
650 <index>
651 <name>index_is_deleted</name>
652 <fieldName>is_deleted</fieldName>
653 <add>3.2</add>
654 <drop>4.4</drop>
655 </index>
656 <index>
657 <name>index_is_deleted_sort_name</name>
658 <fieldName>is_deleted</fieldName>
659 <fieldName>sort_name</fieldName>
660 <fieldName>id</fieldName>
661 <add>4.4</add>
662 </index>
663 <field>
664 <name>created_date</name>
665 <type>timestamp</type>
666 <comment>When was the contact was created.</comment>
667 <required>false</required>
668 <default>NULL</default>
669 <add>4.3</add>
670 </field>
671 <field>
672 <name>modified_date</name>
673 <type>timestamp</type>
674 <comment>When was the contact (or closely related entity) was created or modified or deleted.</comment>
675 <required>false</required>
676 <default>CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP</default>
677 <add>4.3</add>
678 </field>
679 </table>