]> git.mxchange.org Git - friendica.git/blob - include/dbstructure.php
The index for the term search is now massively improved.
[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                                         "keywords" => array("type" => "text", "not null" => "1"),
419                                         "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
420                                         "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
421                                         "photo" => array("type" => "text", "not null" => "1"),
422                                         "thumb" => array("type" => "text", "not null" => "1"),
423                                         "micro" => array("type" => "text", "not null" => "1"),
424                                         "site-pubkey" => array("type" => "text", "not null" => "1"),
425                                         "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
426                                         "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
427                                         "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
428                                         "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
429                                         "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
430                                         "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
431                                         "pubkey" => array("type" => "text", "not null" => "1"),
432                                         "prvkey" => array("type" => "text", "not null" => "1"),
433                                         "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
434                                         "request" => array("type" => "text", "not null" => "1"),
435                                         "notify" => array("type" => "text", "not null" => "1"),
436                                         "poll" => array("type" => "text", "not null" => "1"),
437                                         "confirm" => array("type" => "text", "not null" => "1"),
438                                         "poco" => array("type" => "text", "not null" => "1"),
439                                         "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
440                                         "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
441                                         "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
442                                         "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
443                                         "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
444                                         "last-update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
445                                         "success_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
446                                         "name-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
447                                         "uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
448                                         "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
449                                         "term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
450                                         "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
451                                         "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
452                                         "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
453                                         "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
454                                         "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
455                                         "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
456                                         "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
457                                         "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
458                                         "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
459                                         "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
460                                         "reason" => array("type" => "text", "not null" => "1"),
461                                         "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
462                                         "info" => array("type" => "mediumtext", "not null" => "1"),
463                                         "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
464                                         "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
465                                         "bd" => array("type" => "date", "not null" => "1", "default" => "0000-00-00"),
466                                         "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
467                                         "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
468                                         "ffi_keyword_blacklist" => array("type" => "mediumtext", "not null" => "1"),
469                                         ),
470                         "indexes" => array(
471                                         "PRIMARY" => array("id"),
472                                         "uid" => array("uid"),
473                                         )
474                         );
475         $database["conv"] = array(
476                         "fields" => array(
477                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
478                                         "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
479                                         "recips" => array("type" => "mediumtext", "not null" => "1"),
480                                         "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
481                                         "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
482                                         "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
483                                         "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
484                                         "subject" => array("type" => "mediumtext", "not null" => "1"),
485                                         ),
486                         "indexes" => array(
487                                         "PRIMARY" => array("id"),
488                                         "uid" => array("uid"),
489                                         )
490                         );
491         $database["deliverq"] = array(
492                         "fields" => array(
493                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
494                                         "cmd" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
495                                         "item" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
496                                         "contact" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
497                                         ),
498                         "indexes" => array(
499                                         "PRIMARY" => array("id"),
500                                         )
501                         );
502         $database["dsprphotoq"] = array(
503                         "fields" => array(
504                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
505                                         "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
506                                         "msg" => array("type" => "mediumtext", "not null" => "1"),
507                                         "attempt" => array("type" => "tinyint(4)", "not null" => "1", "default" => "0"),
508                                         ),
509                         "indexes" => array(
510                                         "PRIMARY" => array("id"),
511                                         )
512                         );
513         $database["event"] = array(
514                         "fields" => array(
515                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
516                                         "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
517                                         "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
518                                         "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
519                                         "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
520                                         "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
521                                         "start" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
522                                         "finish" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
523                                         "summary" => array("type" => "text", "not null" => "1"),
524                                         "desc" => array("type" => "text", "not null" => "1"),
525                                         "location" => array("type" => "text", "not null" => "1"),
526                                         "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
527                                         "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
528                                         "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
529                                         "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
530                                         "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
531                                         "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
532                                         "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
533                                         "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
534                                         ),
535                         "indexes" => array(
536                                         "PRIMARY" => array("id"),
537                                         "uid" => array("uid"),
538                                         )
539                         );
540         $database["fcontact"] = array(
541                         "fields" => array(
542                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
543                                         "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
544                                         "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
545                                         "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
546                                         "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
547                                         "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
548                                         "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
549                                         "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
550                                         "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
551                                         "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
552                                         "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
553                                         "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
554                                         "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
555                                         "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
556                                         "pubkey" => array("type" => "text", "not null" => "1"),
557                                         "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
558                                         ),
559                         "indexes" => array(
560                                         "PRIMARY" => array("id"),
561                                         "addr" => array("addr"),
562                                         )
563                         );
564         $database["ffinder"] = array(
565                         "fields" => array(
566                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
567                                         "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
568                                         "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
569                                         "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
570                                         ),
571                         "indexes" => array(
572                                         "PRIMARY" => array("id"),
573                                         )
574                         );
575         $database["fserver"] = array(
576                         "fields" => array(
577                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
578                                         "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
579                                         "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
580                                         "key" => array("type" => "text", "not null" => "1"),
581                                         ),
582                         "indexes" => array(
583                                         "PRIMARY" => array("id"),
584                                         "server" => array("server"),
585                                         )
586                         );
587         $database["fsuggest"] = array(
588                         "fields" => array(
589                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
590                                         "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
591                                         "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
592                                         "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
593                                         "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
594                                         "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
595                                         "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
596                                         "note" => array("type" => "text", "not null" => "1"),
597                                         "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
598                                         ),
599                         "indexes" => array(
600                                         "PRIMARY" => array("id"),
601                                         )
602                         );
603         $database["gcign"] = array(
604                         "fields" => array(
605                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
606                                         "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
607                                         "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
608                                         ),
609                         "indexes" => array(
610                                         "PRIMARY" => array("id"),
611                                         "uid" => array("uid"),
612                                         "gcid" => array("gcid"),
613                                         )
614                         );
615         $database["gcontact"] = array(
616                         "fields" => array(
617                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
618                                         "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
619                                         "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
620                                         "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
621                                         "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
622                                         "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
623                                         "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
624                                         "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
625                                         "about" => array("type" => "text", "not null" => "1"),
626                                         "keywords" => array("type" => "text", "not null" => "1"),
627                                         "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
628                                         "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
629                                         "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
630                                         ),
631                         "indexes" => array(
632                                         "PRIMARY" => array("id"),
633                                         "nurl" => array("nurl"),
634                                         )
635                         );
636         $database["glink"] = array(
637                         "fields" => array(
638                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
639                                         "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
640                                         "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
641                                         "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
642                                         "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
643                                         "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
644                                         ),
645                         "indexes" => array(
646                                         "PRIMARY" => array("id"),
647                                         "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
648                                         "gcid" => array("gcid"),
649                                         "zcid" => array("zcid"),
650                                         )
651                         );
652         $database["group"] = array(
653                         "fields" => array(
654                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
655                                         "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
656                                         "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
657                                         "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
658                                         "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
659                                         ),
660                         "indexes" => array(
661                                         "PRIMARY" => array("id"),
662                                         "uid" => array("uid"),
663                                         )
664                         );
665         $database["group_member"] = array(
666                         "fields" => array(
667                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
668                                         "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
669                                         "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
670                                         "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
671                                         ),
672                         "indexes" => array(
673                                         "PRIMARY" => array("id"),
674                                         "uid_gid_contactid" => array("uid","gid","contact-id"),
675                                         )
676                         );
677         $database["guid"] = array(
678                         "fields" => array(
679                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
680                                         "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
681                                         ),
682                         "indexes" => array(
683                                         "PRIMARY" => array("id"),
684                                         "guid" => array("guid"),
685                                         )
686                         );
687         $database["hook"] = array(
688                         "fields" => array(
689                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
690                                         "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
691                                         "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
692                                         "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
693                                         "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
694                                         ),
695                         "indexes" => array(
696                                         "PRIMARY" => array("id"),
697                                         "hook_file_function" => array("hook(30)","file(60)","function(30)"),
698                                         )
699                         );
700         $database["intro"] = array(
701                         "fields" => array(
702                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
703                                         "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
704                                         "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
705                                         "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
706                                         "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
707                                         "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
708                                         "note" => array("type" => "text", "not null" => "1"),
709                                         "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
710                                         "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
711                                         "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
712                                         "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
713                                         ),
714                         "indexes" => array(
715                                         "PRIMARY" => array("id"),
716                                         )
717                         );
718         $database["item"] = array(
719                         "fields" => array(
720                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
721                                         "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
722                                         "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
723                                         "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
724                                         "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
725                                         "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
726                                         "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
727                                         "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
728                                         "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
729                                         "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
730                                         "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
731                                         "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
732                                         "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
733                                         "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
734                                         "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
735                                         "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
736                                         "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
737                                         "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
738                                         "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
739                                         "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
740                                         "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
741                                         "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
742                                         "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
743                                         "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
744                                         "body" => array("type" => "mediumtext", "not null" => "1"),
745                                         "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
746                                         "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
747                                         "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
748                                         "object" => array("type" => "text", "not null" => "1"),
749                                         "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
750                                         "target" => array("type" => "text", "not null" => "1"),
751                                         "postopts" => array("type" => "text", "not null" => "1"),
752                                         "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
753                                         "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
754                                         "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
755                                         "tag" => array("type" => "mediumtext", "not null" => "1"),
756                                         "attach" => array("type" => "mediumtext", "not null" => "1"),
757                                         "inform" => array("type" => "mediumtext", "not null" => "1"),
758                                         "file" => array("type" => "mediumtext", "not null" => "1"),
759                                         "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
760                                         "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
761                                         "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
762                                         "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
763                                         "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
764                                         "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
765                                         "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
766                                         "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
767                                         "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
768                                         "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
769                                         "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
770                                         "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
771                                         "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
772                                         "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
773                                         "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
774                                         "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
775                                         "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
776                                         "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
777                                         "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
778                                         "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
779                                         "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
780                                         "rendered-html" => array("type" => "mediumtext", "not null" => "1"),
781                                         "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
782                                         ),
783                         "indexes" => array(
784                                         "PRIMARY" => array("id"),
785                                         "guid" => array("guid"),
786                                         "uri" => array("uri"),
787                                         "parent" => array("parent"),
788                                         "parent-uri" => array("parent-uri"),
789                                         "extid" => array("extid"),
790                                         "uid_id" => array("uid","id"),
791                                         "uid_created" => array("uid","created"),
792                                         "uid_unseen" => array("uid","unseen"),
793                                         "uid_network_received" => array("uid","network","received"),
794                                         "uid_received" => array("uid","received"),
795                                         "uid_network_commented" => array("uid","network","commented"),
796                                         "uid_commented" => array("uid","commented"),
797                                         "uid_title" => array("uid","title"),
798                                         "uid_thrparent" => array("uid","thr-parent"),
799                                         "uid_parenturi" => array("uid","parent-uri"),
800                                         "uid_contactid_created" => array("uid","contact-id","created"),
801                                         "wall_body" => array("wall","body(6)"),
802                                         "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
803                                         "uid_uri" => array("uid","uri"),
804                                         "uid_wall_created" => array("uid","wall","created"),
805                                         "resource-id" => array("resource-id"),
806                                         "uid_type" => array("uid","type"),
807                                         "uid_starred" => array("uid","starred"),
808                                         "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
809                                         "uid_wall_parent_created" => array("uid","wall","parent","created"),
810                                         "uid_type_changed" => array("uid","type","changed"),
811                                         "contactid_verb" => array("contact-id","verb"),
812                                         "deleted_changed" => array("deleted","changed"),
813                                         "uid_wall_changed" => array("uid","wall","changed"),
814                                         "uid_eventid" => array("uid","event-id"),
815                                         "uid_authorlink" => array("uid","author-link"),
816                                         "uid_ownerlink" => array("uid","owner-link"),
817                                         )
818                         );
819         $database["item_id"] = array(
820                         "fields" => array(
821                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
822                                         "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
823                                         "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
824                                         "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
825                                         "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
826                                         ),
827                         "indexes" => array(
828                                         "PRIMARY" => array("id"),
829                                         "uid" => array("uid"),
830                                         "sid" => array("sid"),
831                                         "service" => array("service"),
832                                         "iid" => array("iid"),
833                                         )
834                         );
835         $database["locks"] = array(
836                         "fields" => array(
837                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
838                                         "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
839                                         "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
840                                         "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
841                                         ),
842                         "indexes" => array(
843                                         "PRIMARY" => array("id"),
844                                         )
845                         );
846         $database["mail"] = array(
847                         "fields" => array(
848                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
849                                         "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
850                                         "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
851                                         "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
852                                         "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
853                                         "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
854                                         "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
855                                         "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
856                                         "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
857                                         "body" => array("type" => "mediumtext", "not null" => "1"),
858                                         "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
859                                         "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
860                                         "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
861                                         "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
862                                         "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
863                                         "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
864                                         "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
865                                         ),
866                         "indexes" => array(
867                                         "PRIMARY" => array("id"),
868                                         "uid" => array("uid"),
869                                         "guid" => array("guid"),
870                                         "convid" => array("convid"),
871                                         "reply" => array("reply"),
872                                         "uri" => array("uri"),
873                                         "parent-uri" => array("parent-uri"),
874                                         )
875                         );
876         $database["mailacct"] = array(
877                         "fields" => array(
878                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
879                                         "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
880                                         "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
881                                         "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
882                                         "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
883                                         "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
884                                         "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
885                                         "pass" => array("type" => "text", "not null" => "1"),
886                                         "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
887                                         "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
888                                         "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
889                                         "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
890                                         "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
891                                         ),
892                         "indexes" => array(
893                                         "PRIMARY" => array("id"),
894                                         )
895                         );
896         $database["manage"] = array(
897                         "fields" => array(
898                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
899                                         "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
900                                         "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
901                                         ),
902                         "indexes" => array(
903                                         "PRIMARY" => array("id"),
904                                         "uid_mid" => array("uid","mid"),
905                                         )
906                         );
907         $database["notify"] = array(
908                         "fields" => array(
909                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
910                                         "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
911                                         "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
912                                         "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
913                                         "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
914                                         "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
915                                         "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
916                                         "msg" => array("type" => "mediumtext", "not null" => "1"),
917                                         "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
918                                         "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
919                                         "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
920                                         "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
921                                         "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
922                                         "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
923                                         ),
924                         "indexes" => array(
925                                         "PRIMARY" => array("id"),
926                                         "uid" => array("uid"),
927                                         )
928                         );
929         $database["notify-threads"] = array(
930                         "fields" => array(
931                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
932                                         "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
933                                         "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
934                                         "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
935                                         "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
936                                         ),
937                         "indexes" => array(
938                                         "PRIMARY" => array("id"),
939                                         "master-parent-item" => array("master-parent-item"),
940                                         "receiver-uid" => array("receiver-uid"),
941                                         )
942                         );
943         $database["pconfig"] = array(
944                         "fields" => array(
945                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
946                                         "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
947                                         "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
948                                         "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
949                                         "v" => array("type" => "mediumtext", "not null" => "1"),
950                                         ),
951                         "indexes" => array(
952                                         "PRIMARY" => array("id"),
953                                         "uid_cat_k" => array("uid","cat(30)","k(30)"),
954                                         )
955                         );
956         $database["photo"] = array(
957                         "fields" => array(
958                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
959                                         "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
960                                         "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
961                                         "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
962                                         "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
963                                         "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
964                                         "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
965                                         "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
966                                         "desc" => array("type" => "text", "not null" => "1"),
967                                         "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
968                                         "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
969                                         "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
970                                         "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
971                                         "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
972                                         "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
973                                         "data" => array("type" => "mediumblob", "not null" => "1"),
974                                         "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
975                                         "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
976                                         "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
977                                         "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
978                                         "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
979                                         "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
980                                         ),
981                         "indexes" => array(
982                                         "PRIMARY" => array("id"),
983                                         "uid" => array("uid"),
984                                         "resource-id" => array("resource-id"),
985                                         "guid" => array("guid"),
986                                         )
987                         );
988         $database["poll"] = array(
989                         "fields" => array(
990                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
991                                         "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
992                                         "q0" => array("type" => "mediumtext", "not null" => "1"),
993                                         "q1" => array("type" => "mediumtext", "not null" => "1"),
994                                         "q2" => array("type" => "mediumtext", "not null" => "1"),
995                                         "q3" => array("type" => "mediumtext", "not null" => "1"),
996                                         "q4" => array("type" => "mediumtext", "not null" => "1"),
997                                         "q5" => array("type" => "mediumtext", "not null" => "1"),
998                                         "q6" => array("type" => "mediumtext", "not null" => "1"),
999                                         "q7" => array("type" => "mediumtext", "not null" => "1"),
1000                                         "q8" => array("type" => "mediumtext", "not null" => "1"),
1001                                         "q9" => array("type" => "mediumtext", "not null" => "1"),
1002                                         ),
1003                         "indexes" => array(
1004                                         "PRIMARY" => array("id"),
1005                                         "uid" => array("uid"),
1006                                         )
1007                         );
1008         $database["poll_result"] = array(
1009                         "fields" => array(
1010                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1011                                         "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1012                                         "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1013                                         ),
1014                         "indexes" => array(
1015                                         "PRIMARY" => array("id"),
1016                                         "poll_id" => array("poll_id"),
1017                                         "choice" => array("choice"),
1018                                         )
1019                         );
1020         $database["profile"] = array(
1021                         "fields" => array(
1022                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1023                                         "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1024                                         "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1025                                         "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1026                                         "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1027                                         "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1028                                         "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1029                                         "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1030                                         "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1031                                         "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1032                                         "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1033                                         "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1034                                         "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1035                                         "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1036                                         "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1037                                         "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1038                                         "with" => array("type" => "text", "not null" => "1"),
1039                                         "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1040                                         "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1041                                         "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1042                                         "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1043                                         "pub_keywords" => array("type" => "text", "not null" => "1"),
1044                                         "prv_keywords" => array("type" => "text", "not null" => "1"),
1045                                         "likes" => array("type" => "text", "not null" => "1"),
1046                                         "dislikes" => array("type" => "text", "not null" => "1"),
1047                                         "about" => array("type" => "text", "not null" => "1"),
1048                                         "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1049                                         "music" => array("type" => "text", "not null" => "1"),
1050                                         "book" => array("type" => "text", "not null" => "1"),
1051                                         "tv" => array("type" => "text", "not null" => "1"),
1052                                         "film" => array("type" => "text", "not null" => "1"),
1053                                         "interest" => array("type" => "text", "not null" => "1"),
1054                                         "romance" => array("type" => "text", "not null" => "1"),
1055                                         "work" => array("type" => "text", "not null" => "1"),
1056                                         "education" => array("type" => "text", "not null" => "1"),
1057                                         "contact" => array("type" => "text", "not null" => "1"),
1058                                         "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1059                                         "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1060                                         "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1061                                         "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1062                                         "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1063                                         ),
1064                         "indexes" => array(
1065                                         "PRIMARY" => array("id"),
1066                                         "hometown" => array("hometown"),
1067                                         )
1068                         );
1069         $database["profile_check"] = array(
1070                         "fields" => array(
1071                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1072                                         "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1073                                         "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1074                                         "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1075                                         "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1076                                         "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1077                                         ),
1078                         "indexes" => array(
1079                                         "PRIMARY" => array("id"),
1080                                         )
1081                         );
1082         $database["push_subscriber"] = array(
1083                         "fields" => array(
1084                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1085                                         "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1086                                         "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1087                                         "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1088                                         "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1089                                         "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1090                                         "last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1091                                         "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1092                                         ),
1093                         "indexes" => array(
1094                                         "PRIMARY" => array("id"),
1095                                         )
1096                         );
1097         $database["queue"] = array(
1098                         "fields" => array(
1099                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1100                                         "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1101                                         "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1102                                         "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1103                                         "last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1104                                         "content" => array("type" => "mediumtext", "not null" => "1"),
1105                                         "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1106                                         ),
1107                         "indexes" => array(
1108                                         "PRIMARY" => array("id"),
1109                                         "cid" => array("cid"),
1110                                         "created" => array("created"),
1111                                         "last" => array("last"),
1112                                         "network" => array("network"),
1113                                         "batch" => array("batch"),
1114                                         )
1115                         );
1116         $database["register"] = array(
1117                         "fields" => array(
1118                                         "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1119                                         "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1120                                         "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1121                                         "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1122                                         "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1123                                         "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1124                                         ),
1125                         "indexes" => array(
1126                                         "PRIMARY" => array("id"),
1127                                         )
1128                         );
1129         $database["search"] = array(
1130                         "fields" => array(
1131                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1132                                         "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1133                                         "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1134                                         ),
1135                         "indexes" => array(
1136                                         "PRIMARY" => array("id"),
1137                                         "uid" => array("uid"),
1138                                         "term" => array("term"),
1139                                         )
1140                         );
1141         $database["session"] = array(
1142                         "fields" => array(
1143                                         "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1144                                         "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1145                                         "data" => array("type" => "text", "not null" => "1"),
1146                                         "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1147                                         ),
1148                         "indexes" => array(
1149                                         "PRIMARY" => array("id"),
1150                                         "sid" => array("sid"),
1151                                         "expire" => array("expire"),
1152                                         )
1153                         );
1154         $database["sign"] = array(
1155                         "fields" => array(
1156                                         "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1157                                         "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1158                                         "retract_iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1159                                         "signed_text" => array("type" => "mediumtext", "not null" => "1"),
1160                                         "signature" => array("type" => "text", "not null" => "1"),
1161                                         "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1162                                         ),
1163                         "indexes" => array(
1164                                         "PRIMARY" => array("id"),
1165                                         "iid" => array("iid"),
1166                                         "retract_iid" => array("retract_iid"),
1167                                         )
1168                         );
1169         $database["spam"] = array(
1170                         "fields" => array(
1171                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1172                                         "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1173                                         "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1174                                         "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1175                                         "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1176                                         "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1177                                         ),
1178                         "indexes" => array(
1179                                         "PRIMARY" => array("id"),
1180                                         "uid" => array("uid"),
1181                                         "spam" => array("spam"),
1182                                         "ham" => array("ham"),
1183                                         "term" => array("term"),
1184                                         )
1185                         );
1186         $database["term"] = array(
1187                         "fields" => array(
1188                                         "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1189                                         "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1190                                         "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1191                                         "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1192                                         "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1193                                         "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1194                                         "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1195                                         "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1196                                         "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1197                                         "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1198                                         "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1199                                         "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1200                                         ),
1201                         "indexes" => array(
1202                                         "PRIMARY" => array("tid"),
1203                                         "oid_otype_type_term" => array("oid","otype","type","term"),
1204                                         "uid_term_tid" => array("uid","term","tid"),
1205                                         "type_term" => array("type","term"),
1206                                         "uid_otype_type_term_global_created" => array("uid","otype","type","term","global","created"),
1207                                         "otype_type_term_tid" => array("otype","type","term","tid"),
1208                                         "guid" => array("guid"),
1209                                         )
1210                         );
1211         $database["thread"] = array(
1212                         "fields" => array(
1213                                         "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1214                                         "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1215                                         "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1216                                         "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1217                                         "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1218                                         "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1219                                         "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1220                                         "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1221                                         "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1222                                         "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1223                                         "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1224                                         "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1225                                         "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1226                                         "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1227                                         "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1228                                         "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1229                                         "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1230                                         "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1231                                         "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1232                                         "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1233                                         "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1234                                         "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1235                                         "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1236                                         ),
1237                         "indexes" => array(
1238                                         "PRIMARY" => array("iid"),
1239                                         "created" => array("created"),
1240                                         "commented" => array("commented"),
1241                                         "uid_network_commented" => array("uid","network","commented"),
1242                                         "uid_network_created" => array("uid","network","created"),
1243                                         "uid_contactid_commented" => array("uid","contact-id","commented"),
1244                                         "uid_contactid_created" => array("uid","contact-id","created"),
1245                                         "wall_private_received" => array("wall","private","received"),
1246                                         "uid_created" => array("uid","created"),
1247                                         "uid_commented" => array("uid","commented"),
1248                                         )
1249                         );
1250         $database["tokens"] = array(
1251                         "fields" => array(
1252                                         "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1253                                         "secret" => array("type" => "text", "not null" => "1"),
1254                                         "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1255                                         "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1256                                         "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1257                                         "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1258                                         ),
1259                         "indexes" => array(
1260                                         "PRIMARY" => array("id"),
1261                                         )
1262                         );
1263         $database["unique_contacts"] = array(
1264                         "fields" => array(
1265                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1266                                         "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1267                                         "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1268                                         "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1269                                         "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1270                                         "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1271                                         "about" => array("type" => "text", "not null" => "1"),
1272                                         ),
1273                         "indexes" => array(
1274                                         "PRIMARY" => array("id"),
1275                                         "url" => array("url"),
1276                                         )
1277                         );
1278         $database["user"] = array(
1279                         "fields" => array(
1280                                         "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1281                                         "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1282                                         "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1283                                         "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1284                                         "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1285                                         "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1286                                         "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1287                                         "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1288                                         "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1289                                         "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1290                                         "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1291                                         "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1292                                         "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1293                                         "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1294                                         "pubkey" => array("type" => "text", "not null" => "1"),
1295                                         "prvkey" => array("type" => "text", "not null" => "1"),
1296                                         "spubkey" => array("type" => "text", "not null" => "1"),
1297                                         "sprvkey" => array("type" => "text", "not null" => "1"),
1298                                         "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1299                                         "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1300                                         "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1301                                         "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1302                                         "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1303                                         "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1304                                         "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1305                                         "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1306                                         "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1307                                         "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1308                                         "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1309                                         "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1310                                         "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1311                                         "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1312                                         "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1313                                         "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1314                                         "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1315                                         "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1316                                         "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1317                                         "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
1318                                         "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
1319                                         "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
1320                                         "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1321                                         "openidserver" => array("type" => "text", "not null" => "1"),
1322                                         ),
1323                         "indexes" => array(
1324                                         "PRIMARY" => array("uid"),
1325                                         "nickname" => array("nickname"),
1326                                         )
1327                         );
1328         $database["userd"] = array(
1329                         "fields" => array(
1330                                         "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1331                                         "username" => array("type" => "varchar(255)", "not null" => "1"),
1332                                         ),
1333                         "indexes" => array(
1334                                         "PRIMARY" => array("id"),
1335                                         "username" => array("username"),
1336                                         )
1337                         );
1338
1339         return($database);
1340 }
1341
1342
1343 /*
1344  * run from command line
1345  */
1346 function dbstructure_run(&$argv, &$argc) {
1347         global $a, $db;
1348
1349         if(is_null($a)){
1350                 $a = new App;
1351         }
1352
1353         if(is_null($db)) {
1354                 @include(".htconfig.php");
1355                 require_once("include/dba.php");
1356                 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1357                         unset($db_host, $db_user, $db_pass, $db_data);
1358         }
1359
1360         update_structure(true, true);
1361 }
1362
1363 if (array_search(__file__,get_included_files())===0){
1364         dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);
1365         killme();
1366 }