Browse code

- first version of postgres autogenerated schema which fully loads into postgres server - minor changes in mysql schema

Jan Janak authored on 26/08/2005 21:32:41
Showing 7 changed files
... ...
@@ -1 +1 @@
1
-prefix(str) from_uri(int) grp_id(int,null) priority(int,null) 
1
+prefix(str) from_uri(str) grp_id(int,null) priority(int,null) 
... ...
@@ -4,9 +4,9 @@ USE ser;
4 4
 CREATE TABLE version (
5 5
     table_name VARCHAR(32) NOT NULL,
6 6
     table_version INT UNSIGNED NOT NULL DEFAULT '0'
7
-) Type=MyISAm;
7
+);
8 8
 
9
-INSERT INTO version (table_name) VALUES ('acc');
9
+INSERT INTO version (table_name, table_version) VALUES ('acc', '2');
10 10
 INSERT INTO version (table_name, table_version) VALUES ('active_sessions', '1');
11 11
 INSERT INTO version (table_name, table_version) VALUES ('aliases', '6');
12 12
 INSERT INTO version (table_name, table_version) VALUES ('event', '1');
... ...
@@ -49,10 +49,10 @@ CREATE TABLE acc (
49 49
     domain VARCHAR(128) NOT NULL,
50 50
     fromtag VARCHAR(128) NOT NULL,
51 51
     totag VARCHAR(128) NOT NULL,
52
-    time DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
53
-    timestamp DATETIME NOT NULL DEFAULT '',
54
-    caller_deleted TINYINT NOT NULL DEFAULT '',
55
-    callee_deleted TINYINT NOT NULL DEFAULT '',
52
+    time DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
53
+    timestamp DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
54
+    caller_deleted TINYINT NOT NULL DEFAULT '0',
55
+    callee_deleted TINYINT NOT NULL DEFAULT '0',
56 56
     KEY acc_user (username, domain),
57 57
     KEY sip_callid (sip_callid)
58 58
 );
... ...
@@ -71,11 +71,11 @@ CREATE TABLE aliases (
71 71
     domain VARCHAR(128) NOT NULL DEFAULT '',
72 72
     contact VARCHAR(255) NOT NULL DEFAULT '',
73 73
     received VARCHAR(255) DEFAULT NULL,
74
-    expires DATETIME NOT NULL DEFAULT '1234',
74
+    expires DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
75 75
     q FLOAT NOT NULL DEFAULT '1.0',
76 76
     callid VARCHAR(255) NOT NULL DEFAULT 'default_callid',
77 77
     cseq INT UNSIGNED NOT NULL DEFAULT '42',
78
-    last_modified DATETIME NOT NULL DEFAULT '',
78
+    last_modified DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
79 79
     replicate INT UNSIGNED NOT NULL DEFAULT '0',
80 80
     state INT UNSIGNED NOT NULL DEFAULT '0',
81 81
     flags INT UNSIGNED NOT NULL DEFAULT '0',
... ...
@@ -90,15 +90,15 @@ CREATE TABLE event (
90 90
     domain VARCHAR(128) NOT NULL DEFAULT '',
91 91
     uri VARCHAR(255) NOT NULL DEFAULT '',
92 92
     description VARCHAR(128) NOT NULL DEFAULT '',
93
-    KEY (id)
93
+    KEY id (id)
94 94
 );
95 95
 
96 96
 CREATE TABLE grp (
97 97
     username VARCHAR(64) NOT NULL DEFAULT '',
98 98
     domain VARCHAR(128) NOT NULL DEFAULT '',
99 99
     grp VARCHAR(64) NOT NULL DEFAULT '',
100
-    last_modified DATETIME NOT NULL DEFAULT '',
101
-    KEY (username, domain, grp)
100
+    last_modified DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
101
+    KEY grp_idx (username, domain, grp)
102 102
 );
103 103
 
104 104
 CREATE TABLE location (
... ...
@@ -106,17 +106,17 @@ CREATE TABLE location (
106 106
     domain VARCHAR(128) NOT NULL DEFAULT '',
107 107
     contact VARCHAR(255) NOT NULL DEFAULT '',
108 108
     received VARCHAR(255) DEFAULT NULL,
109
-    expires DATETIME NOT NULL DEFAULT '1234',
109
+    expires DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
110 110
     q FLOAT NOT NULL DEFAULT '1.0',
111 111
     callid VARCHAR(255) NOT NULL DEFAULT 'default_callid',
112 112
     cseq INT UNSIGNED NOT NULL DEFAULT '42',
113
-    last_modified DATETIME NOT NULL DEFAULT '',
113
+    last_modified DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
114 114
     replicate INT UNSIGNED NOT NULL DEFAULT '0',
115 115
     state INT UNSIGNED NOT NULL DEFAULT '0',
116 116
     flags INT UNSIGNED NOT NULL DEFAULT '0',
117 117
     user_agent VARCHAR(64) NOT NULL DEFAULT '',
118
-    KEY main_key (username, domain, contact),
119
-    KEY aliases_contact (contact)
118
+    KEY location_key (username, domain, contact),
119
+    KEY location_contact (contact)
120 120
 );
121 121
 
122 122
 CREATE TABLE missed_calls (
... ...
@@ -133,8 +133,8 @@ CREATE TABLE missed_calls (
133 133
     domain VARCHAR(128) NOT NULL DEFAULT '',
134 134
     fromtag VARCHAR(128) NOT NULL DEFAULT '',
135 135
     totag VARCHAR(128) NOT NULL DEFAULT '',
136
-    time DATETIME NOT NULL DEFAULT '0',
137
-    timestamp DATETIME NOT NULL DEFAULT '',
136
+    time DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
137
+    timestamp DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
138 138
     KEY mc_user (username, domain)
139 139
 );
140 140
 
... ...
@@ -147,8 +147,8 @@ CREATE TABLE pending (
147 147
     last_name VARCHAR(45) NOT NULL DEFAULT '',
148 148
     phone VARCHAR(15) NOT NULL DEFAULT '',
149 149
     email_address VARCHAR(50) NOT NULL DEFAULT '',
150
-    datetime_created DATETIME NOT NULL DEFAULT '0',
151
-    datetime_modified DATETIME NOT NULL DEFAULT '0',
150
+    datetime_created DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
151
+    datetime_modified DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
152 152
     confirmation VARCHAR(64) NOT NULL DEFAULT '',
153 153
     flag VARCHAR(1) NOT NULL DEFAULT 'o',
154 154
     sendnotification VARCHAR(50) NOT NULL DEFAULT '',
... ...
@@ -158,21 +158,21 @@ CREATE TABLE pending (
158 158
     allow_find VARCHAR(1) NOT NULL DEFAULT '',
159 159
     timezone VARCHAR(128) NOT NULL DEFAULT '',
160 160
     rpid VARCHAR(255) NOT NULL DEFAULT '',
161
-    domn INT(10) UNSIGNED NOT NULL DEFAULT '',
161
+    domn INT(10) UNSIGNED NOT NULL DEFAULT '0',
162 162
     uuid VARCHAR(255) NOT NULL DEFAULT '',
163
-    KEY (username, domain),
163
+    KEY pending_idx1 (username, domain),
164 164
     KEY user_2 (username),
165
-    KEY phplib_id (phplib_id)
165
+    KEY php (phplib_id)
166 166
 );
167 167
 
168 168
 CREATE TABLE phonebook (
169
-    id INT UNSIGNED NOT NULL DEFAULT '',
169
+    id INT UNSIGNED NOT NULL DEFAULT '0',
170 170
     username VARCHAR(64) NOT NULL DEFAULT '',
171 171
     domain VARCHAR(128) NOT NULL DEFAULT '',
172 172
     fname VARCHAR(32) NOT NULL DEFAULT '',
173 173
     lname VARCHAR(32) NOT NULL DEFAULT '',
174 174
     sip_uri VARCHAR(255) NOT NULL DEFAULT '',
175
-    KEY (id)
175
+    KEY pb_idx (id)
176 176
 );
177 177
 
178 178
 CREATE TABLE reserved (
... ...
@@ -189,8 +189,8 @@ CREATE TABLE subscriber (
189 189
     last_name VARCHAR(45) NOT NULL DEFAULT '',
190 190
     phone VARCHAR(15) NOT NULL DEFAULT '',
191 191
     email_address VARCHAR(50) NOT NULL DEFAULT '',
192
-    datetime_created DATETIME NOT NULL DEFAULT '0',
193
-    datetime_modified DATETIME NOT NULL DEFAULT '0',
192
+    datetime_created DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
193
+    datetime_modified DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
194 194
     confirmation VARCHAR(64) NOT NULL DEFAULT '',
195 195
     flag VARCHAR(1) NOT NULL DEFAULT 'o',
196 196
     sendnotification VARCHAR(50) NOT NULL DEFAULT '',
... ...
@@ -200,10 +200,10 @@ CREATE TABLE subscriber (
200 200
     allow_find VARCHAR(1) NOT NULL DEFAULT '',
201 201
     timezone VARCHAR(128) NOT NULL DEFAULT '',
202 202
     rpid VARCHAR(255) NOT NULL DEFAULT '',
203
-    domn INT(10) UNSIGNED NOT NULL DEFAULT '',
203
+    domn INT(10) UNSIGNED NOT NULL DEFAULT '0',
204 204
     uuid VARCHAR(255) NOT NULL DEFAULT '',
205 205
     UNIQUE KEY (username, domain),
206
-    KEY user_2 (username),
206
+    KEY sub_idx1 (username),
207 207
     KEY phplib_id (phplib_id)
208 208
 );
209 209
 
... ...
@@ -222,34 +222,34 @@ CREATE TABLE silo (
222 222
     r_uri VARCHAR(255) NOT NULL DEFAULT '',
223 223
     username VARCHAR(64) NOT NULL DEFAULT '',
224 224
     domain VARCHAR(128) NOT NULL DEFAULT '',
225
-    inc_time DATETIME NOT NULL DEFAULT '0',
226
-    exp_time DATETIME NOT NULL DEFAULT '0',
225
+    inc_time DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
226
+    exp_time DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
227 227
     ctype VARCHAR(128) NOT NULL DEFAULT 'text/plain',
228 228
     body BLOB NOT NULL DEFAULT '',
229
-    KEY (mid)
229
+    KEY silo_idx1 (mid)
230 230
 );
231 231
 
232 232
 CREATE TABLE domain (
233 233
     domain VARCHAR(128) NOT NULL DEFAULT '',
234
-    last_modified DATETIME NOT NULL DEFAULT '0',
235
-    KEY (domain)
234
+    last_modified DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
235
+    KEY domain_idx1 (domain)
236 236
 );
237 237
 
238 238
 CREATE TABLE uri (
239 239
     username VARCHAR(64) NOT NULL DEFAULT '',
240 240
     domain VARCHAR(128) NOT NULL DEFAULT '',
241 241
     uri_user VARCHAR(64) NOT NULL DEFAULT '',
242
-    last_modified DATETIME NOT NULL DEFAULT '',
243
-    KEY (username, domain, uri_user)
242
+    last_modified DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
243
+    KEY uri_idx1 (username, domain, uri_user)
244 244
 );
245 245
 
246 246
 CREATE TABLE server_monitoring (
247
-    time DATETIME NOT NULL DEFAULT '0',
247
+    time DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
248 248
     id INT NOT NULL DEFAULT '0',
249 249
     param VARCHAR(32) NOT NULL DEFAULT '',
250 250
     value INT NOT NULL DEFAULT '0',
251 251
     increment INT NOT NULL DEFAULT '0',
252
-    KEY (id, param)
252
+    KEY sm_idx1 (id, param)
253 253
 );
254 254
 
255 255
 CREATE TABLE usr_preferences (
... ...
@@ -260,7 +260,7 @@ CREATE TABLE usr_preferences (
260 260
     value VARCHAR(128) NOT NULL DEFAULT '',
261 261
     type INT NOT NULL DEFAULT '0',
262 262
     modified DATETIME NOT NULL,
263
-    KEY (attribute, username, domain)
263
+    KEY up_idx (attribute, username, domain)
264 264
 );
265 265
 
266 266
 CREATE TABLE usr_preferences_types (
... ...
@@ -269,14 +269,14 @@ CREATE TABLE usr_preferences_types (
269 269
     att_raw_type INT NOT NULL DEFAULT '2',
270 270
     att_type_spec VARCHAR(255),
271 271
     default_value VARCHAR(100) NOT NULL DEFAULT '',
272
-    KEY (att_name)
272
+    KEY upt_idx1 (att_name)
273 273
 );
274 274
 
275 275
 CREATE TABLE trusted (
276 276
     src_ip VARCHAR(39) NOT NULL,
277 277
     proto VARCHAR(4) NOT NULL,
278 278
     from_pattern VARCHAR(64) NOT NULL,
279
-    KEY (src_ip, proto, from_pattern)
279
+    KEY trusted_idx (src_ip, proto, from_pattern)
280 280
 );
281 281
 
282 282
 CREATE TABLE server_monitoring_agg (
... ...
@@ -292,8 +292,8 @@ CREATE TABLE server_monitoring_agg (
292 292
     max_val INT NOT NULL DEFAULT '0',
293 293
     min_inc INT NOT NULL DEFAULT '0',
294 294
     max_inc INT NOT NULL DEFAULT '0',
295
-    lastupdate DATETIME NOT NULL DEFAULT '0',
296
-    KEY (param)
295
+    lastupdate DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
296
+    KEY smagg_idx1 (param)
297 297
 );
298 298
 
299 299
 CREATE TABLE admin_privileges (
... ...
@@ -301,7 +301,7 @@ CREATE TABLE admin_privileges (
301 301
     domain VARCHAR(128) NOT NULL DEFAULT '',
302 302
     priv_name VARCHAR(64) NOT NULL DEFAULT '',
303 303
     priv_value VARCHAR(64) NOT NULL DEFAULT '0',
304
-    KEY (username, priv_name, priv_value, domain)
304
+    KEY adminpriv_idx1 (username, priv_name, priv_value, domain)
305 305
 );
306 306
 
307 307
 CREATE TABLE call_forwarding (
... ...
@@ -325,7 +325,7 @@ CREATE TABLE speed_dial (
325 325
     fname VARCHAR(128) NOT NULL DEFAULT '',
326 326
     lname VARCHAR(128) NOT NULL DEFAULT '',
327 327
     description VARCHAR(64) NOT NULL DEFAULT '',
328
-    KEY (username, domain, sd_username, sd_domain)
328
+    KEY speeddial_idx1 (username, domain, sd_username, sd_domain)
329 329
 );
330 330
 
331 331
 CREATE TABLE gw (
... ...
@@ -335,8 +335,8 @@ CREATE TABLE gw (
335 335
     uri_scheme TINYINT UNSIGNED,
336 336
     transport SMALLINT UNSIGNED,
337 337
     grp_id INT NOT NULL,
338
-    KEY (gw_name),
339
-    KEY (grp_id)
338
+    KEY gw_idx1 (gw_name),
339
+    KEY gw_idx2 (grp_id)
340 340
 );
341 341
 
342 342
 CREATE TABLE gw_grp (
... ...
@@ -346,11 +346,11 @@ CREATE TABLE gw_grp (
346 346
 
347 347
 CREATE TABLE lcr (
348 348
     prefix VARCHAR(16) NOT NULL,
349
-    from_uri INT(255) NOT NULL DEFAULT '%',
349
+    from_uri VARCHAR(255) NOT NULL DEFAULT '%',
350 350
     grp_id INT,
351 351
     priority INT,
352
-    KEY (prefix),
353
-    KEY (from_uri),
354
-    KEY (grp_id)
352
+    KEY lcr_idx1 (prefix),
353
+    KEY lcr_idx2 (from_uri),
354
+    KEY lcr_idx3 (grp_id)
355 355
 );
356 356
 
... ...
@@ -1,31 +1 @@
1
-USE ser;
2
-
3
-DROP TABLE version;
4
-DROP TABLE acc;
5
-DROP TABLE active_sessions;
6
-DROP TABLE aliases;
7
-DROP TABLE event;
8
-DROP TABLE grp;
9
-DROP TABLE location;
10
-DROP TABLE missed_calls;
11
-DROP TABLE pending;
12
-DROP TABLE phonebook;
13
-DROP TABLE reserved;
14
-DROP TABLE subscriber;
15
-DROP TABLE config;
16
-DROP TABLE silo;
17
-DROP TABLE domain;
18
-DROP TABLE uri;
19
-DROP TABLE server_monitoring;
20
-DROP TABLE usr_preferences;
21
-DROP TABLE usr_preferences_types;
22
-DROP TABLE trusted;
23
-DROP TABLE server_monitoring_agg;
24
-DROP TABLE admin_privileges;
25
-DROP TABLE call_forwarding;
26
-DROP TABLE speed_dial;
27
-DROP TABLE gw;
28
-DROP TABLE gw_grp;
29
-DROP TABLE lcr;
30
-
31 1
 DROP DATABASE ser;
... ...
@@ -1,12 +1,9 @@
1
-CREATE DATABASE or_ser;
2
-USE or_ser;
3
-
4 1
 CREATE TABLE version (
5 2
     table_name string(32) NOT NULL,
6 3
     table_version int NOT NULL DEFAULT '0'
7 4
 );
8 5
 
9
-INSERT INTO version (table_name) VALUES ('acc');
6
+INSERT INTO version (table_name, table_version) VALUES ('acc', '2');
10 7
 INSERT INTO version (table_name, table_version) VALUES ('active_sessions', '1');
11 8
 INSERT INTO version (table_name, table_version) VALUES ('aliases', '6');
12 9
 INSERT INTO version (table_name, table_version) VALUES ('event', '1');
... ...
@@ -49,10 +46,10 @@ CREATE TABLE acc (
49 46
     domain string(128) NOT NULL,
50 47
     fromtag string(128) NOT NULL,
51 48
     totag string(128) NOT NULL,
52
-    time datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
53
-    timestamp datetime NOT NULL DEFAULT '',
54
-    caller_deleted char NOT NULL DEFAULT '',
55
-    callee_deleted char NOT NULL DEFAULT ''
49
+    time datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
50
+    timestamp datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
51
+    caller_deleted char NOT NULL DEFAULT '0',
52
+    callee_deleted char NOT NULL DEFAULT '0'
56 53
 );
57 54
 
58 55
 CREATE TABLE active_sessions (
... ...
@@ -67,11 +64,11 @@ CREATE TABLE aliases (
67 64
     domain string(128) NOT NULL DEFAULT '',
68 65
     contact string(255) NOT NULL DEFAULT '',
69 66
     received string(255) DEFAULT NULL,
70
-    expires datetime NOT NULL DEFAULT '1234',
67
+    expires datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
71 68
     q float NOT NULL DEFAULT '1.0',
72 69
     callid string(255) NOT NULL DEFAULT 'default_callid',
73 70
     cseq int NOT NULL DEFAULT '42',
74
-    last_modified datetime NOT NULL DEFAULT '',
71
+    last_modified datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
75 72
     replicate int NOT NULL DEFAULT '0',
76 73
     state int NOT NULL DEFAULT '0',
77 74
     flags int NOT NULL DEFAULT '0',
... ...
@@ -90,7 +87,7 @@ CREATE TABLE grp (
90 87
     username string(64) NOT NULL DEFAULT '',
91 88
     domain string(128) NOT NULL DEFAULT '',
92 89
     grp string(64) NOT NULL DEFAULT '',
93
-    last_modified datetime NOT NULL DEFAULT ''
90
+    last_modified datetime NOT NULL DEFAULT '1970-01-01 00:00:00'
94 91
 );
95 92
 
96 93
 CREATE TABLE location (
... ...
@@ -98,11 +95,11 @@ CREATE TABLE location (
98 95
     domain string(128) NOT NULL DEFAULT '',
99 96
     contact string(255) NOT NULL DEFAULT '',
100 97
     received string(255) DEFAULT NULL,
101
-    expires datetime NOT NULL DEFAULT '1234',
98
+    expires datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
102 99
     q float NOT NULL DEFAULT '1.0',
103 100
     callid string(255) NOT NULL DEFAULT 'default_callid',
104 101
     cseq int NOT NULL DEFAULT '42',
105
-    last_modified datetime NOT NULL DEFAULT '',
102
+    last_modified datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
106 103
     replicate int NOT NULL DEFAULT '0',
107 104
     state int NOT NULL DEFAULT '0',
108 105
     flags int NOT NULL DEFAULT '0',
... ...
@@ -123,8 +120,8 @@ CREATE TABLE missed_calls (
123 120
     domain string(128) NOT NULL DEFAULT '',
124 121
     fromtag string(128) NOT NULL DEFAULT '',
125 122
     totag string(128) NOT NULL DEFAULT '',
126
-    time datetime NOT NULL DEFAULT '0',
127
-    timestamp datetime NOT NULL DEFAULT ''
123
+    time datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
124
+    timestamp datetime NOT NULL DEFAULT '1970-01-01 00:00:00'
128 125
 );
129 126
 
130 127
 CREATE TABLE pending (
... ...
@@ -136,8 +133,8 @@ CREATE TABLE pending (
136 133
     last_name string(45) NOT NULL DEFAULT '',
137 134
     phone string(15) NOT NULL DEFAULT '',
138 135
     email_address string(50) NOT NULL DEFAULT '',
139
-    datetime_created datetime NOT NULL DEFAULT '0',
140
-    datetime_modified datetime NOT NULL DEFAULT '0',
136
+    datetime_created datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
137
+    datetime_modified datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
141 138
     confirmation string(64) NOT NULL DEFAULT '',
142 139
     flag string(1) NOT NULL DEFAULT 'o',
143 140
     sendnotification string(50) NOT NULL DEFAULT '',
... ...
@@ -147,12 +144,12 @@ CREATE TABLE pending (
147 144
     allow_find string(1) NOT NULL DEFAULT '',
148 145
     timezone string(128) NOT NULL DEFAULT '',
149 146
     rpid string(255) NOT NULL DEFAULT '',
150
-    domn int(10) NOT NULL DEFAULT '',
147
+    domn int(10) NOT NULL DEFAULT '0',
151 148
     uuid string(255) NOT NULL DEFAULT ''
152 149
 );
153 150
 
154 151
 CREATE TABLE phonebook (
155
-    id int NOT NULL DEFAULT '',
152
+    id int NOT NULL DEFAULT '0',
156 153
     username string(64) NOT NULL DEFAULT '',
157 154
     domain string(128) NOT NULL DEFAULT '',
158 155
     fname string(32) NOT NULL DEFAULT '',
... ...
@@ -174,8 +171,8 @@ CREATE TABLE subscriber (
174 171
     last_name string(45) NOT NULL DEFAULT '',
175 172
     phone string(15) NOT NULL DEFAULT '',
176 173
     email_address string(50) NOT NULL DEFAULT '',
177
-    datetime_created datetime NOT NULL DEFAULT '0',
178
-    datetime_modified datetime NOT NULL DEFAULT '0',
174
+    datetime_created datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
175
+    datetime_modified datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
179 176
     confirmation string(64) NOT NULL DEFAULT '',
180 177
     flag string(1) NOT NULL DEFAULT 'o',
181 178
     sendnotification string(50) NOT NULL DEFAULT '',
... ...
@@ -185,7 +182,7 @@ CREATE TABLE subscriber (
185 182
     allow_find string(1) NOT NULL DEFAULT '',
186 183
     timezone string(128) NOT NULL DEFAULT '',
187 184
     rpid string(255) NOT NULL DEFAULT '',
188
-    domn int(10) NOT NULL DEFAULT '',
185
+    domn int(10) NOT NULL DEFAULT '0',
189 186
     uuid string(255) NOT NULL DEFAULT '',
190 187
      UNIQUE (username, domain, ),
191 188
 
... ...
@@ -206,26 +203,26 @@ CREATE TABLE silo (
206 203
     r_uri string(255) NOT NULL DEFAULT '',
207 204
     username string(64) NOT NULL DEFAULT '',
208 205
     domain string(128) NOT NULL DEFAULT '',
209
-    inc_time datetime NOT NULL DEFAULT '0',
210
-    exp_time datetime NOT NULL DEFAULT '0',
206
+    inc_time datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
207
+    exp_time datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
211 208
     ctype string(128) NOT NULL DEFAULT 'text/plain',
212 209
     body binary NOT NULL DEFAULT ''
213 210
 );
214 211
 
215 212
 CREATE TABLE domain (
216 213
     domain string(128) NOT NULL DEFAULT '',
217
-    last_modified datetime NOT NULL DEFAULT '0'
214
+    last_modified datetime NOT NULL DEFAULT '1970-01-01 00:00:00'
218 215
 );
219 216
 
220 217
 CREATE TABLE uri (
221 218
     username string(64) NOT NULL DEFAULT '',
222 219
     domain string(128) NOT NULL DEFAULT '',
223 220
     uri_user string(64) NOT NULL DEFAULT '',
224
-    last_modified datetime NOT NULL DEFAULT ''
221
+    last_modified datetime NOT NULL DEFAULT '1970-01-01 00:00:00'
225 222
 );
226 223
 
227 224
 CREATE TABLE server_monitoring (
228
-    time datetime NOT NULL DEFAULT '0',
225
+    time datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
229 226
     id int NOT NULL DEFAULT '0',
230 227
     param string(32) NOT NULL DEFAULT '',
231 228
     value int NOT NULL DEFAULT '0',
... ...
@@ -269,7 +266,7 @@ CREATE TABLE server_monitoring_agg (
269 266
     max_val int NOT NULL DEFAULT '0',
270 267
     min_inc int NOT NULL DEFAULT '0',
271 268
     max_inc int NOT NULL DEFAULT '0',
272
-    lastupdate datetime NOT NULL DEFAULT '0'
269
+    lastupdate datetime NOT NULL DEFAULT '1970-01-01 00:00:00'
273 270
 );
274 271
 
275 272
 CREATE TABLE admin_privileges (
... ...
@@ -318,7 +315,7 @@ CREATE TABLE gw_grp (
318 315
 
319 316
 CREATE TABLE lcr (
320 317
     prefix string(16) NOT NULL,
321
-    from_uri int(255) NOT NULL DEFAULT '%',
318
+    from_uri string(255) NOT NULL DEFAULT '%',
322 319
     grp_id int,
323 320
     priority int
324 321
 );
... ...
@@ -1,31 +0,0 @@
1
-USE or_ser;
2
-
3
-DROP TABLE version;
4
-DROP TABLE acc;
5
-DROP TABLE active_sessions;
6
-DROP TABLE aliases;
7
-DROP TABLE event;
8
-DROP TABLE grp;
9
-DROP TABLE location;
10
-DROP TABLE missed_calls;
11
-DROP TABLE pending;
12
-DROP TABLE phonebook;
13
-DROP TABLE reserved;
14
-DROP TABLE subscriber;
15
-DROP TABLE config;
16
-DROP TABLE silo;
17
-DROP TABLE domain;
18
-DROP TABLE uri;
19
-DROP TABLE server_monitoring;
20
-DROP TABLE usr_preferences;
21
-DROP TABLE usr_preferences_types;
22
-DROP TABLE trusted;
23
-DROP TABLE server_monitoring_agg;
24
-DROP TABLE admin_privileges;
25
-DROP TABLE call_forwarding;
26
-DROP TABLE speed_dial;
27
-DROP TABLE gw;
28
-DROP TABLE gw_grp;
29
-DROP TABLE lcr;
30
-
31
-DROP DATABASE or_ser;
... ...
@@ -1,12 +1,9 @@
1
-CREATE DATABASE pg_ser;
2
-USE pg_ser;
3
-
4 1
 CREATE TABLE version (
5
-    table_name string(32) NOT NULL,
6
-    table_version int NOT NULL DEFAULT '0'
2
+    table_name VARCHAR(32) NOT NULL,
3
+    table_version INTEGER NOT NULL DEFAULT '0'
7 4
 );
8 5
 
9
-INSERT INTO version (table_name) VALUES ('acc');
6
+INSERT INTO version (table_name, table_version) VALUES ('acc', '2');
10 7
 INSERT INTO version (table_name, table_version) VALUES ('active_sessions', '1');
11 8
 INSERT INTO version (table_name, table_version) VALUES ('aliases', '6');
12 9
 INSERT INTO version (table_name, table_version) VALUES ('event', '1');
... ...
@@ -34,292 +31,345 @@ INSERT INTO version (table_name, table_version) VALUES ('gw_grp', '2');
34 31
 INSERT INTO version (table_name, table_version) VALUES ('lcr', '1');
35 32
 
36 33
 CREATE TABLE acc (
37
-    caller_UUID string(255) NOT NULL,
38
-    callee_UUID string(255) NOT NULL,
39
-    sip_from string(255) NOT NULL,
40
-    sip_to string(255) NOT NULL,
41
-    sip_status string(128) NOT NULL,
42
-    sip_method string(16) NOT NULL,
43
-    i_uri string(255) NOT NULL,
44
-    o_uri string(255) NOT NULL,
45
-    from_uri string(255) NOT NULL,
46
-    to_uri string(255) NOT NULL,
47
-    sip_callid string(255) NOT NULL,
48
-    username string(64) NOT NULL,
49
-    domain string(128) NOT NULL,
50
-    fromtag string(128) NOT NULL,
51
-    totag string(128) NOT NULL,
52
-    time datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
53
-    timestamp datetime NOT NULL DEFAULT '',
54
-    caller_deleted char NOT NULL DEFAULT '',
55
-    callee_deleted char NOT NULL DEFAULT ''
34
+    caller_UUID VARCHAR(255) NOT NULL,
35
+    callee_UUID VARCHAR(255) NOT NULL,
36
+    sip_from VARCHAR(255) NOT NULL,
37
+    sip_to VARCHAR(255) NOT NULL,
38
+    sip_status VARCHAR(128) NOT NULL,
39
+    sip_method VARCHAR(16) NOT NULL,
40
+    i_uri VARCHAR(255) NOT NULL,
41
+    o_uri VARCHAR(255) NOT NULL,
42
+    from_uri VARCHAR(255) NOT NULL,
43
+    to_uri VARCHAR(255) NOT NULL,
44
+    sip_callid VARCHAR(255) NOT NULL,
45
+    username VARCHAR(64) NOT NULL,
46
+    domain VARCHAR(128) NOT NULL,
47
+    fromtag VARCHAR(128) NOT NULL,
48
+    totag VARCHAR(128) NOT NULL,
49
+    time TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00',
50
+    timestamp TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00',
51
+    caller_deleted SMALLINT NOT NULL DEFAULT '0',
52
+    callee_deleted SMALLINT NOT NULL DEFAULT '0'
56 53
 );
57 54
 
55
+CREATE INDEX acc_user ON acc (username, domain);
56
+CREATE INDEX sip_callid ON acc (sip_callid);
57
+
58 58
 CREATE TABLE active_sessions (
59
-    sid string(32) NOT NULL DEFAULT '',
60
-    name string(32) NOT NULL DEFAULT '',
61
-    val string(32) NOT NULL DEFAULT '',
62
-    changed string(14) NOT NULL
59
+    sid VARCHAR(32) NOT NULL DEFAULT '',
60
+    name VARCHAR(32) NOT NULL DEFAULT '',
61
+    val VARCHAR(32) NOT NULL DEFAULT '',
62
+    changed VARCHAR(14) NOT NULL
63 63
 );
64 64
 
65
+CREATE INDEX name ON active_sessions (name, sid);
66
+CREATE INDEX changed ON active_sessions (changed);
67
+
65 68
 CREATE TABLE aliases (
66
-    username string(64) NOT NULL DEFAULT '',
67
-    domain string(128) NOT NULL DEFAULT '',
68
-    contact string(255) NOT NULL DEFAULT '',
69
-    received string(255) DEFAULT NULL,
70
-    expires datetime NOT NULL DEFAULT '1234',
71
-    q float NOT NULL DEFAULT '1.0',
72
-    callid string(255) NOT NULL DEFAULT 'default_callid',
73
-    cseq int NOT NULL DEFAULT '42',
74
-    last_modified datetime NOT NULL DEFAULT '',
75
-    replicate int NOT NULL DEFAULT '0',
76
-    state int NOT NULL DEFAULT '0',
77
-    flags int NOT NULL DEFAULT '0',
78
-    user_agent string(64) NOT NULL DEFAULT ''
69
+    username VARCHAR(64) NOT NULL DEFAULT '',
70
+    domain VARCHAR(128) NOT NULL DEFAULT '',
71
+    contact VARCHAR(255) NOT NULL DEFAULT '',
72
+    received VARCHAR(255) DEFAULT NULL,
73
+    expires TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00',
74
+    q REAL NOT NULL DEFAULT '1.0',
75
+    callid VARCHAR(255) NOT NULL DEFAULT 'default_callid',
76
+    cseq INTEGER NOT NULL DEFAULT '42',
77
+    last_modified TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00',
78
+    replicate INTEGER NOT NULL DEFAULT '0',
79
+    state INTEGER NOT NULL DEFAULT '0',
80
+    flags INTEGER NOT NULL DEFAULT '0',
81
+    user_agent VARCHAR(64) NOT NULL DEFAULT ''
79 82
 );
80 83
 
84
+CREATE INDEX main_key ON aliases (username, domain, contact);
85
+CREATE INDEX aliases_contact ON aliases (contact);
86
+
81 87
 CREATE TABLE event (
82
-    id int NOT NULL,
83
-    username string(64) NOT NULL DEFAULT '',
84
-    domain string(128) NOT NULL DEFAULT '',
85
-    uri string(255) NOT NULL DEFAULT '',
86
-    description string(128) NOT NULL DEFAULT ''
88
+    id INTEGER NOT NULL,
89
+    username VARCHAR(64) NOT NULL DEFAULT '',
90
+    domain VARCHAR(128) NOT NULL DEFAULT '',
91
+    uri VARCHAR(255) NOT NULL DEFAULT '',
92
+    description VARCHAR(128) NOT NULL DEFAULT ''
87 93
 );
88 94
 
95
+CREATE INDEX id ON event (id);
96
+
89 97
 CREATE TABLE grp (
90
-    username string(64) NOT NULL DEFAULT '',
91
-    domain string(128) NOT NULL DEFAULT '',
92
-    grp string(64) NOT NULL DEFAULT '',
93
-    last_modified datetime NOT NULL DEFAULT ''
98
+    username VARCHAR(64) NOT NULL DEFAULT '',
99
+    domain VARCHAR(128) NOT NULL DEFAULT '',
100
+    grp VARCHAR(64) NOT NULL DEFAULT '',
101
+    last_modified TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00'
94 102
 );
95 103
 
104
+CREATE INDEX grp_idx ON grp (username, domain, grp);
105
+
96 106
 CREATE TABLE location (
97
-    username string(64) NOT NULL DEFAULT '',
98
-    domain string(128) NOT NULL DEFAULT '',
99
-    contact string(255) NOT NULL DEFAULT '',
100
-    received string(255) DEFAULT NULL,
101
-    expires datetime NOT NULL DEFAULT '1234',
102
-    q float NOT NULL DEFAULT '1.0',
103
-    callid string(255) NOT NULL DEFAULT 'default_callid',
104
-    cseq int NOT NULL DEFAULT '42',
105
-    last_modified datetime NOT NULL DEFAULT '',
106
-    replicate int NOT NULL DEFAULT '0',
107
-    state int NOT NULL DEFAULT '0',
108
-    flags int NOT NULL DEFAULT '0',
109
-    user_agent string(64) NOT NULL DEFAULT ''
107
+    username VARCHAR(64) NOT NULL DEFAULT '',
108
+    domain VARCHAR(128) NOT NULL DEFAULT '',
109
+    contact VARCHAR(255) NOT NULL DEFAULT '',
110
+    received VARCHAR(255) DEFAULT NULL,
111
+    expires TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00',
112
+    q REAL NOT NULL DEFAULT '1.0',
113
+    callid VARCHAR(255) NOT NULL DEFAULT 'default_callid',
114
+    cseq INTEGER NOT NULL DEFAULT '42',
115
+    last_modified TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00',
116
+    replicate INTEGER NOT NULL DEFAULT '0',
117
+    state INTEGER NOT NULL DEFAULT '0',
118
+    flags INTEGER NOT NULL DEFAULT '0',
119
+    user_agent VARCHAR(64) NOT NULL DEFAULT ''
110 120
 );
111 121
 
122
+CREATE INDEX location_key ON location (username, domain, contact);
123
+CREATE INDEX location_contact ON location (contact);
124
+
112 125
 CREATE TABLE missed_calls (
113
-    sip_from string(255) NOT NULL DEFAULT '',
114
-    sip_to string(255) NOT NULL DEFAULT '',
115
-    sip_status string(128) NOT NULL DEFAULT '',
116
-    sip_method string(16) NOT NULL DEFAULT '',
117
-    i_uri string(255) NOT NULL DEFAULT '',
118
-    o_uri string(255) NOT NULL DEFAULT '',
119
-    from_uri string(255) NOT NULL DEFAULT '',
120
-    to_uri string(255) NOT NULL DEFAULT '',
121
-    sip_callid string(255) NOT NULL DEFAULT '',
122
-    username string(64) NOT NULL DEFAULT '',
123
-    domain string(128) NOT NULL DEFAULT '',
124
-    fromtag string(128) NOT NULL DEFAULT '',
125
-    totag string(128) NOT NULL DEFAULT '',
126
-    time datetime NOT NULL DEFAULT '0',
127
-    timestamp datetime NOT NULL DEFAULT ''
126
+    sip_from VARCHAR(255) NOT NULL DEFAULT '',
127
+    sip_to VARCHAR(255) NOT NULL DEFAULT '',
128
+    sip_status VARCHAR(128) NOT NULL DEFAULT '',
129
+    sip_method VARCHAR(16) NOT NULL DEFAULT '',
130
+    i_uri VARCHAR(255) NOT NULL DEFAULT '',
131
+    o_uri VARCHAR(255) NOT NULL DEFAULT '',
132
+    from_uri VARCHAR(255) NOT NULL DEFAULT '',
133
+    to_uri VARCHAR(255) NOT NULL DEFAULT '',
134
+    sip_callid VARCHAR(255) NOT NULL DEFAULT '',
135
+    username VARCHAR(64) NOT NULL DEFAULT '',
136
+    domain VARCHAR(128) NOT NULL DEFAULT '',
137
+    fromtag VARCHAR(128) NOT NULL DEFAULT '',
138
+    totag VARCHAR(128) NOT NULL DEFAULT '',
139
+    time TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00',
140
+    timestamp TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00'
128 141
 );
129 142
 
143
+CREATE INDEX mc_user ON missed_calls (username, domain);
144
+
130 145
 CREATE TABLE pending (
131
-    phplib_id string(32) NOT NULL DEFAULT '',
132
-    username string(64) NOT NULL DEFAULT '',
133
-    domain string(128) NOT NULL DEFAULT '',
134
-    password string(25) NOT NULL DEFAULT '',
135
-    first_name string(25) NOT NULL DEFAULT '',
136
-    last_name string(45) NOT NULL DEFAULT '',
137
-    phone string(15) NOT NULL DEFAULT '',
138
-    email_address string(50) NOT NULL DEFAULT '',
139
-    datetime_created datetime NOT NULL DEFAULT '0',
140
-    datetime_modified datetime NOT NULL DEFAULT '0',
141
-    confirmation string(64) NOT NULL DEFAULT '',
142
-    flag string(1) NOT NULL DEFAULT 'o',
143
-    sendnotification string(50) NOT NULL DEFAULT '',
144
-    greeting string(50) NOT NULL DEFAULT '',
145
-    ha1 string(128) NOT NULL DEFAULT '',
146
-    ha1b string(128) NOT NULL DEFAULT '',
147
-    allow_find string(1) NOT NULL DEFAULT '',
148
-    timezone string(128) NOT NULL DEFAULT '',
149
-    rpid string(255) NOT NULL DEFAULT '',
150
-    domn int(10) NOT NULL DEFAULT '',
151
-    uuid string(255) NOT NULL DEFAULT ''
146
+    phplib_id VARCHAR(32) NOT NULL DEFAULT '',
147
+    username VARCHAR(64) NOT NULL DEFAULT '',
148
+    domain VARCHAR(128) NOT NULL DEFAULT '',
149
+    password VARCHAR(25) NOT NULL DEFAULT '',
150
+    first_name VARCHAR(25) NOT NULL DEFAULT '',
151
+    last_name VARCHAR(45) NOT NULL DEFAULT '',
152
+    phone VARCHAR(15) NOT NULL DEFAULT '',
153
+    email_address VARCHAR(50) NOT NULL DEFAULT '',
154
+    datetime_created TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00',
155
+    datetime_modified TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00',
156
+    confirmation VARCHAR(64) NOT NULL DEFAULT '',
157
+    flag VARCHAR(1) NOT NULL DEFAULT 'o',
158
+    sendnotification VARCHAR(50) NOT NULL DEFAULT '',
159
+    greeting VARCHAR(50) NOT NULL DEFAULT '',
160
+    ha1 VARCHAR(128) NOT NULL DEFAULT '',
161
+    ha1b VARCHAR(128) NOT NULL DEFAULT '',
162
+    allow_find VARCHAR(1) NOT NULL DEFAULT '',
163
+    timezone VARCHAR(128) NOT NULL DEFAULT '',
164
+    rpid VARCHAR(255) NOT NULL DEFAULT '',
165
+    domn INTEGER NOT NULL DEFAULT '0',
166
+    uuid VARCHAR(255) NOT NULL DEFAULT ''
152 167
 );
153 168
 
169
+CREATE INDEX pending_idx1 ON pending (username, domain);
170
+CREATE INDEX user_2 ON pending (username);
171
+CREATE INDEX php ON pending (phplib_id);
172
+
154 173
 CREATE TABLE phonebook (
155
-    id int NOT NULL DEFAULT '',
156
-    username string(64) NOT NULL DEFAULT '',
157
-    domain string(128) NOT NULL DEFAULT '',
158
-    fname string(32) NOT NULL DEFAULT '',
159
-    lname string(32) NOT NULL DEFAULT '',
160
-    sip_uri string(255) NOT NULL DEFAULT ''
174
+    id INTEGER NOT NULL DEFAULT '0',
175
+    username VARCHAR(64) NOT NULL DEFAULT '',
176
+    domain VARCHAR(128) NOT NULL DEFAULT '',
177
+    fname VARCHAR(32) NOT NULL DEFAULT '',
178
+    lname VARCHAR(32) NOT NULL DEFAULT '',
179
+    sip_uri VARCHAR(255) NOT NULL DEFAULT ''
161 180
 );
162 181
 
182
+CREATE INDEX pb_idx ON phonebook (id);
183
+
163 184
 CREATE TABLE reserved (
164
-    username string(64) NOT NULL,
165
-    user2 UNIQUE (username, )
185
+    username VARCHAR(64) NOT NULL,
186
+    CONSTRAINT user2 UNIQUE (username)
166 187
 );
167 188
 
168 189
 CREATE TABLE subscriber (
169
-    phplib_id string(32) NOT NULL DEFAULT '',
170
-    username string(64) NOT NULL DEFAULT '',
171
-    domain string(128) NOT NULL DEFAULT '',
172
-    password string(25) NOT NULL DEFAULT '',
173
-    first_name string(25) NOT NULL DEFAULT '',
174
-    last_name string(45) NOT NULL DEFAULT '',
175
-    phone string(15) NOT NULL DEFAULT '',
176
-    email_address string(50) NOT NULL DEFAULT '',
177
-    datetime_created datetime NOT NULL DEFAULT '0',
178
-    datetime_modified datetime NOT NULL DEFAULT '0',
179
-    confirmation string(64) NOT NULL DEFAULT '',
180
-    flag string(1) NOT NULL DEFAULT 'o',
181
-    sendnotification string(50) NOT NULL DEFAULT '',
182
-    greeting string(50) NOT NULL DEFAULT '',
183
-    ha1 string(128) NOT NULL DEFAULT '',
184
-    ha1b string(128) NOT NULL DEFAULT '',
185
-    allow_find string(1) NOT NULL DEFAULT '',
186
-    timezone string(128) NOT NULL DEFAULT '',
187
-    rpid string(255) NOT NULL DEFAULT '',
188
-    domn int(10) NOT NULL DEFAULT '',
189
-    uuid string(255) NOT NULL DEFAULT '',
190
-     UNIQUE (username, domain, ),
191
-
190
+    phplib_id VARCHAR(32) NOT NULL DEFAULT '',
191
+    username VARCHAR(64) NOT NULL DEFAULT '',
192
+    domain VARCHAR(128) NOT NULL DEFAULT '',
193
+    password VARCHAR(25) NOT NULL DEFAULT '',
194
+    first_name VARCHAR(25) NOT NULL DEFAULT '',
195
+    last_name VARCHAR(45) NOT NULL DEFAULT '',
196
+    phone VARCHAR(15) NOT NULL DEFAULT '',
197
+    email_address VARCHAR(50) NOT NULL DEFAULT '',
198
+    datetime_created TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00',
199
+    datetime_modified TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00',
200
+    confirmation VARCHAR(64) NOT NULL DEFAULT '',
201
+    flag VARCHAR(1) NOT NULL DEFAULT 'o',
202
+    sendnotification VARCHAR(50) NOT NULL DEFAULT '',
203
+    greeting VARCHAR(50) NOT NULL DEFAULT '',
204
+    ha1 VARCHAR(128) NOT NULL DEFAULT '',
205
+    ha1b VARCHAR(128) NOT NULL DEFAULT '',
206
+    allow_find VARCHAR(1) NOT NULL DEFAULT '',
207
+    timezone VARCHAR(128) NOT NULL DEFAULT '',
208
+    rpid VARCHAR(255) NOT NULL DEFAULT '',
209
+    domn INTEGER NOT NULL DEFAULT '0',
210
+    uuid VARCHAR(255) NOT NULL DEFAULT '',
211
+    UNIQUE (username, domain)
192 212
 );
193 213
 
214
+CREATE INDEX sub_idx1 ON subscriber (username);
215
+CREATE INDEX phplib_id ON subscriber (phplib_id);
216
+
194 217
 CREATE TABLE config (
195
-    attribute string(32) NOT NULL,
196
-    value string(128) NOT NULL,
197
-    username string(64) NOT NULL DEFAULT '',
198
-    domain string(128) NOT NULL DEFAULT '',
199
-    modified datetime
218
+    attribute VARCHAR(32) NOT NULL,
219
+    value VARCHAR(128) NOT NULL,
220
+    username VARCHAR(64) NOT NULL DEFAULT '',
221
+    domain VARCHAR(128) NOT NULL DEFAULT '',
222
+    modified TIMESTAMP
200 223
 );
201 224
 
202 225
 CREATE TABLE silo (
203
-    mid int NOT NULL,
204
-    src_addr string(255) NOT NULL DEFAULT '',
205
-    dst_addr string(255) NOT NULL DEFAULT '',
206
-    r_uri string(255) NOT NULL DEFAULT '',
207
-    username string(64) NOT NULL DEFAULT '',
208
-    domain string(128) NOT NULL DEFAULT '',
209
-    inc_time datetime NOT NULL DEFAULT '0',
210
-    exp_time datetime NOT NULL DEFAULT '0',
211
-    ctype string(128) NOT NULL DEFAULT 'text/plain',
212
-    body binary NOT NULL DEFAULT ''
226
+    mid INTEGER NOT NULL,
227
+    src_addr VARCHAR(255) NOT NULL DEFAULT '',
228
+    dst_addr VARCHAR(255) NOT NULL DEFAULT '',
229
+    r_uri VARCHAR(255) NOT NULL DEFAULT '',
230
+    username VARCHAR(64) NOT NULL DEFAULT '',
231
+    domain VARCHAR(128) NOT NULL DEFAULT '',
232
+    inc_time TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00',
233
+    exp_time TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00',
234
+    ctype VARCHAR(128) NOT NULL DEFAULT 'text/plain',
235
+    body BYTEA NOT NULL DEFAULT ''
213 236
 );
214 237
 
238
+CREATE INDEX silo_idx1 ON silo (mid);
239
+
215 240
 CREATE TABLE domain (
216
-    domain string(128) NOT NULL DEFAULT '',
217
-    last_modified datetime NOT NULL DEFAULT '0'
241
+    domain VARCHAR(128) NOT NULL DEFAULT '',
242
+    last_modified TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00'
218 243
 );
219 244
 
245
+CREATE INDEX domain_idx1 ON domain (domain);
246
+
220 247
 CREATE TABLE uri (
221
-    username string(64) NOT NULL DEFAULT '',
222
-    domain string(128) NOT NULL DEFAULT '',
223
-    uri_user string(64) NOT NULL DEFAULT '',
224
-    last_modified datetime NOT NULL DEFAULT ''
248
+    username VARCHAR(64) NOT NULL DEFAULT '',
249
+    domain VARCHAR(128) NOT NULL DEFAULT '',
250
+    uri_user VARCHAR(64) NOT NULL DEFAULT '',
251
+    last_modified TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00'
225 252
 );
226 253
 
254
+CREATE INDEX uri_idx1 ON uri (username, domain, uri_user);
255
+
227 256
 CREATE TABLE server_monitoring (
228
-    time datetime NOT NULL DEFAULT '0',
229
-    id int NOT NULL DEFAULT '0',
230
-    param string(32) NOT NULL DEFAULT '',
231
-    value int NOT NULL DEFAULT '0',
232
-    increment int NOT NULL DEFAULT '0'
257
+    time TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00',
258
+    id INTEGER NOT NULL DEFAULT '0',
259
+    param VARCHAR(32) NOT NULL DEFAULT '',
260
+    value INTEGER NOT NULL DEFAULT '0',
261
+    increment INTEGER NOT NULL DEFAULT '0'
233 262
 );
234 263
 
264
+CREATE INDEX sm_idx1 ON server_monitoring (id, param);
265
+
235 266
 CREATE TABLE usr_preferences (
236
-    uuid string(255) NOT NULL DEFAULT '',
237
-    username string(64) NOT NULL DEFAULT '',
238
-    domain string(128) NOT NULL DEFAULT '',
239
-    attribute string(32) NOT NULL DEFAULT '',
240
-    value string(128) NOT NULL DEFAULT '',
241
-    type int NOT NULL DEFAULT '0',
242
-    modified datetime NOT NULL
267
+    uuid VARCHAR(255) NOT NULL DEFAULT '',
268
+    username VARCHAR(64) NOT NULL DEFAULT '',
269
+    domain VARCHAR(128) NOT NULL DEFAULT '',
270
+    attribute VARCHAR(32) NOT NULL DEFAULT '',
271
+    value VARCHAR(128) NOT NULL DEFAULT '',
272
+    type INTEGER NOT NULL DEFAULT '0',
273
+    modified TIMESTAMP NOT NULL
243 274
 );
244 275
 
276
+CREATE INDEX up_idx ON usr_preferences (attribute, username, domain);
277
+
245 278
 CREATE TABLE usr_preferences_types (
246
-    att_name string(32) NOT NULL DEFAULT '',
247
-    att_rich_type string(32) NOT NULL DEFAULT 'string',
248
-    att_raw_type int NOT NULL DEFAULT '2',
249
-    att_type_spec string(255),
250
-    default_value string(100) NOT NULL DEFAULT ''
279
+    att_name VARCHAR(32) NOT NULL DEFAULT '',
280
+    att_rich_type VARCHAR(32) NOT NULL DEFAULT 'string',
281
+    att_raw_type INTEGER NOT NULL DEFAULT '2',
282
+    att_type_spec VARCHAR(255),
283
+    default_value VARCHAR(100) NOT NULL DEFAULT ''
251 284
 );
252 285
 
286
+CREATE INDEX upt_idx1 ON usr_preferences_types (att_name);
287
+
253 288
 CREATE TABLE trusted (
254
-    src_ip string(39) NOT NULL,
255
-    proto string(4) NOT NULL,
256
-    from_pattern string(64) NOT NULL
289
+    src_ip VARCHAR(39) NOT NULL,
290
+    proto VARCHAR(4) NOT NULL,
291
+    from_pattern VARCHAR(64) NOT NULL
257 292
 );
258 293
 
294
+CREATE INDEX trusted_idx ON trusted (src_ip, proto, from_pattern);
295
+
259 296
 CREATE TABLE server_monitoring_agg (
260
-    param string(32) NOT NULL DEFAULT '',
261
-    s_value int NOT NULL DEFAULT '0',
262
-    s_increment int NOT NULL DEFAULT '0',
263
-    last_aggregated_increment int NOT NULL DEFAULT '0',
264
-    av double NOT NULL DEFAULT '0',
265
-    mv int NOT NULL DEFAULT '0',
266
-    ad double NOT NULL DEFAULT '0',
267
-    lv int NOT NULL DEFAULT '0',
268
-    min_val int NOT NULL DEFAULT '0',
269
-    max_val int NOT NULL DEFAULT '0',
270
-    min_inc int NOT NULL DEFAULT '0',
271
-    max_inc int NOT NULL DEFAULT '0',
272
-    lastupdate datetime NOT NULL DEFAULT '0'
297
+    param VARCHAR(32) NOT NULL DEFAULT '',
298
+    s_value INTEGER NOT NULL DEFAULT '0',
299
+    s_increment INTEGER NOT NULL DEFAULT '0',
300
+    last_aggregated_increment INTEGER NOT NULL DEFAULT '0',
301
+    av DOUBLE PRECISION NOT NULL DEFAULT '0',
302
+    mv INTEGER NOT NULL DEFAULT '0',
303
+    ad DOUBLE PRECISION NOT NULL DEFAULT '0',
304
+    lv INTEGER NOT NULL DEFAULT '0',
305
+    min_val INTEGER NOT NULL DEFAULT '0',
306
+    max_val INTEGER NOT NULL DEFAULT '0',
307
+    min_inc INTEGER NOT NULL DEFAULT '0',
308
+    max_inc INTEGER NOT NULL DEFAULT '0',
309
+    lastupdate TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00'
273 310
 );
274 311
 
312
+CREATE INDEX smagg_idx1 ON server_monitoring_agg (param);
313
+
275 314
 CREATE TABLE admin_privileges (
276
-    username string(64) NOT NULL DEFAULT '',
277
-    domain string(128) NOT NULL DEFAULT '',
278
-    priv_name string(64) NOT NULL DEFAULT '',
279
-    priv_value string(64) NOT NULL DEFAULT '0'
315
+    username VARCHAR(64) NOT NULL DEFAULT '',
316
+    domain VARCHAR(128) NOT NULL DEFAULT '',
317
+    priv_name VARCHAR(64) NOT NULL DEFAULT '',
318
+    priv_value VARCHAR(64) NOT NULL DEFAULT '0'
280 319
 );
281 320
 
321
+CREATE INDEX adminpriv_idx1 ON admin_privileges (username, priv_name, priv_value, domain);
322
+
282 323
 CREATE TABLE call_forwarding (
283
-    username string(64) NOT NULL DEFAULT '',
284
-    domain string(128) NOT NULL DEFAULT '',
285
-    uri_re string(128) NOT NULL DEFAULT '',
286
-    purpose string(32) NOT NULL DEFAULT '',
287
-    action string(32) NOT NULL DEFAULT '',
288
-    param1 string(128) DEFAULT '',
289
-    param2 string(128) DEFAULT '',
290
-    cf_key UNIQUE (username, domain, uri_re, purpose, )
324
+    username VARCHAR(64) NOT NULL DEFAULT '',
325
+    domain VARCHAR(128) NOT NULL DEFAULT '',
326
+    uri_re VARCHAR(128) NOT NULL DEFAULT '',
327
+    purpose VARCHAR(32) NOT NULL DEFAULT '',
328
+    action VARCHAR(32) NOT NULL DEFAULT '',
329
+    param1 VARCHAR(128) DEFAULT '',
330
+    param2 VARCHAR(128) DEFAULT '',
331
+    CONSTRAINT cf_key UNIQUE (username, domain, uri_re, purpose)
291 332
 );
292 333
 
293 334
 CREATE TABLE speed_dial (
294
-    uuid string(255) NOT NULL DEFAULT '',
295
-    username string(64) NOT NULL DEFAULT '',
296
-    domain string(128) NOT NULL DEFAULT '',
297
-    sd_username string(64) NOT NULL DEFAULT '',
298
-    sd_domain string(128) NOT NULL DEFAULT '',
299
-    new_uri string(255) NOT NULL DEFAULT '',
300
-    fname string(128) NOT NULL DEFAULT '',
301
-    lname string(128) NOT NULL DEFAULT '',
302
-    description string(64) NOT NULL DEFAULT ''
335
+    uuid VARCHAR(255) NOT NULL DEFAULT '',
336
+    username VARCHAR(64) NOT NULL DEFAULT '',
337
+    domain VARCHAR(128) NOT NULL DEFAULT '',
338
+    sd_username VARCHAR(64) NOT NULL DEFAULT '',
339
+    sd_domain VARCHAR(128) NOT NULL DEFAULT '',
340
+    new_uri VARCHAR(255) NOT NULL DEFAULT '',
341
+    fname VARCHAR(128) NOT NULL DEFAULT '',
342
+    lname VARCHAR(128) NOT NULL DEFAULT '',
343
+    description VARCHAR(64) NOT NULL DEFAULT ''
303 344
 );
304 345
 
346
+CREATE INDEX speeddial_idx1 ON speed_dial (username, domain, sd_username, sd_domain);
347
+
305 348
 CREATE TABLE gw (
306
-    gw_name string(128) NOT NULL,
307
-    ip_addr int NOT NULL,
308
-    port short,
309
-    uri_scheme char,
310
-    transport short,
311
-    grp_id int NOT NULL
349
+    gw_name VARCHAR(128) NOT NULL,
350
+    ip_addr INTEGER NOT NULL,
351
+    port SMALLINT,
352
+    uri_scheme SMALLINT,
353
+    transport SMALLINT,
354
+    grp_id INTEGER NOT NULL
312 355
 );
313 356
 
357
+CREATE INDEX gw_idx1 ON gw (gw_name);
358
+CREATE INDEX gw_idx2 ON gw (grp_id);
359
+
314 360
 CREATE TABLE gw_grp (
315
-    grp_id int NOT NULL,
316
-    grp_name string(64) NOT NULL
361
+    grp_id INTEGER NOT NULL,
362
+    grp_name VARCHAR(64) NOT NULL
317 363
 );
318 364
 
319 365
 CREATE TABLE lcr (
320
-    prefix string(16) NOT NULL,
321
-    from_uri int(255) NOT NULL DEFAULT '%',
322
-    grp_id int,
323
-    priority int
366
+    prefix VARCHAR(16) NOT NULL,
367
+    from_uri VARCHAR(255) NOT NULL DEFAULT '%',
368
+    grp_id INTEGER,
369
+    priority INTEGER
324 370
 );
325 371
 
372
+CREATE INDEX lcr_idx1 ON lcr (prefix);
373
+CREATE INDEX lcr_idx2 ON lcr (from_uri);
374
+CREATE INDEX lcr_idx3 ON lcr (grp_id);
375
+
... ...
@@ -1,31 +0,0 @@
1
-USE pg_ser;
2
-
3
-DROP TABLE version;
4
-DROP TABLE acc;
5
-DROP TABLE active_sessions;
6
-DROP TABLE aliases;
7
-DROP TABLE event;
8
-DROP TABLE grp;
9
-DROP TABLE location;
10
-DROP TABLE missed_calls;
11
-DROP TABLE pending;
12
-DROP TABLE phonebook;
13
-DROP TABLE reserved;
14
-DROP TABLE subscriber;
15
-DROP TABLE config;
16
-DROP TABLE silo;
17
-DROP TABLE domain;
18
-DROP TABLE uri;
19
-DROP TABLE server_monitoring;
20
-DROP TABLE usr_preferences;
21
-DROP TABLE usr_preferences_types;
22
-DROP TABLE trusted;
23
-DROP TABLE server_monitoring_agg;
24
-DROP TABLE admin_privileges;
25
-DROP TABLE call_forwarding;
26
-DROP TABLE speed_dial;
27
-DROP TABLE gw;
28
-DROP TABLE gw_grp;
29
-DROP TABLE lcr;
30
-
31
-DROP DATABASE pg_ser;