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