]> git.mxchange.org Git - friendica.git/blob - include/dbstructure.php
The CSS code for shared messages is moved from "vier" to the global.css, so that...
[friendica.git] / include / dbstructure.php
1 <?php
2
3 require_once("boot.php");
4
5 function dbstructure_run(&$argv, &$argc) {
6         global $a, $db;
7
8         if(is_null($a)){
9                 $a = new App;
10         }
11
12         if(is_null($db)) {
13                 @include(".htconfig.php");
14                 require_once("include/dba.php");
15                 $db = new dba($db_host, $db_user, $db_pass, $db_data);
16                         unset($db_host, $db_user, $db_pass, $db_data);
17         }
18
19         load_config('config');
20         load_config('system');
21
22         update_structure($a);
23 }
24
25 if (array_search(__file__,get_included_files())===0){
26         dbstructure_run($argv,$argc);
27         killme();
28 }
29
30 function table_structure($table) {
31         $structures = q("DESCRIBE `%s`", $table);
32
33         $indexes = q("SHOW INDEX FROM `%s`", $table);
34
35         $fielddata = array();
36         $indexdata = array();
37
38         if (is_array($indexes))
39                 foreach ($indexes AS $index) {
40                         if ($index["Index_type"] == "FULLTEXT")
41                                 continue;
42
43                         $column = $index["Column_name"];
44                         if ($index["Sub_part"] != "")
45                                 $column .= "(".$index["Sub_part"].")";
46
47                         $indexdata[$index["Key_name"]][] = $column;
48                 }
49
50         if (is_array($structures)) {
51                 foreach($structures AS $field) {
52                         $fielddata[$field["Field"]]["type"] = $field["Type"];
53                         if ($field["Null"] == "NO")
54                                 $fielddata[$field["Field"]]["not null"] = true;
55
56                         if ($field["Default"] != "")
57                                 $fielddata[$field["Field"]]["default"] = $field["Default"];
58
59                         if ($field["Extra"] != "")
60                                 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
61
62                         if ($field["Key"] == "PRI")
63                                 $fielddata[$field["Field"]]["primary"] = true;
64                 }
65         }
66
67         return(array("fields"=>$fielddata, "indexes"=>$indexdata));
68 }
69
70 function print_structure($db) {
71         foreach ($db AS $name => $structure) {
72                 echo "\t".'$db["'.$name."\"] = array(\n";
73
74                 echo "\t\t\t".'"fields" => array('."\n";
75                 foreach ($structure["fields"] AS $fieldname => $parameters) {
76                         echo "\t\t\t\t\t".'"'.$fieldname.'" => array(';
77
78                         $data = "";
79                         foreach ($parameters AS $name => $value) {
80                                 if ($data != "")
81                                         $data .= ", ";
82                                 $data .= '"'.$name.'" => "'.$value.'"';
83                         }
84
85                         echo $data."),\n";
86                 }
87                 echo "\t\t\t\t\t),\n";
88                 echo "\t\t\t".'"indexes" => array('."\n";
89                 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
90                         echo "\t\t\t\t\t".'"'.$indexname.'" => array("'.implode($fieldnames, '","').'"'."),\n";
91                 }
92                 echo "\t\t\t\t\t)\n";
93                 echo "\t\t\t);\n";
94         }
95 }
96
97 function update_structure($a) {
98
99         // Get the current structure
100         $db = array();
101
102         $tables = q("show tables");
103
104         foreach ($tables AS $table) {
105                 $table = current($table);
106
107                 $db[$table] = table_structure($table);
108         }
109
110         // Get the definition
111         $definition = db_definition();
112
113         // Compare it
114         foreach ($definition AS $name => $structure) {
115                 if (!isset($db[$name]))
116                         db_create_table($name, $structure["fields"]);
117                 else {
118                         // Compare the field structure field by field
119                         foreach ($structure["fields"] AS $fieldname => $parameters) {
120                                 if (!isset($db[$name]["fields"][$fieldname]))
121                                         db_add_table_field($name, $fieldname, $parameters);
122                                 else {
123                                         // Compare the field definition
124                                         $current_field_definition = implode($db[$name]["fields"][$fieldname]);
125                                         $new_field_definition = implode($parameters);
126                                         if ($current_field_definition != $new_field_definition)
127                                                 db_modify_table_field($name, $fieldname, $parameters);
128                                 }
129                         }
130                 }
131
132                 // Drop the index if it isn't present in the definition
133                 if (isset($db[$name]))
134                         foreach ($db[$name]["indexes"] AS $indexname => $fieldnames)
135                                 if (!isset($structure["indexes"][$indexname]))
136                                         db_drop_index($name, $indexname);
137
138                 // Create the index
139                 foreach ($structure["indexes"] AS $indexname => $fieldnames)
140                         if (!isset($db[$name]["indexes"][$indexname]))
141                                 db_create_index($name, $indexname, $fieldnames);
142         }
143 }
144
145 function db_field_command($parameters, $create = true) {
146         $fieldstruct = $parameters["type"];
147
148         if ($parameters["not null"])
149                 $fieldstruct .= " NOT NULL";
150
151         if ($parameters["default"] != "")
152                 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
153
154         if ($parameters["extra"] != "")
155                 $fieldstruct .= " ".$parameters["extra"];
156
157         if (($parameters["primary"] != "") AND $create)
158                 $fieldstruct .= " PRIMARY KEY";
159
160         return($fieldstruct);
161 }
162
163 function db_create_table($name, $fields) {
164         $sql = "";
165         foreach($fields AS $fieldname => $field) {
166                 if ($sql != "")
167                         $sql .= ",\n";
168
169                 $sql .= "`".dbesc($fieldname)."` ".db_field_command($field);
170         }
171
172         $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n", dbesc($name)).$sql."\n) DEFAULT CHARSET=utf8";
173         echo $sql.";\n";
174         //$ret = q($sql);
175 }
176
177 function db_add_table_field($name, $fieldname, $parameters) {
178         $sql = sprintf("ALTER TABLE `%s` ADD `%s` %s", dbesc($name), dbesc($fieldname), db_field_command($parameters));
179         echo $sql.";\n";
180         //$ret = q($sql);
181 }
182
183 function db_modify_table_field($name, $fieldname, $parameters) {
184         $sql = sprintf("ALTER TABLE `%s` MODIFY `%s` %s", dbesc($name), dbesc($fieldname), db_field_command($parameters, false));
185         echo $sql.";\n";
186         //$ret = q($sql);
187 }
188
189 function db_drop_index($name, $indexname) {
190         $sql = sprintf("DROP INDEX `%s` ON `%s`", dbesc($indexname), dbesc($name));
191         echo $sql.";\n";
192         //$ret = q($sql);
193 }
194
195 function db_create_index($name, $indexname, $fieldnames) {
196
197         if ($indexname == "PRIMARY")
198                 return;
199
200         $names = "";
201         foreach ($fieldnames AS $fieldname) {
202                 if ($names != "")
203                         $names .= ",";
204
205                 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches))
206                         $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
207                 else
208                         $names .= "`".dbesc($fieldname)."`";
209         }
210
211         $sql = sprintf("CREATE INDEX `%s` ON `%s`(%s)", dbesc($indexname), dbesc($name), $names);
212         echo $sql."\n";
213         //$ret = q($sql);
214 }
215
216 function db_definition() {
217
218         $db = array();
219
220         $db["addon"] = array(
221                         "fields" => array(
222                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
223                                         "name" => array("type" => "char(255)", "not null" => "1"),
224                                         "version" => array("type" => "char(255)", "not null" => "1"),
225                                         "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
226                                         "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
227                                         "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
228                                         "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
229                                         ),
230                         "indexes" => array(
231                                         "PRIMARY" => array("id"),
232                                         )
233                         );
234         $db["attach"] = array(
235                         "fields" => array(
236                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
237                                         "uid" => array("type" => "int(11)", "not null" => "1"),
238                                         "hash" => array("type" => "char(64)", "not null" => "1"),
239                                         "filename" => array("type" => "char(255)", "not null" => "1"),
240                                         "filetype" => array("type" => "char(64)", "not null" => "1"),
241                                         "filesize" => array("type" => "int(11)", "not null" => "1"),
242                                         "data" => array("type" => "longblob", "not null" => "1"),
243                                         "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
244                                         "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
245                                         "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
246                                         "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
247                                         "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
248                                         "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
249                                         ),
250                         "indexes" => array(
251                                         "PRIMARY" => array("id"),
252                                         )
253                         );
254         $db["auth_codes"] = array(
255                         "fields" => array(
256                                         "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
257                                         "client_id" => array("type" => "varchar(20)", "not null" => "1"),
258                                         "redirect_uri" => array("type" => "varchar(200)", "not null" => "1"),
259                                         "expires" => array("type" => "int(11)", "not null" => "1"),
260                                         "scope" => array("type" => "varchar(250)", "not null" => "1"),
261                                         ),
262                         "indexes" => array(
263                                         "PRIMARY" => array("id"),
264                                         )
265                         );
266         $db["cache"] = array(
267                         "fields" => array(
268                                         "k" => array("type" => "char(255)", "not null" => "1", "primary" => "1"),
269                                         "v" => array("type" => "text", "not null" => "1"),
270                                         "updated" => array("type" => "datetime", "not null" => "1"),
271                                         ),
272                         "indexes" => array(
273                                         "PRIMARY" => array("k"),
274                                         "updated" => array("updated"),
275                                         )
276                         );
277         $db["challenge"] = array(
278                         "fields" => array(
279                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
280                                         "challenge" => array("type" => "char(255)", "not null" => "1"),
281                                         "dfrn-id" => array("type" => "char(255)", "not null" => "1"),
282                                         "expire" => array("type" => "int(11)", "not null" => "1"),
283                                         "type" => array("type" => "char(255)", "not null" => "1"),
284                                         "last_update" => array("type" => "char(255)", "not null" => "1"),
285                                         ),
286                         "indexes" => array(
287                                         "PRIMARY" => array("id"),
288                                         )
289                         );
290         $db["clients"] = array(
291                         "fields" => array(
292                                         "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
293                                         "pw" => array("type" => "varchar(20)", "not null" => "1"),
294                                         "redirect_uri" => array("type" => "varchar(200)", "not null" => "1"),
295                                         "name" => array("type" => "text"),
296                                         "icon" => array("type" => "text"),
297                                         "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
298                                         ),
299                         "indexes" => array(
300                                         "PRIMARY" => array("client_id"),
301                                         )
302                         );
303         $db["config"] = array(
304                         "fields" => array(
305                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
306                                         "cat" => array("type" => "char(255)", "not null" => "1"),
307                                         "k" => array("type" => "char(255)", "not null" => "1"),
308                                         "v" => array("type" => "text", "not null" => "1"),
309                                         ),
310                         "indexes" => array(
311                                         "PRIMARY" => array("id"),
312                                         "access" => array("cat","k"),
313                                         )
314                         );
315         $db["contact"] = array(
316                         "fields" => array(
317                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
318                                         "uid" => array("type" => "int(11)", "not null" => "1"),
319                                         "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
320                                         "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
321                                         "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
322                                         "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
323                                         "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
324                                         "network" => array("type" => "char(255)", "not null" => "1"),
325                                         "name" => array("type" => "char(255)", "not null" => "1"),
326                                         "nick" => array("type" => "char(255)", "not null" => "1"),
327                                         "attag" => array("type" => "char(255)", "not null" => "1"),
328                                         "photo" => array("type" => "text", "not null" => "1"),
329                                         "thumb" => array("type" => "text", "not null" => "1"),
330                                         "micro" => array("type" => "text", "not null" => "1"),
331                                         "site-pubkey" => array("type" => "text", "not null" => "1"),
332                                         "issued-id" => array("type" => "char(255)", "not null" => "1"),
333                                         "dfrn-id" => array("type" => "char(255)", "not null" => "1"),
334                                         "url" => array("type" => "char(255)", "not null" => "1"),
335                                         "nurl" => array("type" => "char(255)", "not null" => "1"),
336                                         "addr" => array("type" => "char(255)", "not null" => "1"),
337                                         "alias" => array("type" => "char(255)", "not null" => "1"),
338                                         "pubkey" => array("type" => "text", "not null" => "1"),
339                                         "prvkey" => array("type" => "text", "not null" => "1"),
340                                         "batch" => array("type" => "char(255)", "not null" => "1"),
341                                         "request" => array("type" => "text", "not null" => "1"),
342                                         "notify" => array("type" => "text", "not null" => "1"),
343                                         "poll" => array("type" => "text", "not null" => "1"),
344                                         "confirm" => array("type" => "text", "not null" => "1"),
345                                         "poco" => array("type" => "text", "not null" => "1"),
346                                         "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
347                                         "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
348                                         "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
349                                         "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
350                                         "hub-verify" => array("type" => "char(255)", "not null" => "1"),
351                                         "last-update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
352                                         "success_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
353                                         "name-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
354                                         "uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
355                                         "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
356                                         "term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
357                                         "priority" => array("type" => "tinyint(3)", "not null" => "1"),
358                                         "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
359                                         "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
360                                         "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
361                                         "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
362                                         "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
363                                         "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
364                                         "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
365                                         "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
366                                         "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
367                                         "reason" => array("type" => "text", "not null" => "1"),
368                                         "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
369                                         "info" => array("type" => "mediumtext", "not null" => "1"),
370                                         "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
371                                         "bdyear" => array("type" => "char(4)", "not null" => "1"),
372                                         "bd" => array("type" => "date", "not null" => "1"),
373                                         "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
374                                         "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
375                                         ),
376                         "indexes" => array(
377                                         "PRIMARY" => array("id"),
378                                         "uid" => array("uid"),
379                                         )
380                         );
381         $db["conv"] = array(
382                         "fields" => array(
383                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
384                                         "guid" => array("type" => "char(64)", "not null" => "1"),
385                                         "recips" => array("type" => "mediumtext", "not null" => "1"),
386                                         "uid" => array("type" => "int(11)", "not null" => "1"),
387                                         "creator" => array("type" => "char(255)", "not null" => "1"),
388                                         "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
389                                         "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
390                                         "subject" => array("type" => "mediumtext", "not null" => "1"),
391                                         ),
392                         "indexes" => array(
393                                         "PRIMARY" => array("id"),
394                                         "uid" => array("uid"),
395                                         )
396                         );
397         $db["deliverq"] = array(
398                         "fields" => array(
399                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
400                                         "cmd" => array("type" => "char(32)", "not null" => "1"),
401                                         "item" => array("type" => "int(11)", "not null" => "1"),
402                                         "contact" => array("type" => "int(11)", "not null" => "1"),
403                                         ),
404                         "indexes" => array(
405                                         "PRIMARY" => array("id"),
406                                         )
407                         );
408         $db["dsprphotoq"] = array(
409                         "fields" => array(
410                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
411                                         "uid" => array("type" => "int(11)", "not null" => "1"),
412                                         "msg" => array("type" => "mediumtext", "not null" => "1"),
413                                         "attempt" => array("type" => "tinyint(4)", "not null" => "1"),
414                                         ),
415                         "indexes" => array(
416                                         "PRIMARY" => array("id"),
417                                         )
418                         );
419         $db["event"] = array(
420                         "fields" => array(
421                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
422                                         "uid" => array("type" => "int(11)", "not null" => "1"),
423                                         "cid" => array("type" => "int(11)", "not null" => "1"),
424                                         "uri" => array("type" => "char(255)", "not null" => "1"),
425                                         "created" => array("type" => "datetime", "not null" => "1"),
426                                         "edited" => array("type" => "datetime", "not null" => "1"),
427                                         "start" => array("type" => "datetime", "not null" => "1"),
428                                         "finish" => array("type" => "datetime", "not null" => "1"),
429                                         "summary" => array("type" => "text", "not null" => "1"),
430                                         "desc" => array("type" => "text", "not null" => "1"),
431                                         "location" => array("type" => "text", "not null" => "1"),
432                                         "type" => array("type" => "char(255)", "not null" => "1"),
433                                         "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
434                                         "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
435                                         "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
436                                         "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
437                                         "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
438                                         "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
439                                         "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
440                                         ),
441                         "indexes" => array(
442                                         "PRIMARY" => array("id"),
443                                         "uid" => array("uid"),
444                                         )
445                         );
446         $db["fcontact"] = array(
447                         "fields" => array(
448                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
449                                         "url" => array("type" => "char(255)", "not null" => "1"),
450                                         "name" => array("type" => "char(255)", "not null" => "1"),
451                                         "photo" => array("type" => "char(255)", "not null" => "1"),
452                                         "request" => array("type" => "char(255)", "not null" => "1"),
453                                         "nick" => array("type" => "char(255)", "not null" => "1"),
454                                         "addr" => array("type" => "char(255)", "not null" => "1"),
455                                         "batch" => array("type" => "char(255)", "not null" => "1"),
456                                         "notify" => array("type" => "char(255)", "not null" => "1"),
457                                         "poll" => array("type" => "char(255)", "not null" => "1"),
458                                         "confirm" => array("type" => "char(255)", "not null" => "1"),
459                                         "priority" => array("type" => "tinyint(1)", "not null" => "1"),
460                                         "network" => array("type" => "char(32)", "not null" => "1"),
461                                         "alias" => array("type" => "char(255)", "not null" => "1"),
462                                         "pubkey" => array("type" => "text", "not null" => "1"),
463                                         "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
464                                         ),
465                         "indexes" => array(
466                                         "PRIMARY" => array("id"),
467                                         "addr" => array("addr"),
468                                         )
469                         );
470         $db["ffinder"] = array(
471                         "fields" => array(
472                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
473                                         "uid" => array("type" => "int(10) unsigned", "not null" => "1"),
474                                         "cid" => array("type" => "int(10) unsigned", "not null" => "1"),
475                                         "fid" => array("type" => "int(10) unsigned", "not null" => "1"),
476                                         ),
477                         "indexes" => array(
478                                         "PRIMARY" => array("id"),
479                                         )
480                         );
481         $db["fserver"] = array(
482                         "fields" => array(
483                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
484                                         "server" => array("type" => "char(255)", "not null" => "1"),
485                                         "posturl" => array("type" => "char(255)", "not null" => "1"),
486                                         "key" => array("type" => "text", "not null" => "1"),
487                                         ),
488                         "indexes" => array(
489                                         "PRIMARY" => array("id"),
490                                         "server" => array("server"),
491                                         )
492                         );
493         $db["fsuggest"] = array(
494                         "fields" => array(
495                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
496                                         "uid" => array("type" => "int(11)", "not null" => "1"),
497                                         "cid" => array("type" => "int(11)", "not null" => "1"),
498                                         "name" => array("type" => "char(255)", "not null" => "1"),
499                                         "url" => array("type" => "char(255)", "not null" => "1"),
500                                         "request" => array("type" => "char(255)", "not null" => "1"),
501                                         "photo" => array("type" => "char(255)", "not null" => "1"),
502                                         "note" => array("type" => "text", "not null" => "1"),
503                                         "created" => array("type" => "datetime", "not null" => "1"),
504                                         ),
505                         "indexes" => array(
506                                         "PRIMARY" => array("id"),
507                                         )
508                         );
509         $db["gcign"] = array(
510                         "fields" => array(
511                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
512                                         "uid" => array("type" => "int(11)", "not null" => "1"),
513                                         "gcid" => array("type" => "int(11)", "not null" => "1"),
514                                         ),
515                         "indexes" => array(
516                                         "PRIMARY" => array("id"),
517                                         "uid" => array("uid"),
518                                         "gcid" => array("gcid"),
519                                         )
520                         );
521         $db["gcontact"] = array(
522                         "fields" => array(
523                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
524                                         "name" => array("type" => "char(255)", "not null" => "1"),
525                                         "url" => array("type" => "char(255)", "not null" => "1"),
526                                         "nurl" => array("type" => "char(255)", "not null" => "1"),
527                                         "photo" => array("type" => "char(255)", "not null" => "1"),
528                                         "connect" => array("type" => "char(255)", "not null" => "1"),
529                                         ),
530                         "indexes" => array(
531                                         "PRIMARY" => array("id"),
532                                         "nurl" => array("nurl"),
533                                         )
534                         );
535         $db["glink"] = array(
536                         "fields" => array(
537                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
538                                         "cid" => array("type" => "int(11)", "not null" => "1"),
539                                         "uid" => array("type" => "int(11)", "not null" => "1"),
540                                         "gcid" => array("type" => "int(11)", "not null" => "1"),
541                                         "zcid" => array("type" => "int(11)", "not null" => "1"),
542                                         "updated" => array("type" => "datetime", "not null" => "1"),
543                                         ),
544                         "indexes" => array(
545                                         "PRIMARY" => array("id"),
546                                         "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
547                                         "gcid" => array("gcid"),
548                                         "zcid" => array("zcid"),
549                                         )
550                         );
551         $db["group"] = array(
552                         "fields" => array(
553                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
554                                         "uid" => array("type" => "int(10) unsigned", "not null" => "1"),
555                                         "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
556                                         "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
557                                         "name" => array("type" => "char(255)", "not null" => "1"),
558                                         ),
559                         "indexes" => array(
560                                         "PRIMARY" => array("id"),
561                                         "uid" => array("uid"),
562                                         )
563                         );
564         $db["group_member"] = array(
565                         "fields" => array(
566                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
567                                         "uid" => array("type" => "int(10) unsigned", "not null" => "1"),
568                                         "gid" => array("type" => "int(10) unsigned", "not null" => "1"),
569                                         "contact-id" => array("type" => "int(10) unsigned", "not null" => "1"),
570                                         ),
571                         "indexes" => array(
572                                         "PRIMARY" => array("id"),
573                                         "uid_gid_contactid" => array("uid","gid","contact-id"),
574                                         )
575                         );
576         $db["guid"] = array(
577                         "fields" => array(
578                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
579                                         "guid" => array("type" => "char(64)", "not null" => "1"),
580                                         ),
581                         "indexes" => array(
582                                         "PRIMARY" => array("id"),
583                                         "guid" => array("guid"),
584                                         )
585                         );
586         $db["hook"] = array(
587                         "fields" => array(
588                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
589                                         "hook" => array("type" => "char(255)", "not null" => "1"),
590                                         "file" => array("type" => "char(255)", "not null" => "1"),
591                                         "function" => array("type" => "char(255)", "not null" => "1"),
592                                         "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
593                                         ),
594                         "indexes" => array(
595                                         "PRIMARY" => array("id"),
596                                         "hook_file_function" => array("hook","file","function"),
597                                         )
598                         );
599         $db["intro"] = array(
600                         "fields" => array(
601                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
602                                         "uid" => array("type" => "int(10) unsigned", "not null" => "1"),
603                                         "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
604                                         "contact-id" => array("type" => "int(11)", "not null" => "1"),
605                                         "knowyou" => array("type" => "tinyint(1)", "not null" => "1"),
606                                         "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
607                                         "note" => array("type" => "text", "not null" => "1"),
608                                         "hash" => array("type" => "char(255)", "not null" => "1"),
609                                         "datetime" => array("type" => "datetime", "not null" => "1"),
610                                         "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
611                                         "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
612                                         ),
613                         "indexes" => array(
614                                         "PRIMARY" => array("id"),
615                                         )
616                         );
617         $db["item"] = array(
618                         "fields" => array(
619                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
620                                         "guid" => array("type" => "char(64)", "not null" => "1"),
621                                         "uri" => array("type" => "char(255)", "not null" => "1"),
622                                         "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
623                                         "contact-id" => array("type" => "int(11)", "not null" => "1"),
624                                         "type" => array("type" => "char(255)", "not null" => "1"),
625                                         "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
626                                         "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
627                                         "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
628                                         "parent-uri" => array("type" => "char(255)", "not null" => "1"),
629                                         "extid" => array("type" => "char(255)", "not null" => "1"),
630                                         "thr-parent" => array("type" => "char(255)", "not null" => "1"),
631                                         "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
632                                         "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
633                                         "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
634                                         "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
635                                         "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
636                                         "owner-name" => array("type" => "char(255)", "not null" => "1"),
637                                         "owner-link" => array("type" => "char(255)", "not null" => "1"),
638                                         "owner-avatar" => array("type" => "char(255)", "not null" => "1"),
639                                         "author-name" => array("type" => "char(255)", "not null" => "1"),
640                                         "author-link" => array("type" => "char(255)", "not null" => "1"),
641                                         "author-avatar" => array("type" => "char(255)", "not null" => "1"),
642                                         "title" => array("type" => "char(255)", "not null" => "1"),
643                                         "body" => array("type" => "mediumtext", "not null" => "1"),
644                                         "app" => array("type" => "char(255)", "not null" => "1"),
645                                         "verb" => array("type" => "char(255)", "not null" => "1"),
646                                         "object-type" => array("type" => "char(255)", "not null" => "1"),
647                                         "object" => array("type" => "text", "not null" => "1"),
648                                         "target-type" => array("type" => "char(255)", "not null" => "1"),
649                                         "target" => array("type" => "text", "not null" => "1"),
650                                         "postopts" => array("type" => "text", "not null" => "1"),
651                                         "plink" => array("type" => "char(255)", "not null" => "1"),
652                                         "resource-id" => array("type" => "char(255)", "not null" => "1"),
653                                         "event-id" => array("type" => "int(11)", "not null" => "1"),
654                                         "tag" => array("type" => "mediumtext", "not null" => "1"),
655                                         "attach" => array("type" => "mediumtext", "not null" => "1"),
656                                         "inform" => array("type" => "mediumtext", "not null" => "1"),
657                                         "file" => array("type" => "mediumtext", "not null" => "1"),
658                                         "location" => array("type" => "char(255)", "not null" => "1"),
659                                         "coord" => array("type" => "char(255)", "not null" => "1"),
660                                         "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
661                                         "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
662                                         "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
663                                         "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
664                                         "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
665                                         "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
666                                         "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
667                                         "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
668                                         "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
669                                         "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
670                                         "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
671                                         "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
672                                         "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
673                                         "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
674                                         "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
675                                         "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
676                                         "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
677                                         "network" => array("type" => "char(32)", "not null" => "1"),
678                                         ),
679                         "indexes" => array(
680                                         "PRIMARY" => array("id"),
681                                         "guid" => array("guid"),
682                                         "uri" => array("uri"),
683                                         "parent" => array("parent"),
684                                         "parent-uri" => array("parent-uri"),
685                                         "extid" => array("extid"),
686                                         "uid_id" => array("uid","id"),
687                                         "uid_created" => array("uid","created"),
688                                         "uid_unseen" => array("uid","unseen"),
689                                         "uid_network_received" => array("uid","network","received"),
690                                         "uid_received" => array("uid","received"),
691                                         "uid_network_commented" => array("uid","network","commented"),
692                                         "uid_commented" => array("uid","commented"),
693                                         "uid_title" => array("uid","title"),
694                                         "uid_thrparent" => array("uid","thr-parent"),
695                                         "uid_parenturi" => array("uid","parent-uri"),
696                                         "uid_contactid_created" => array("uid","contact-id","created"),
697                                         "wall_body" => array("wall","body(6)"),
698                                         "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
699                                         "uid_uri" => array("uid","uri"),
700                                         "uid_wall_created" => array("uid","wall","created"),
701                                         "resource-id" => array("resource-id"),
702                                         "uid_type" => array("uid","type"),
703                                         "uid_starred" => array("uid","starred"),
704                                         "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
705                                         "uid_wall_parent_created" => array("uid","wall","parent","created"),
706                                         "uid_type_changed" => array("uid","type","changed"),
707                                         "contactid_verb" => array("contact-id","verb"),
708                                         "deleted_changed" => array("deleted","changed"),
709                                         "uid_wall_changed" => array("uid","wall","changed"),
710                                         "uid_eventid" => array("uid","event-id"),
711                                         "uid_authorlink" => array("uid","author-link"),
712                                         "uid_ownerlink" => array("uid","owner-link"),
713                                         )
714                         );
715         $db["item_id"] = array(
716                         "fields" => array(
717                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
718                                         "iid" => array("type" => "int(11)", "not null" => "1"),
719                                         "uid" => array("type" => "int(11)", "not null" => "1"),
720                                         "sid" => array("type" => "char(255)", "not null" => "1"),
721                                         "service" => array("type" => "char(255)", "not null" => "1"),
722                                         ),
723                         "indexes" => array(
724                                         "PRIMARY" => array("id"),
725                                         "uid" => array("uid"),
726                                         "sid" => array("sid"),
727                                         "service" => array("service"),
728                                         "iid" => array("iid"),
729                                         )
730                         );
731         $db["locks"] = array(
732                         "fields" => array(
733                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
734                                         "name" => array("type" => "char(128)", "not null" => "1"),
735                                         "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
736                                         ),
737                         "indexes" => array(
738                                         "PRIMARY" => array("id"),
739                                         )
740                         );
741         $db["mail"] = array(
742                         "fields" => array(
743                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
744                                         "uid" => array("type" => "int(10) unsigned", "not null" => "1"),
745                                         "guid" => array("type" => "char(64)", "not null" => "1"),
746                                         "from-name" => array("type" => "char(255)", "not null" => "1"),
747                                         "from-photo" => array("type" => "char(255)", "not null" => "1"),
748                                         "from-url" => array("type" => "char(255)", "not null" => "1"),
749                                         "contact-id" => array("type" => "char(255)", "not null" => "1"),
750                                         "convid" => array("type" => "int(11) unsigned", "not null" => "1"),
751                                         "title" => array("type" => "char(255)", "not null" => "1"),
752                                         "body" => array("type" => "mediumtext", "not null" => "1"),
753                                         "seen" => array("type" => "tinyint(1)", "not null" => "1"),
754                                         "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
755                                         "replied" => array("type" => "tinyint(1)", "not null" => "1"),
756                                         "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
757                                         "uri" => array("type" => "char(255)", "not null" => "1"),
758                                         "parent-uri" => array("type" => "char(255)", "not null" => "1"),
759                                         "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
760                                         ),
761                         "indexes" => array(
762                                         "PRIMARY" => array("id"),
763                                         "uid" => array("uid"),
764                                         "guid" => array("guid"),
765                                         "convid" => array("convid"),
766                                         "reply" => array("reply"),
767                                         "uri" => array("uri"),
768                                         "parent-uri" => array("parent-uri"),
769                                         )
770                         );
771         $db["mailacct"] = array(
772                         "fields" => array(
773                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
774                                         "uid" => array("type" => "int(11)", "not null" => "1"),
775                                         "server" => array("type" => "char(255)", "not null" => "1"),
776                                         "port" => array("type" => "int(11)", "not null" => "1"),
777                                         "ssltype" => array("type" => "char(16)", "not null" => "1"),
778                                         "mailbox" => array("type" => "char(255)", "not null" => "1"),
779                                         "user" => array("type" => "char(255)", "not null" => "1"),
780                                         "pass" => array("type" => "text", "not null" => "1"),
781                                         "reply_to" => array("type" => "char(255)", "not null" => "1"),
782                                         "action" => array("type" => "int(11)", "not null" => "1"),
783                                         "movetofolder" => array("type" => "char(255)", "not null" => "1"),
784                                         "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
785                                         "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
786                                         ),
787                         "indexes" => array(
788                                         "PRIMARY" => array("id"),
789                                         )
790                         );
791         $db["manage"] = array(
792                         "fields" => array(
793                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
794                                         "uid" => array("type" => "int(11)", "not null" => "1"),
795                                         "mid" => array("type" => "int(11)", "not null" => "1"),
796                                         ),
797                         "indexes" => array(
798                                         "PRIMARY" => array("id"),
799                                         "uid_mid" => array("uid","mid"),
800                                         )
801                         );
802         $db["notify"] = array(
803                         "fields" => array(
804                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
805                                         "hash" => array("type" => "char(64)", "not null" => "1"),
806                                         "type" => array("type" => "int(11)", "not null" => "1"),
807                                         "name" => array("type" => "char(255)", "not null" => "1"),
808                                         "url" => array("type" => "char(255)", "not null" => "1"),
809                                         "photo" => array("type" => "char(255)", "not null" => "1"),
810                                         "date" => array("type" => "datetime", "not null" => "1"),
811                                         "msg" => array("type" => "mediumtext", "not null" => "1"),
812                                         "uid" => array("type" => "int(11)", "not null" => "1"),
813                                         "link" => array("type" => "char(255)", "not null" => "1"),
814                                         "parent" => array("type" => "int(11)", "not null" => "1"),
815                                         "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
816                                         "verb" => array("type" => "char(255)", "not null" => "1"),
817                                         "otype" => array("type" => "char(16)", "not null" => "1"),
818                                         ),
819                         "indexes" => array(
820                                         "PRIMARY" => array("id"),
821                                         "uid" => array("uid"),
822                                         )
823                         );
824         $db["notify-threads"] = array(
825                         "fields" => array(
826                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
827                                         "notify-id" => array("type" => "int(11)", "not null" => "1"),
828                                         "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
829                                         "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
830                                         "receiver-uid" => array("type" => "int(11)", "not null" => "1"),
831                                         ),
832                         "indexes" => array(
833                                         "PRIMARY" => array("id"),
834                                         "master-parent-item" => array("master-parent-item"),
835                                         "receiver-uid" => array("receiver-uid"),
836                                         )
837                         );
838         $db["pconfig"] = array(
839                         "fields" => array(
840                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
841                                         "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
842                                         "cat" => array("type" => "char(255)", "not null" => "1"),
843                                         "k" => array("type" => "char(255)", "not null" => "1"),
844                                         "v" => array("type" => "mediumtext", "not null" => "1"),
845                                         ),
846                         "indexes" => array(
847                                         "PRIMARY" => array("id"),
848                                         "access" => array("uid","cat","k"),
849                                         )
850                         );
851         $db["photo"] = array(
852                         "fields" => array(
853                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
854                                         "uid" => array("type" => "int(10) unsigned", "not null" => "1"),
855                                         "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
856                                         "guid" => array("type" => "char(64)", "not null" => "1"),
857                                         "resource-id" => array("type" => "char(255)", "not null" => "1"),
858                                         "created" => array("type" => "datetime", "not null" => "1"),
859                                         "edited" => array("type" => "datetime", "not null" => "1"),
860                                         "title" => array("type" => "char(255)", "not null" => "1"),
861                                         "desc" => array("type" => "text", "not null" => "1"),
862                                         "album" => array("type" => "char(255)", "not null" => "1"),
863                                         "filename" => array("type" => "char(255)", "not null" => "1"),
864                                         "type" => array("type" => "char(128)", "not null" => "1", "default" => "image/jpeg"),
865                                         "height" => array("type" => "smallint(6)", "not null" => "1"),
866                                         "width" => array("type" => "smallint(6)", "not null" => "1"),
867                                         "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
868                                         "data" => array("type" => "mediumblob", "not null" => "1"),
869                                         "scale" => array("type" => "tinyint(3)", "not null" => "1"),
870                                         "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
871                                         "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
872                                         "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
873                                         "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
874                                         "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
875                                         ),
876                         "indexes" => array(
877                                         "PRIMARY" => array("id"),
878                                         "uid" => array("uid"),
879                                         "resource-id" => array("resource-id"),
880                                         "guid" => array("guid"),
881                                         )
882                         );
883         $db["poll"] = array(
884                         "fields" => array(
885                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
886                                         "uid" => array("type" => "int(11)", "not null" => "1"),
887                                         "q0" => array("type" => "mediumtext", "not null" => "1"),
888                                         "q1" => array("type" => "mediumtext", "not null" => "1"),
889                                         "q2" => array("type" => "mediumtext", "not null" => "1"),
890                                         "q3" => array("type" => "mediumtext", "not null" => "1"),
891                                         "q4" => array("type" => "mediumtext", "not null" => "1"),
892                                         "q5" => array("type" => "mediumtext", "not null" => "1"),
893                                         "q6" => array("type" => "mediumtext", "not null" => "1"),
894                                         "q7" => array("type" => "mediumtext", "not null" => "1"),
895                                         "q8" => array("type" => "mediumtext", "not null" => "1"),
896                                         "q9" => array("type" => "mediumtext", "not null" => "1"),
897                                         ),
898                         "indexes" => array(
899                                         "PRIMARY" => array("id"),
900                                         "uid" => array("uid"),
901                                         )
902                         );
903         $db["poll_result"] = array(
904                         "fields" => array(
905                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
906                                         "poll_id" => array("type" => "int(11)", "not null" => "1"),
907                                         "choice" => array("type" => "int(11)", "not null" => "1"),
908                                         ),
909                         "indexes" => array(
910                                         "PRIMARY" => array("id"),
911                                         "poll_id" => array("poll_id"),
912                                         "choice" => array("choice"),
913                                         )
914                         );
915         $db["profile"] = array(
916                         "fields" => array(
917                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
918                                         "uid" => array("type" => "int(11)", "not null" => "1"),
919                                         "profile-name" => array("type" => "char(255)", "not null" => "1"),
920                                         "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
921                                         "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
922                                         "name" => array("type" => "char(255)", "not null" => "1"),
923                                         "pdesc" => array("type" => "char(255)", "not null" => "1"),
924                                         "dob" => array("type" => "char(32)", "not null" => "1", "default" => "0000-00-00"),
925                                         "address" => array("type" => "char(255)", "not null" => "1"),
926                                         "locality" => array("type" => "char(255)", "not null" => "1"),
927                                         "region" => array("type" => "char(255)", "not null" => "1"),
928                                         "postal-code" => array("type" => "char(32)", "not null" => "1"),
929                                         "country-name" => array("type" => "char(255)", "not null" => "1"),
930                                         "hometown" => array("type" => "char(255)", "not null" => "1"),
931                                         "gender" => array("type" => "char(32)", "not null" => "1"),
932                                         "marital" => array("type" => "char(255)", "not null" => "1"),
933                                         "with" => array("type" => "text", "not null" => "1"),
934                                         "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
935                                         "sexual" => array("type" => "char(255)", "not null" => "1"),
936                                         "politic" => array("type" => "char(255)", "not null" => "1"),
937                                         "religion" => array("type" => "char(255)", "not null" => "1"),
938                                         "pub_keywords" => array("type" => "text", "not null" => "1"),
939                                         "prv_keywords" => array("type" => "text", "not null" => "1"),
940                                         "likes" => array("type" => "text", "not null" => "1"),
941                                         "dislikes" => array("type" => "text", "not null" => "1"),
942                                         "about" => array("type" => "text", "not null" => "1"),
943                                         "summary" => array("type" => "char(255)", "not null" => "1"),
944                                         "music" => array("type" => "text", "not null" => "1"),
945                                         "book" => array("type" => "text", "not null" => "1"),
946                                         "tv" => array("type" => "text", "not null" => "1"),
947                                         "film" => array("type" => "text", "not null" => "1"),
948                                         "interest" => array("type" => "text", "not null" => "1"),
949                                         "romance" => array("type" => "text", "not null" => "1"),
950                                         "work" => array("type" => "text", "not null" => "1"),
951                                         "education" => array("type" => "text", "not null" => "1"),
952                                         "contact" => array("type" => "text", "not null" => "1"),
953                                         "homepage" => array("type" => "char(255)", "not null" => "1"),
954                                         "photo" => array("type" => "char(255)", "not null" => "1"),
955                                         "thumb" => array("type" => "char(255)", "not null" => "1"),
956                                         "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
957                                         "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
958                                         ),
959                         "indexes" => array(
960                                         "PRIMARY" => array("id"),
961                                         "hometown" => array("hometown"),
962                                         )
963                         );
964         $db["profile_check"] = array(
965                         "fields" => array(
966                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
967                                         "uid" => array("type" => "int(10) unsigned", "not null" => "1"),
968                                         "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
969                                         "dfrn_id" => array("type" => "char(255)", "not null" => "1"),
970                                         "sec" => array("type" => "char(255)", "not null" => "1"),
971                                         "expire" => array("type" => "int(11)", "not null" => "1"),
972                                         ),
973                         "indexes" => array(
974                                         "PRIMARY" => array("id"),
975                                         )
976                         );
977         $db["push_subscriber"] = array(
978                         "fields" => array(
979                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
980                                         "uid" => array("type" => "int(11)", "not null" => "1"),
981                                         "callback_url" => array("type" => "char(255)", "not null" => "1"),
982                                         "topic" => array("type" => "char(255)", "not null" => "1"),
983                                         "nickname" => array("type" => "char(255)", "not null" => "1"),
984                                         "push" => array("type" => "int(11)", "not null" => "1"),
985                                         "last_update" => array("type" => "datetime", "not null" => "1"),
986                                         "secret" => array("type" => "char(255)", "not null" => "1"),
987                                         ),
988                         "indexes" => array(
989                                         "PRIMARY" => array("id"),
990                                         )
991                         );
992         $db["queue"] = array(
993                         "fields" => array(
994                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
995                                         "cid" => array("type" => "int(11)", "not null" => "1"),
996                                         "network" => array("type" => "char(32)", "not null" => "1"),
997                                         "created" => array("type" => "datetime", "not null" => "1"),
998                                         "last" => array("type" => "datetime", "not null" => "1"),
999                                         "content" => array("type" => "mediumtext", "not null" => "1"),
1000                                         "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1001                                         ),
1002                         "indexes" => array(
1003                                         "PRIMARY" => array("id"),
1004                                         "cid" => array("cid"),
1005                                         "created" => array("created"),
1006                                         "last" => array("last"),
1007                                         "network" => array("network"),
1008                                         "batch" => array("batch"),
1009                                         )
1010                         );
1011         $db["register"] = array(
1012                         "fields" => array(
1013                                         "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1014                                         "hash" => array("type" => "char(255)", "not null" => "1"),
1015                                         "created" => array("type" => "datetime", "not null" => "1"),
1016                                         "uid" => array("type" => "int(11) unsigned", "not null" => "1"),
1017                                         "password" => array("type" => "char(255)", "not null" => "1"),
1018                                         "language" => array("type" => "char(16)", "not null" => "1"),
1019                                         ),
1020                         "indexes" => array(
1021                                         "PRIMARY" => array("id"),
1022                                         )
1023                         );
1024         $db["search"] = array(
1025                         "fields" => array(
1026                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1027                                         "uid" => array("type" => "int(11)", "not null" => "1"),
1028                                         "term" => array("type" => "char(255)", "not null" => "1"),
1029                                         ),
1030                         "indexes" => array(
1031                                         "PRIMARY" => array("id"),
1032                                         "uid" => array("uid"),
1033                                         "term" => array("term"),
1034                                         )
1035                         );
1036         $db["session"] = array(
1037                         "fields" => array(
1038                                         "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1039                                         "sid" => array("type" => "char(255)", "not null" => "1"),
1040                                         "data" => array("type" => "text", "not null" => "1"),
1041                                         "expire" => array("type" => "int(10) unsigned", "not null" => "1"),
1042                                         ),
1043                         "indexes" => array(
1044                                         "PRIMARY" => array("id"),
1045                                         "sid" => array("sid"),
1046                                         "expire" => array("expire"),
1047                                         )
1048                         );
1049         $db["sign"] = array(
1050                         "fields" => array(
1051                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1052                                         "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1053                                         "retract_iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1054                                         "signed_text" => array("type" => "mediumtext", "not null" => "1"),
1055                                         "signature" => array("type" => "text", "not null" => "1"),
1056                                         "signer" => array("type" => "char(255)", "not null" => "1"),
1057                                         ),
1058                         "indexes" => array(
1059                                         "PRIMARY" => array("id"),
1060                                         "iid" => array("iid"),
1061                                         "retract_iid" => array("retract_iid"),
1062                                         )
1063                         );
1064         $db["spam"] = array(
1065                         "fields" => array(
1066                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1067                                         "uid" => array("type" => "int(11)", "not null" => "1"),
1068                                         "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1069                                         "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1070                                         "term" => array("type" => "char(255)", "not null" => "1"),
1071                                         "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1072                                         ),
1073                         "indexes" => array(
1074                                         "PRIMARY" => array("id"),
1075                                         "uid" => array("uid"),
1076                                         "spam" => array("spam"),
1077                                         "ham" => array("ham"),
1078                                         "term" => array("term"),
1079                                         )
1080                         );
1081         $db["term"] = array(
1082                         "fields" => array(
1083                                         "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1084                                         "oid" => array("type" => "int(10) unsigned", "not null" => "1"),
1085                                         "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1"),
1086                                         "type" => array("type" => "tinyint(3) unsigned", "not null" => "1"),
1087                                         "term" => array("type" => "char(255)", "not null" => "1"),
1088                                         "url" => array("type" => "char(255)", "not null" => "1"),
1089                                         "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1090                                         "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1091                                         ),
1092                         "indexes" => array(
1093                                         "PRIMARY" => array("tid"),
1094                                         "oid_otype_type_term" => array("oid","otype","type","term"),
1095                                         "uid_term_tid" => array("uid","term","tid"),
1096                                         "type_term" => array("type","term"),
1097                                         "uid_otype_type_term_tid" => array("uid","otype","type","term","tid"),
1098                                         "otype_type_term_tid" => array("otype","type","term","tid"),
1099                                         )
1100                         );
1101         $db["thread"] = array(
1102                         "fields" => array(
1103                                         "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1104                                         "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1105                                         "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1106                                         "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1107                                         "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1108                                         "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1109                                         "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1110                                         "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1111                                         "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1112                                         "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1113                                         "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1114                                         "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1115                                         "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1116                                         "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1117                                         "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1118                                         "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1119                                         "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1120                                         "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1121                                         "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1122                                         "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1123                                         "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1124                                         "network" => array("type" => "char(32)", "not null" => "1"),
1125                                         ),
1126                         "indexes" => array(
1127                                         "PRIMARY" => array("iid"),
1128                                         "created" => array("created"),
1129                                         "commented" => array("commented"),
1130                                         "uid_network_commented" => array("uid","network","commented"),
1131                                         "uid_network_created" => array("uid","network","created"),
1132                                         "uid_contactid_commented" => array("uid","contact-id","commented"),
1133                                         "uid_contactid_created" => array("uid","contact-id","created"),
1134                                         "wall_private_received" => array("wall","private","received"),
1135                                         "uid_created" => array("uid","created"),
1136                                         "uid_commented" => array("uid","commented"),
1137                                         )
1138                         );
1139         $db["tokens"] = array(
1140                         "fields" => array(
1141                                         "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1142                                         "secret" => array("type" => "text", "not null" => "1"),
1143                                         "client_id" => array("type" => "varchar(20)", "not null" => "1"),
1144                                         "expires" => array("type" => "int(11)", "not null" => "1"),
1145                                         "scope" => array("type" => "varchar(200)", "not null" => "1"),
1146                                         "uid" => array("type" => "int(11)", "not null" => "1"),
1147                                         ),
1148                         "indexes" => array(
1149                                         "PRIMARY" => array("id"),
1150                                         )
1151                         );
1152         $db["unique_contacts"] = array(
1153                         "fields" => array(
1154                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1155                                         "url" => array("type" => "char(255)", "not null" => "1"),
1156                                         "nick" => array("type" => "char(255)", "not null" => "1"),
1157                                         "name" => array("type" => "char(255)", "not null" => "1"),
1158                                         "avatar" => array("type" => "char(255)", "not null" => "1"),
1159                                         ),
1160                         "indexes" => array(
1161                                         "PRIMARY" => array("id"),
1162                                         "url" => array("url"),
1163                                         )
1164                         );
1165         $db["user"] = array(
1166                         "fields" => array(
1167                                         "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1168                                         "guid" => array("type" => "char(64)", "not null" => "1"),
1169                                         "username" => array("type" => "char(255)", "not null" => "1"),
1170                                         "password" => array("type" => "char(255)", "not null" => "1"),
1171                                         "nickname" => array("type" => "char(255)", "not null" => "1"),
1172                                         "email" => array("type" => "char(255)", "not null" => "1"),
1173                                         "openid" => array("type" => "char(255)", "not null" => "1"),
1174                                         "timezone" => array("type" => "char(128)", "not null" => "1"),
1175                                         "language" => array("type" => "char(32)", "not null" => "1", "default" => "en"),
1176                                         "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1177                                         "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1178                                         "default-location" => array("type" => "char(255)", "not null" => "1"),
1179                                         "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1180                                         "theme" => array("type" => "char(255)", "not null" => "1"),
1181                                         "pubkey" => array("type" => "text", "not null" => "1"),
1182                                         "prvkey" => array("type" => "text", "not null" => "1"),
1183                                         "spubkey" => array("type" => "text", "not null" => "1"),
1184                                         "sprvkey" => array("type" => "text", "not null" => "1"),
1185                                         "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1186                                         "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1187                                         "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1188                                         "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1189                                         "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1190                                         "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1191                                         "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1192                                         "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1193                                         "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1194                                         "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1195                                         "pwdreset" => array("type" => "char(255)", "not null" => "1"),
1196                                         "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1197                                         "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1198                                         "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1199                                         "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1200                                         "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1201                                         "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1202                                         "service_class" => array("type" => "char(32)", "not null" => "1"),
1203                                         "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1204                                         "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
1205                                         "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
1206                                         "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
1207                                         "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1208                                         "openidserver" => array("type" => "text", "not null" => "1"),
1209                                         ),
1210                         "indexes" => array(
1211                                         "PRIMARY" => array("uid"),
1212                                         "nickname" => array("nickname"),
1213                                         )
1214                         );
1215         $db["userd"] = array(
1216                         "fields" => array(
1217                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1218                                         "username" => array("type" => "char(255)", "not null" => "1"),
1219                                         ),
1220                         "indexes" => array(
1221                                         "PRIMARY" => array("id"),
1222                                         "username" => array("username"),
1223                                         )
1224                         );
1225
1226         return($db);
1227 }