Merge pull request #3915 from eileenmcnaughton/CRM-15168
[civicrm-core.git] / xml / schema / Core / Address.xml
CommitLineData
6a488035
TO
1<?xml version="1.0" encoding="iso-8859-1" ?>
2
3<table>
4 <base>CRM/Core</base>
5 <class>Address</class>
6 <name>civicrm_address</name>
7 <comment>Stores the physical street / mailing address. This format should be capable of storing ALL international addresses.</comment>
8 <add>1.1</add>
9 <log>true</log>
10 <field>
11 <name>id</name>
12 <type>int unsigned</type>
61ce9b45 13 <title>Address ID</title>
6a488035
TO
14 <required>true</required>
15 <comment>Unique Address ID</comment>
16 <add>1.1</add>
17 </field>
18 <primaryKey>
19 <name>id</name>
20 <autoincrement>true</autoincrement>
21 </primaryKey>
22 <field>
23 <name>contact_id</name>
61ce9b45 24 <title>Contact ID</title>
6a488035
TO
25 <type>int unsigned</type>
26 <comment>FK to Contact ID</comment>
27 <add>2.0</add>
28 </field>
29 <foreignKey>
30 <name>contact_id</name>
31 <table>civicrm_contact</table>
32 <key>id</key>
33 <add>2.0</add>
34 <onDelete>CASCADE</onDelete>
35 </foreignKey>
36 <field>
37 <name>location_type_id</name>
38 <title>Address Location Type</title>
39 <type>int unsigned</type>
40 <comment>Which Location does this address belong to.</comment>
398f49ab
AS
41 <add>2.0</add>
42 <pseudoconstant>
43 <table>civicrm_location_type</table>
44 <keyColumn>id</keyColumn>
a38a89fc 45 <labelColumn>display_name</labelColumn>
398f49ab 46 </pseudoconstant>
614d72ec 47 <html>
e0991796 48 <type>Select</type>
614d72ec 49 </html>
6a488035
TO
50 </field>
51 <index>
52 <name>index_location_type</name>
53 <fieldName>location_type_id</fieldName>
54 <add>2.0</add>
55 </index>
56 <field>
57 <name>is_primary</name>
58 <title>Is Address Primary?</title>
59 <type>boolean</type>
60 <default>0</default>
61 <comment>Is this the primary address.</comment>
62 <add>2.0</add>
63 </field>
64 <index>
65 <name>index_is_primary</name>
66 <fieldName>is_primary</fieldName>
67 <add>2.0</add>
68 </index>
69 <field>
70 <name>is_billing</name>
61ce9b45 71 <title>Is Billing Address</title>
6a488035
TO
72 <type>boolean</type>
73 <default>0</default>
74 <comment>Is this the billing address.</comment>
75 <add>2.0</add>
76 </field>
77 <index>
78 <name>index_is_billing</name>
79 <fieldName>is_billing</fieldName>
80 <add>2.0</add>
81 </index>
82 <field>
83 <name>street_address</name>
84 <title>Street Address</title>
85 <type>varchar</type>
86 <length>96</length>
87 <import>true</import>
88 <headerPattern>/(street|address)/i</headerPattern>
89 <dataPattern>/^(\d{1,5}( [0-9A-Za-z]+)+)$|^(P\.?O\.\? Box \d{1,5})$/i</dataPattern>
90 <comment>Concatenation of all routable street address components (prefix, street number, street name, suffix, unit number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail delivery, etc.).</comment>
91 <add>1.1</add>
92 </field>
93 <field>
94 <name>street_number</name>
61ce9b45 95 <title>Street Number</title>
6a488035
TO
96 <type>int</type>
97 <export>true</export>
98 <comment>Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.</comment>
99 <add>1.1</add>
100 </field>
101 <field>
102 <name>street_number_suffix</name>
61ce9b45 103 <title>Street Number Suffix</title>
6a488035
TO
104 <type>varchar</type>
105 <length>8</length>
106 <export>true</export>
107 <comment>Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A</comment>
108 <add>1.1</add>
109 </field>
110 <field>
111 <name>street_number_predirectional</name>
61ce9b45 112 <title>Street Direction Prefix</title>
6a488035
TO
113 <type>varchar</type>
114 <length>8</length>
115 <comment>Directional prefix, e.g. SE Main St, SE is the prefix.</comment>
116 <add>1.1</add>
117 </field>
118 <field>
119 <name>street_name</name>
120 <type>varchar</type>
61ce9b45 121 <title>Street Name</title>
6a488035
TO
122 <length>64</length>
123 <export>true</export>
124 <comment>Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.</comment>
125 <add>1.1</add>
126 </field>
127 <index>
128 <name>index_street_name</name>
129 <fieldName>street_name</fieldName>
130 <add>1.1</add>
131 </index>
132 <field>
133 <name>street_type</name>
61ce9b45 134 <title>Street Type</title>
6a488035
TO
135 <type>varchar</type>
136 <length>8</length>
137 <comment>St, Rd, Dr, etc.</comment>
138 <add>1.1</add>
139 </field>
140 <field>
141 <name>street_number_postdirectional</name>
61ce9b45 142 <title>Street Direction Suffix</title>
6a488035
TO
143 <type>varchar</type>
144 <length>8</length>
145 <comment>Directional prefix, e.g. Main St S, S is the suffix.</comment>
146 <add>1.1</add>
147 </field>
148 <field>
149 <name>street_unit</name>
61ce9b45 150 <title>Street Unit</title>
6a488035
TO
151 <type>varchar</type>
152 <length>16</length>
153 <export>true</export>
154 <comment>Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200</comment>
155 <add>1.1</add>
156 </field>
157 <field>
158 <name>supplemental_address_1</name>
c29131ec 159 <title>Supplemental Address 1</title>
6a488035
TO
160 <type>varchar</type>
161 <length>96</length>
162 <import>true</import>
163 <headerPattern>/(supplemental(\s)?)?address(\s\d+)?/i</headerPattern>
164 <dataPattern>/unit|ap(ar)?t(ment)?\s(\d|\w)+/i</dataPattern>
165 <comment>Supplemental Address Information, Line 1</comment>
166 <add>1.1</add>
167 </field>
168 <field>
169 <name>supplemental_address_2</name>
c29131ec 170 <title>Supplemental Address 2</title>
6a488035
TO
171 <type>varchar</type>
172 <length>96</length>
173 <import>true</import>
174 <headerPattern>/(supplemental(\s)?)?address(\s\d+)?/i</headerPattern>
175 <dataPattern>/unit|ap(ar)?t(ment)?\s(\d|\w)+/i</dataPattern>
176 <comment>Supplemental Address Information, Line 2</comment>
177 <add>1.1</add>
178 </field>
179 <field>
180 <name>supplemental_address_3</name>
61ce9b45 181 <title>Supplemental Address 3</title>
6a488035
TO
182 <type>varchar</type>
183 <length>96</length>
184 <comment>Supplemental Address Information, Line 3</comment>
185 <add>1.1</add>
186 </field>
187 <field>
188 <name>city</name>
189 <title>City</title>
190 <type>varchar</type>
191 <length>64</length>
192 <import>true</import>
193 <headerPattern>/city/i</headerPattern>
194 <dataPattern>/^[A-Za-z]+(\.?)(\s?[A-Za-z]+){0,2}$/</dataPattern>
195 <comment>City, Town or Village Name.</comment>
196 <add>1.1</add>
197 </field>
198 <index>
199 <name>index_city</name>
200 <fieldName>city</fieldName>
201 <add>1.1</add>
202 </index>
203 <field>
204 <name>county_id</name>
205 <type>int unsigned</type>
61ce9b45 206 <title>County</title>
6a488035 207 <comment>Which County does this address belong to.</comment>
dc86f881
CW
208 <pseudoconstant>
209 <table>civicrm_county</table>
210 <keyColumn>id</keyColumn>
211 <labelColumn>name</labelColumn>
212 </pseudoconstant>
614d72ec 213 <html>
e0991796 214 <type>Select</type>
614d72ec 215 </html>
dc86f881 216 <add>1.1</add>
6a488035
TO
217 </field>
218 <foreignKey>
219 <name>county_id</name>
220 <table>civicrm_county</table>
221 <key>id</key>
222 <import>true</import>
223 <headerPattern>/county/i</headerPattern>
224 <dataPattern>/[A-Z]{2}/</dataPattern>
225 <add>1.1</add>
226 <onDelete>SET NULL</onDelete>
227 </foreignKey>
228 <field>
229 <name>state_province_id</name>
230 <title>State</title>
231 <type>int unsigned</type>
232 <comment>Which State_Province does this address belong to.</comment>
dc86f881
CW
233 <pseudoconstant>
234 <table>civicrm_state_province</table>
235 <keyColumn>id</keyColumn>
236 <labelColumn>name</labelColumn>
237 </pseudoconstant>
614d72ec 238 <html>
e0991796 239 <type>Select</type>
614d72ec 240 </html>
6a488035
TO
241 <add>1.1</add>
242 </field>
243 <foreignKey>
244 <name>state_province_id</name>
245 <table>civicrm_state_province</table>
246 <key>id</key>
247 <import>true</import>
248 <headerPattern>/state|prov(ince)?/i</headerPattern>
249 <dataPattern>/A[LKSZRAP]|C[AOT]|D[EC]|F[LM]|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEHINOPST]|N[CDEHJMVY]|O[HKR]|P[ARW]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY]/i</dataPattern>
250 <add>1.1</add>
251 <onDelete>SET NULL</onDelete>
252 </foreignKey>
253 <field>
254 <name>postal_code_suffix</name>
255 <title>Postal Code Suffix</title>
256 <type>varchar</type>
257 <length>12</length>
258 <import>true</import>
259 <headerPattern>/p(ostal)\sc(ode)\ss(uffix)/i</headerPattern>
260 <dataPattern>/\d?\d{4}(-\d{4})?/</dataPattern>
261 <comment>Store the suffix, like the +4 part in the USPS system.</comment>
262 <add>1.1</add>
3c7d2158 263 </field>
6a488035
TO
264 <field>
265 <name>postal_code</name>
266 <title>Postal Code</title>
267 <type>varchar</type>
268 <length>12</length>
269 <import>true</import>
270 <headerPattern>/postal|zip/i</headerPattern>
271 <dataPattern>/\d?\d{4}(-\d{4})?/</dataPattern>
272 <comment>Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.</comment>
273 <add>1.1</add>
274 </field>
275 <field>
276 <name>usps_adc</name>
61ce9b45 277 <title>USPS Code</title>
6a488035
TO
278 <type>varchar</type>
279 <length>32</length>
280 <comment>USPS Bulk mailing code.</comment>
281 <add>1.1</add>
282 </field>
283 <field>
284 <name>country_id</name>
285 <title>Country</title>
286 <type>int unsigned</type>
287 <comment>Which Country does this address belong to.</comment>
dc86f881
CW
288 <pseudoconstant>
289 <table>civicrm_country</table>
290 <keyColumn>id</keyColumn>
291 <labelColumn>name</labelColumn>
a38a89fc 292 <nameColumn>iso_code</nameColumn>
dc86f881 293 </pseudoconstant>
614d72ec 294 <html>
e0991796 295 <type>Select</type>
614d72ec 296 </html>
dc86f881 297 <add>1.1</add>
6a488035
TO
298 </field>
299 <foreignKey>
300 <name>country_id</name>
301 <table>civicrm_country</table>
302 <key>id</key>
303 <import>true</import>
304 <headerPattern>/country/i</headerPattern>
305 <dataPattern>/\w+(\s\w+)?/</dataPattern>
306 <add>1.1</add>
307 <onDelete>SET NULL</onDelete>
308 </foreignKey>
309 <field>
310 <name>geo_code_1</name>
61ce9b45 311 <title>Latitude</title>
6a488035
TO
312 <type>float</type>
313 <import>true</import>
314 <headerPattern>/geo/i</headerPattern>
315 <comment>Latitude</comment>
316 <add>1.1</add>
317 </field>
318 <field>
319 <name>geo_code_2</name>
61ce9b45 320 <title>Longitude</title>
6a488035
TO
321 <type>float</type>
322 <comment>Longitude</comment>
323 <import>true</import>
324 <headerPattern>/geo/i</headerPattern>
325 <add>1.1</add>
326 </field>
327 <field>
328 <name>manual_geo_code</name>
61ce9b45 329 <title>Is manually geocoded</title>
6a488035
TO
330 <type>boolean</type>
331 <default>0</default>
332 <comment>Is this a manually entered geo code</comment>
333 <add>4.3</add>
334 </field>
335 <field>
336 <name>timezone</name>
61ce9b45 337 <title>Timezone</title>
6a488035
TO
338 <type>varchar</type>
339 <length>8</length>
340 <comment>Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".</comment>
341 <add>1.1</add>
342 </field>
343 <field>
344 <name>name</name>
345 <uniqueName>address_name</uniqueName>
346 <title>Address Name</title>
347 <type>varchar</type>
348 <length>255</length>
349 <import>true</import>
350 <headerPattern>/^location|(l(ocation\s)?name)$/i</headerPattern>
351 <dataPattern>/^\w+$/</dataPattern>
352 <add>2.1</add>
353 </field>
354 <field>
355 <name>master_id</name>
356 <title>Master Address Belongs To</title>
357 <type>int unsigned</type>
358 <import>true</import>
359 <comment>FK to Address ID</comment>
360 <add>3.3</add>
361 </field>
362 <foreignKey>
363 <name>master_id</name>
364 <table>civicrm_address</table>
365 <key>id</key>
366 <add>3.3</add>
367 <onDelete>SET NULL</onDelete>
368 </foreignKey>
369</table>