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