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