2 require_once("boot.php");
3 require_once("include/text.php");
5 define('NEW_UPDATE_ROUTINE_VERSION', 1170);
8 * send the email and do what is needed to do on update fails
10 * @param update_id (int) number of failed update
11 * @param error_message (str) error message
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)",
20 // every admin could had different language
22 foreach ($adminlist as $admin) {
23 $lang = (($admin['language'])?$admin['language']:'en');
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);
36 'type' => "SYSTEM_EMAIL",
37 'to_email' => $admin['email'],
38 'preamble' => $preamble,
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)
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');
64 logger("CRITICAL: Database structure update failed: ".$retval);
69 function table_structure($table) {
70 $structures = q("DESCRIBE `%s`", $table);
72 $indexes = q("SHOW INDEX FROM `%s`", $table);
77 if (is_array($indexes))
78 foreach ($indexes AS $index) {
79 if ($index["Index_type"] == "FULLTEXT")
82 $column = $index["Column_name"];
83 if ($index["Sub_part"] != "")
84 $column .= "(".$index["Sub_part"].")";
86 $indexdata[$index["Key_name"]][] = $column;
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;
95 if ($field["Default"] != "")
96 $fielddata[$field["Field"]]["default"] = $field["Default"];
98 if ($field["Extra"] != "")
99 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
101 if ($field["Key"] == "PRI")
102 $fielddata[$field["Field"]]["primary"] = true;
106 return(array("fields"=>$fielddata, "indexes"=>$indexdata));
109 function print_structure($database) {
110 foreach ($database AS $name => $structure) {
111 echo "\t".'$database["'.$name."\"] = array(\n";
113 echo "\t\t\t".'"fields" => array('."\n";
114 foreach ($structure["fields"] AS $fieldname => $parameters) {
115 echo "\t\t\t\t\t".'"'.$fieldname.'" => array(';
118 foreach ($parameters AS $name => $value) {
121 $data .= '"'.$name.'" => "'.$value.'"';
126 echo "\t\t\t\t\t),\n";
127 echo "\t\t\t".'"indexes" => array('."\n";
128 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
129 echo "\t\t\t\t\t".'"'.$indexname.'" => array("'.implode($fieldnames, '","').'"'."),\n";
131 echo "\t\t\t\t\t)\n";
136 function update_structure($verbose, $action) {
141 logger('updating structure', LOGGER_DEBUG);
143 // Get the current structure
146 $tables = q("show tables");
148 foreach ($tables AS $table) {
149 $table = current($table);
151 $database[$table] = table_structure($table);
154 // Get the definition
155 $definition = db_definition();
158 foreach ($definition AS $name => $structure) {
160 if (!isset($database[$name])) {
161 $r = db_create_table($name, $structure["fields"], $verbose, $action);
163 $errors .= t('Errors encountered creating database tables.').$name.EOL;
165 // Drop the index if it isn't present in the definition
166 foreach ($database[$name]["indexes"] AS $indexname => $fieldnames)
167 if (!isset($structure["indexes"][$indexname])) {
168 $sql2=db_drop_index($indexname);
170 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
175 // Compare the field structure field by field
176 foreach ($structure["fields"] AS $fieldname => $parameters) {
177 if (!isset($database[$name]["fields"][$fieldname])) {
178 $sql2=db_add_table_field($fieldname, $parameters);
180 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
184 // Compare the field definition
185 $current_field_definition = implode($database[$name]["fields"][$fieldname]);
186 $new_field_definition = implode($parameters);
187 if ($current_field_definition != $new_field_definition) {
188 $sql2=db_modify_table_field($fieldname, $parameters);
190 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
200 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
201 if (!isset($database[$name]["indexes"][$indexname])) {
202 $sql2=db_create_index($indexname, $fieldnames);
205 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
221 $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
229 function db_field_command($parameters, $create = true) {
230 $fieldstruct = $parameters["type"];
232 if ($parameters["not null"])
233 $fieldstruct .= " NOT NULL";
235 if ($parameters["default"] != "")
236 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
238 if ($parameters["extra"] != "")
239 $fieldstruct .= " ".$parameters["extra"];
241 if (($parameters["primary"] != "") AND $create)
242 $fieldstruct .= " PRIMARY KEY";
244 return($fieldstruct);
247 function db_create_table($name, $fields, $verbose, $action) {
253 foreach($fields AS $fieldname => $field) {
257 $sql .= "`".dbesc($fieldname)."` ".db_field_command($field);
260 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n", dbesc($name)).$sql."\n) DEFAULT CHARSET=utf8";
271 function db_add_table_field($fieldname, $parameters) {
272 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
276 function db_modify_table_field($fieldname, $parameters) {
277 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
281 function db_drop_index($indexname) {
282 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
286 function db_create_index($indexname, $fieldnames) {
288 if ($indexname == "PRIMARY")
292 foreach ($fieldnames AS $fieldname) {
296 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches))
297 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
299 $names .= "`".dbesc($fieldname)."`";
302 $sql = sprintf("ADD INDEX `%s` (%s)", dbesc($indexname), $names);
306 function db_definition() {
310 $database["addon"] = array(
312 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
313 "name" => array("type" => "varchar(255)", "not null" => "1"),
314 "version" => array("type" => "varchar(255)", "not null" => "1"),
315 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
316 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
317 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
318 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
321 "PRIMARY" => array("id"),
324 $database["attach"] = array(
326 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
327 "uid" => array("type" => "int(11)", "not null" => "1"),
328 "hash" => array("type" => "varchar(64)", "not null" => "1"),
329 "filename" => array("type" => "varchar(255)", "not null" => "1"),
330 "filetype" => array("type" => "varchar(64)", "not null" => "1"),
331 "filesize" => array("type" => "int(11)", "not null" => "1"),
332 "data" => array("type" => "longblob", "not null" => "1"),
333 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
334 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
335 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
336 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
337 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
338 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
341 "PRIMARY" => array("id"),
344 $database["auth_codes"] = array(
346 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
347 "client_id" => array("type" => "varchar(20)", "not null" => "1"),
348 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1"),
349 "expires" => array("type" => "int(11)", "not null" => "1"),
350 "scope" => array("type" => "varchar(250)", "not null" => "1"),
353 "PRIMARY" => array("id"),
356 $database["cache"] = array(
358 "k" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
359 "v" => array("type" => "text", "not null" => "1"),
360 "updated" => array("type" => "datetime", "not null" => "1"),
363 "PRIMARY" => array("k"),
364 "updated" => array("updated"),
367 $database["challenge"] = array(
369 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
370 "challenge" => array("type" => "varchar(255)", "not null" => "1"),
371 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1"),
372 "expire" => array("type" => "int(11)", "not null" => "1"),
373 "type" => array("type" => "varchar(255)", "not null" => "1"),
374 "last_update" => array("type" => "varchar(255)", "not null" => "1"),
377 "PRIMARY" => array("id"),
380 $database["clients"] = array(
382 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
383 "pw" => array("type" => "varchar(20)", "not null" => "1"),
384 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1"),
385 "name" => array("type" => "text"),
386 "icon" => array("type" => "text"),
387 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
390 "PRIMARY" => array("client_id"),
393 $database["config"] = array(
395 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
396 "cat" => array("type" => "varchar(255)", "not null" => "1"),
397 "k" => array("type" => "varchar(255)", "not null" => "1"),
398 "v" => array("type" => "text", "not null" => "1"),
401 "PRIMARY" => array("id"),
402 "cat_k" => array("cat(30)","k(30)"),
405 $database["contact"] = array(
407 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
408 "uid" => array("type" => "int(11)", "not null" => "1"),
409 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
410 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
411 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
412 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
413 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
414 "network" => array("type" => "varchar(255)", "not null" => "1"),
415 "name" => array("type" => "varchar(255)", "not null" => "1"),
416 "nick" => array("type" => "varchar(255)", "not null" => "1"),
417 "attag" => array("type" => "varchar(255)", "not null" => "1"),
418 "photo" => array("type" => "text", "not null" => "1"),
419 "thumb" => array("type" => "text", "not null" => "1"),
420 "micro" => array("type" => "text", "not null" => "1"),
421 "site-pubkey" => array("type" => "text", "not null" => "1"),
422 "issued-id" => array("type" => "varchar(255)", "not null" => "1"),
423 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1"),
424 "url" => array("type" => "varchar(255)", "not null" => "1"),
425 "nurl" => array("type" => "varchar(255)", "not null" => "1"),
426 "addr" => array("type" => "varchar(255)", "not null" => "1"),
427 "alias" => array("type" => "varchar(255)", "not null" => "1"),
428 "pubkey" => array("type" => "text", "not null" => "1"),
429 "prvkey" => array("type" => "text", "not null" => "1"),
430 "batch" => array("type" => "varchar(255)", "not null" => "1"),
431 "request" => array("type" => "text", "not null" => "1"),
432 "notify" => array("type" => "text", "not null" => "1"),
433 "poll" => array("type" => "text", "not null" => "1"),
434 "confirm" => array("type" => "text", "not null" => "1"),
435 "poco" => array("type" => "text", "not null" => "1"),
436 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
437 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
438 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
439 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
440 "hub-verify" => array("type" => "varchar(255)", "not null" => "1"),
441 "last-update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
442 "success_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
443 "name-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
444 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
445 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
446 "term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
447 "priority" => array("type" => "tinyint(3)", "not null" => "1"),
448 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
449 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
450 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
451 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
452 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
453 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
454 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
455 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
456 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
457 "reason" => array("type" => "text", "not null" => "1"),
458 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
459 "info" => array("type" => "mediumtext", "not null" => "1"),
460 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
461 "bdyear" => array("type" => "varchar(4)", "not null" => "1"),
462 "bd" => array("type" => "date", "not null" => "1"),
463 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
464 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
467 "PRIMARY" => array("id"),
468 "uid" => array("uid"),
471 $database["conv"] = array(
473 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
474 "guid" => array("type" => "varchar(64)", "not null" => "1"),
475 "recips" => array("type" => "mediumtext", "not null" => "1"),
476 "uid" => array("type" => "int(11)", "not null" => "1"),
477 "creator" => array("type" => "varchar(255)", "not null" => "1"),
478 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
479 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
480 "subject" => array("type" => "mediumtext", "not null" => "1"),
483 "PRIMARY" => array("id"),
484 "uid" => array("uid"),
487 $database["deliverq"] = array(
489 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
490 "cmd" => array("type" => "varchar(32)", "not null" => "1"),
491 "item" => array("type" => "int(11)", "not null" => "1"),
492 "contact" => array("type" => "int(11)", "not null" => "1"),
495 "PRIMARY" => array("id"),
498 $database["dsprphotoq"] = array(
500 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
501 "uid" => array("type" => "int(11)", "not null" => "1"),
502 "msg" => array("type" => "mediumtext", "not null" => "1"),
503 "attempt" => array("type" => "tinyint(4)", "not null" => "1"),
506 "PRIMARY" => array("id"),
509 $database["event"] = array(
511 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
512 "uid" => array("type" => "int(11)", "not null" => "1"),
513 "cid" => array("type" => "int(11)", "not null" => "1"),
514 "uri" => array("type" => "varchar(255)", "not null" => "1"),
515 "created" => array("type" => "datetime", "not null" => "1"),
516 "edited" => array("type" => "datetime", "not null" => "1"),
517 "start" => array("type" => "datetime", "not null" => "1"),
518 "finish" => array("type" => "datetime", "not null" => "1"),
519 "summary" => array("type" => "text", "not null" => "1"),
520 "desc" => array("type" => "text", "not null" => "1"),
521 "location" => array("type" => "text", "not null" => "1"),
522 "type" => array("type" => "varchar(255)", "not null" => "1"),
523 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
524 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
525 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
526 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
527 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
528 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
529 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
532 "PRIMARY" => array("id"),
533 "uid" => array("uid"),
536 $database["fcontact"] = array(
538 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
539 "url" => array("type" => "varchar(255)", "not null" => "1"),
540 "name" => array("type" => "varchar(255)", "not null" => "1"),
541 "photo" => array("type" => "varchar(255)", "not null" => "1"),
542 "request" => array("type" => "varchar(255)", "not null" => "1"),
543 "nick" => array("type" => "varchar(255)", "not null" => "1"),
544 "addr" => array("type" => "varchar(255)", "not null" => "1"),
545 "batch" => array("type" => "varchar(255)", "not null" => "1"),
546 "notify" => array("type" => "varchar(255)", "not null" => "1"),
547 "poll" => array("type" => "varchar(255)", "not null" => "1"),
548 "confirm" => array("type" => "varchar(255)", "not null" => "1"),
549 "priority" => array("type" => "tinyint(1)", "not null" => "1"),
550 "network" => array("type" => "varchar(32)", "not null" => "1"),
551 "alias" => array("type" => "varchar(255)", "not null" => "1"),
552 "pubkey" => array("type" => "text", "not null" => "1"),
553 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
556 "PRIMARY" => array("id"),
557 "addr" => array("addr"),
560 $database["ffinder"] = array(
562 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
563 "uid" => array("type" => "int(10) unsigned", "not null" => "1"),
564 "cid" => array("type" => "int(10) unsigned", "not null" => "1"),
565 "fid" => array("type" => "int(10) unsigned", "not null" => "1"),
568 "PRIMARY" => array("id"),
571 $database["fserver"] = array(
573 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
574 "server" => array("type" => "varchar(255)", "not null" => "1"),
575 "posturl" => array("type" => "varchar(255)", "not null" => "1"),
576 "key" => array("type" => "text", "not null" => "1"),
579 "PRIMARY" => array("id"),
580 "server" => array("server"),
583 $database["fsuggest"] = array(
585 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
586 "uid" => array("type" => "int(11)", "not null" => "1"),
587 "cid" => array("type" => "int(11)", "not null" => "1"),
588 "name" => array("type" => "varchar(255)", "not null" => "1"),
589 "url" => array("type" => "varchar(255)", "not null" => "1"),
590 "request" => array("type" => "varchar(255)", "not null" => "1"),
591 "photo" => array("type" => "varchar(255)", "not null" => "1"),
592 "note" => array("type" => "text", "not null" => "1"),
593 "created" => array("type" => "datetime", "not null" => "1"),
596 "PRIMARY" => array("id"),
599 $database["gcign"] = array(
601 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
602 "uid" => array("type" => "int(11)", "not null" => "1"),
603 "gcid" => array("type" => "int(11)", "not null" => "1"),
606 "PRIMARY" => array("id"),
607 "uid" => array("uid"),
608 "gcid" => array("gcid"),
611 $database["gcontact"] = array(
613 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
614 "name" => array("type" => "varchar(255)", "not null" => "1"),
615 "url" => array("type" => "varchar(255)", "not null" => "1"),
616 "nurl" => array("type" => "varchar(255)", "not null" => "1"),
617 "photo" => array("type" => "varchar(255)", "not null" => "1"),
618 "connect" => array("type" => "varchar(255)", "not null" => "1"),
621 "PRIMARY" => array("id"),
622 "nurl" => array("nurl"),
625 $database["glink"] = array(
627 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
628 "cid" => array("type" => "int(11)", "not null" => "1"),
629 "uid" => array("type" => "int(11)", "not null" => "1"),
630 "gcid" => array("type" => "int(11)", "not null" => "1"),
631 "zcid" => array("type" => "int(11)", "not null" => "1"),
632 "updated" => array("type" => "datetime", "not null" => "1"),
635 "PRIMARY" => array("id"),
636 "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
637 "gcid" => array("gcid"),
638 "zcid" => array("zcid"),
641 $database["group"] = array(
643 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
644 "uid" => array("type" => "int(10) unsigned", "not null" => "1"),
645 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
646 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
647 "name" => array("type" => "varchar(255)", "not null" => "1"),
650 "PRIMARY" => array("id"),
651 "uid" => array("uid"),
654 $database["group_member"] = array(
656 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
657 "uid" => array("type" => "int(10) unsigned", "not null" => "1"),
658 "gid" => array("type" => "int(10) unsigned", "not null" => "1"),
659 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1"),
662 "PRIMARY" => array("id"),
663 "uid_gid_contactid" => array("uid","gid","contact-id"),
666 $database["guid"] = array(
668 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
669 "guid" => array("type" => "varchar(255)", "not null" => "1"),
672 "PRIMARY" => array("id"),
673 "guid" => array("guid"),
676 $database["hook"] = array(
678 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
679 "hook" => array("type" => "varchar(255)", "not null" => "1"),
680 "file" => array("type" => "varchar(255)", "not null" => "1"),
681 "function" => array("type" => "varchar(255)", "not null" => "1"),
682 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
685 "PRIMARY" => array("id"),
686 "hook_file_function" => array("hook(30)","file(60)","function(30)"),
689 $database["intro"] = array(
691 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
692 "uid" => array("type" => "int(10) unsigned", "not null" => "1"),
693 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
694 "contact-id" => array("type" => "int(11)", "not null" => "1"),
695 "knowyou" => array("type" => "tinyint(1)", "not null" => "1"),
696 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
697 "note" => array("type" => "text", "not null" => "1"),
698 "hash" => array("type" => "varchar(255)", "not null" => "1"),
699 "datetime" => array("type" => "datetime", "not null" => "1"),
700 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
701 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
704 "PRIMARY" => array("id"),
707 $database["item"] = array(
709 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
710 "guid" => array("type" => "varchar(255)", "not null" => "1"),
711 "uri" => array("type" => "varchar(255)", "not null" => "1"),
712 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
713 "contact-id" => array("type" => "int(11)", "not null" => "1"),
714 "type" => array("type" => "varchar(255)", "not null" => "1"),
715 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
716 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
717 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
718 "parent-uri" => array("type" => "varchar(255)", "not null" => "1"),
719 "extid" => array("type" => "varchar(255)", "not null" => "1"),
720 "thr-parent" => array("type" => "varchar(255)", "not null" => "1"),
721 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
722 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
723 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
724 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
725 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
726 "owner-name" => array("type" => "varchar(255)", "not null" => "1"),
727 "owner-link" => array("type" => "varchar(255)", "not null" => "1"),
728 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1"),
729 "author-name" => array("type" => "varchar(255)", "not null" => "1"),
730 "author-link" => array("type" => "varchar(255)", "not null" => "1"),
731 "author-avatar" => array("type" => "varchar(255)", "not null" => "1"),
732 "title" => array("type" => "varchar(255)", "not null" => "1"),
733 "body" => array("type" => "mediumtext", "not null" => "1"),
734 "app" => array("type" => "varchar(255)", "not null" => "1"),
735 "verb" => array("type" => "varchar(255)", "not null" => "1"),
736 "object-type" => array("type" => "varchar(255)", "not null" => "1"),
737 "object" => array("type" => "text", "not null" => "1"),
738 "target-type" => array("type" => "varchar(255)", "not null" => "1"),
739 "target" => array("type" => "text", "not null" => "1"),
740 "postopts" => array("type" => "text", "not null" => "1"),
741 "plink" => array("type" => "varchar(255)", "not null" => "1"),
742 "resource-id" => array("type" => "varchar(255)", "not null" => "1"),
743 "event-id" => array("type" => "int(11)", "not null" => "1"),
744 "tag" => array("type" => "mediumtext", "not null" => "1"),
745 "attach" => array("type" => "mediumtext", "not null" => "1"),
746 "inform" => array("type" => "mediumtext", "not null" => "1"),
747 "file" => array("type" => "mediumtext", "not null" => "1"),
748 "location" => array("type" => "varchar(255)", "not null" => "1"),
749 "coord" => array("type" => "varchar(255)", "not null" => "1"),
750 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
751 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
752 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
753 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
754 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
755 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
756 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
757 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
758 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
759 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
760 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
761 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
762 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
763 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
764 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
765 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
766 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
767 "network" => array("type" => "varchar(32)", "not null" => "1"),
770 "PRIMARY" => array("id"),
771 "guid" => array("guid"),
772 "uri" => array("uri"),
773 "parent" => array("parent"),
774 "parent-uri" => array("parent-uri"),
775 "extid" => array("extid"),
776 "uid_id" => array("uid","id"),
777 "uid_created" => array("uid","created"),
778 "uid_unseen" => array("uid","unseen"),
779 "uid_network_received" => array("uid","network","received"),
780 "uid_received" => array("uid","received"),
781 "uid_network_commented" => array("uid","network","commented"),
782 "uid_commented" => array("uid","commented"),
783 "uid_title" => array("uid","title"),
784 "uid_thrparent" => array("uid","thr-parent"),
785 "uid_parenturi" => array("uid","parent-uri"),
786 "uid_contactid_created" => array("uid","contact-id","created"),
787 "wall_body" => array("wall","body(6)"),
788 "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
789 "uid_uri" => array("uid","uri"),
790 "uid_wall_created" => array("uid","wall","created"),
791 "resource-id" => array("resource-id"),
792 "uid_type" => array("uid","type"),
793 "uid_starred" => array("uid","starred"),
794 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
795 "uid_wall_parent_created" => array("uid","wall","parent","created"),
796 "uid_type_changed" => array("uid","type","changed"),
797 "contactid_verb" => array("contact-id","verb"),
798 "deleted_changed" => array("deleted","changed"),
799 "uid_wall_changed" => array("uid","wall","changed"),
800 "uid_eventid" => array("uid","event-id"),
801 "uid_authorlink" => array("uid","author-link"),
802 "uid_ownerlink" => array("uid","owner-link"),
805 $database["item_id"] = array(
807 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
808 "iid" => array("type" => "int(11)", "not null" => "1"),
809 "uid" => array("type" => "int(11)", "not null" => "1"),
810 "sid" => array("type" => "varchar(255)", "not null" => "1"),
811 "service" => array("type" => "varchar(255)", "not null" => "1"),
814 "PRIMARY" => array("id"),
815 "uid" => array("uid"),
816 "sid" => array("sid"),
817 "service" => array("service"),
818 "iid" => array("iid"),
821 $database["locks"] = array(
823 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
824 "name" => array("type" => "varchar(128)", "not null" => "1"),
825 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
828 "PRIMARY" => array("id"),
831 $database["mail"] = array(
833 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
834 "uid" => array("type" => "int(10) unsigned", "not null" => "1"),
835 "guid" => array("type" => "varchar(64)", "not null" => "1"),
836 "from-name" => array("type" => "varchar(255)", "not null" => "1"),
837 "from-photo" => array("type" => "varchar(255)", "not null" => "1"),
838 "from-url" => array("type" => "varchar(255)", "not null" => "1"),
839 "contact-id" => array("type" => "varchar(255)", "not null" => "1"),
840 "convid" => array("type" => "int(11) unsigned", "not null" => "1"),
841 "title" => array("type" => "varchar(255)", "not null" => "1"),
842 "body" => array("type" => "mediumtext", "not null" => "1"),
843 "seen" => array("type" => "tinyint(1)", "not null" => "1"),
844 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
845 "replied" => array("type" => "tinyint(1)", "not null" => "1"),
846 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
847 "uri" => array("type" => "varchar(255)", "not null" => "1"),
848 "parent-uri" => array("type" => "varchar(255)", "not null" => "1"),
849 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
852 "PRIMARY" => array("id"),
853 "uid" => array("uid"),
854 "guid" => array("guid"),
855 "convid" => array("convid"),
856 "reply" => array("reply"),
857 "uri" => array("uri"),
858 "parent-uri" => array("parent-uri"),
861 $database["mailacct"] = array(
863 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
864 "uid" => array("type" => "int(11)", "not null" => "1"),
865 "server" => array("type" => "varchar(255)", "not null" => "1"),
866 "port" => array("type" => "int(11)", "not null" => "1"),
867 "ssltype" => array("type" => "varchar(16)", "not null" => "1"),
868 "mailbox" => array("type" => "varchar(255)", "not null" => "1"),
869 "user" => array("type" => "varchar(255)", "not null" => "1"),
870 "pass" => array("type" => "text", "not null" => "1"),
871 "reply_to" => array("type" => "varchar(255)", "not null" => "1"),
872 "action" => array("type" => "int(11)", "not null" => "1"),
873 "movetofolder" => array("type" => "varchar(255)", "not null" => "1"),
874 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
875 "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
878 "PRIMARY" => array("id"),
881 $database["manage"] = array(
883 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
884 "uid" => array("type" => "int(11)", "not null" => "1"),
885 "mid" => array("type" => "int(11)", "not null" => "1"),
888 "PRIMARY" => array("id"),
889 "uid_mid" => array("uid","mid"),
892 $database["notify"] = array(
894 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
895 "hash" => array("type" => "varchar(64)", "not null" => "1"),
896 "type" => array("type" => "int(11)", "not null" => "1"),
897 "name" => array("type" => "varchar(255)", "not null" => "1"),
898 "url" => array("type" => "varchar(255)", "not null" => "1"),
899 "photo" => array("type" => "varchar(255)", "not null" => "1"),
900 "date" => array("type" => "datetime", "not null" => "1"),
901 "msg" => array("type" => "mediumtext", "not null" => "1"),
902 "uid" => array("type" => "int(11)", "not null" => "1"),
903 "link" => array("type" => "varchar(255)", "not null" => "1"),
904 "parent" => array("type" => "int(11)", "not null" => "1"),
905 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
906 "verb" => array("type" => "varchar(255)", "not null" => "1"),
907 "otype" => array("type" => "varchar(16)", "not null" => "1"),
910 "PRIMARY" => array("id"),
911 "uid" => array("uid"),
914 $database["notify-threads"] = array(
916 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
917 "notify-id" => array("type" => "int(11)", "not null" => "1"),
918 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
919 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
920 "receiver-uid" => array("type" => "int(11)", "not null" => "1"),
923 "PRIMARY" => array("id"),
924 "master-parent-item" => array("master-parent-item"),
925 "receiver-uid" => array("receiver-uid"),
928 $database["pconfig"] = array(
930 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
931 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
932 "cat" => array("type" => "varchar(255)", "not null" => "1"),
933 "k" => array("type" => "varchar(255)", "not null" => "1"),
934 "v" => array("type" => "mediumtext", "not null" => "1"),
937 "PRIMARY" => array("id"),
938 "uid_cat_k" => array("uid","cat(30)","k(30)"),
941 $database["photo"] = array(
943 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
944 "uid" => array("type" => "int(10) unsigned", "not null" => "1"),
945 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
946 "guid" => array("type" => "varchar(64)", "not null" => "1"),
947 "resource-id" => array("type" => "varchar(255)", "not null" => "1"),
948 "created" => array("type" => "datetime", "not null" => "1"),
949 "edited" => array("type" => "datetime", "not null" => "1"),
950 "title" => array("type" => "varchar(255)", "not null" => "1"),
951 "desc" => array("type" => "text", "not null" => "1"),
952 "album" => array("type" => "varchar(255)", "not null" => "1"),
953 "filename" => array("type" => "varchar(255)", "not null" => "1"),
954 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
955 "height" => array("type" => "smallint(6)", "not null" => "1"),
956 "width" => array("type" => "smallint(6)", "not null" => "1"),
957 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
958 "data" => array("type" => "mediumblob", "not null" => "1"),
959 "scale" => array("type" => "tinyint(3)", "not null" => "1"),
960 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
961 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
962 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
963 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
964 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
967 "PRIMARY" => array("id"),
968 "uid" => array("uid"),
969 "resource-id" => array("resource-id"),
970 "guid" => array("guid"),
973 $database["poll"] = array(
975 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
976 "uid" => array("type" => "int(11)", "not null" => "1"),
977 "q0" => array("type" => "mediumtext", "not null" => "1"),
978 "q1" => array("type" => "mediumtext", "not null" => "1"),
979 "q2" => array("type" => "mediumtext", "not null" => "1"),
980 "q3" => array("type" => "mediumtext", "not null" => "1"),
981 "q4" => array("type" => "mediumtext", "not null" => "1"),
982 "q5" => array("type" => "mediumtext", "not null" => "1"),
983 "q6" => array("type" => "mediumtext", "not null" => "1"),
984 "q7" => array("type" => "mediumtext", "not null" => "1"),
985 "q8" => array("type" => "mediumtext", "not null" => "1"),
986 "q9" => array("type" => "mediumtext", "not null" => "1"),
989 "PRIMARY" => array("id"),
990 "uid" => array("uid"),
993 $database["poll_result"] = array(
995 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
996 "poll_id" => array("type" => "int(11)", "not null" => "1"),
997 "choice" => array("type" => "int(11)", "not null" => "1"),
1000 "PRIMARY" => array("id"),
1001 "poll_id" => array("poll_id"),
1002 "choice" => array("choice"),
1005 $database["profile"] = array(
1007 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1008 "uid" => array("type" => "int(11)", "not null" => "1"),
1009 "profile-name" => array("type" => "varchar(255)", "not null" => "1"),
1010 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1011 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1012 "name" => array("type" => "varchar(255)", "not null" => "1"),
1013 "pdesc" => array("type" => "varchar(255)", "not null" => "1"),
1014 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1015 "address" => array("type" => "varchar(255)", "not null" => "1"),
1016 "locality" => array("type" => "varchar(255)", "not null" => "1"),
1017 "region" => array("type" => "varchar(255)", "not null" => "1"),
1018 "postal-code" => array("type" => "varchar(32)", "not null" => "1"),
1019 "country-name" => array("type" => "varchar(255)", "not null" => "1"),
1020 "hometown" => array("type" => "varchar(255)", "not null" => "1"),
1021 "gender" => array("type" => "varchar(32)", "not null" => "1"),
1022 "marital" => array("type" => "varchar(255)", "not null" => "1"),
1023 "with" => array("type" => "text", "not null" => "1"),
1024 "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1025 "sexual" => array("type" => "varchar(255)", "not null" => "1"),
1026 "politic" => array("type" => "varchar(255)", "not null" => "1"),
1027 "religion" => array("type" => "varchar(255)", "not null" => "1"),
1028 "pub_keywords" => array("type" => "text", "not null" => "1"),
1029 "prv_keywords" => array("type" => "text", "not null" => "1"),
1030 "likes" => array("type" => "text", "not null" => "1"),
1031 "dislikes" => array("type" => "text", "not null" => "1"),
1032 "about" => array("type" => "text", "not null" => "1"),
1033 "summary" => array("type" => "varchar(255)", "not null" => "1"),
1034 "music" => array("type" => "text", "not null" => "1"),
1035 "book" => array("type" => "text", "not null" => "1"),
1036 "tv" => array("type" => "text", "not null" => "1"),
1037 "film" => array("type" => "text", "not null" => "1"),
1038 "interest" => array("type" => "text", "not null" => "1"),
1039 "romance" => array("type" => "text", "not null" => "1"),
1040 "work" => array("type" => "text", "not null" => "1"),
1041 "education" => array("type" => "text", "not null" => "1"),
1042 "contact" => array("type" => "text", "not null" => "1"),
1043 "homepage" => array("type" => "varchar(255)", "not null" => "1"),
1044 "photo" => array("type" => "varchar(255)", "not null" => "1"),
1045 "thumb" => array("type" => "varchar(255)", "not null" => "1"),
1046 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1047 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1050 "PRIMARY" => array("id"),
1051 "hometown" => array("hometown"),
1054 $database["profile_check"] = array(
1056 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1057 "uid" => array("type" => "int(10) unsigned", "not null" => "1"),
1058 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1059 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1"),
1060 "sec" => array("type" => "varchar(255)", "not null" => "1"),
1061 "expire" => array("type" => "int(11)", "not null" => "1"),
1064 "PRIMARY" => array("id"),
1067 $database["push_subscriber"] = array(
1069 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1070 "uid" => array("type" => "int(11)", "not null" => "1"),
1071 "callback_url" => array("type" => "varchar(255)", "not null" => "1"),
1072 "topic" => array("type" => "varchar(255)", "not null" => "1"),
1073 "nickname" => array("type" => "varchar(255)", "not null" => "1"),
1074 "push" => array("type" => "int(11)", "not null" => "1"),
1075 "last_update" => array("type" => "datetime", "not null" => "1"),
1076 "secret" => array("type" => "varchar(255)", "not null" => "1"),
1079 "PRIMARY" => array("id"),
1082 $database["queue"] = array(
1084 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1085 "cid" => array("type" => "int(11)", "not null" => "1"),
1086 "network" => array("type" => "varchar(32)", "not null" => "1"),
1087 "created" => array("type" => "datetime", "not null" => "1"),
1088 "last" => array("type" => "datetime", "not null" => "1"),
1089 "content" => array("type" => "mediumtext", "not null" => "1"),
1090 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1093 "PRIMARY" => array("id"),
1094 "cid" => array("cid"),
1095 "created" => array("created"),
1096 "last" => array("last"),
1097 "network" => array("network"),
1098 "batch" => array("batch"),
1101 $database["register"] = array(
1103 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1104 "hash" => array("type" => "varchar(255)", "not null" => "1"),
1105 "created" => array("type" => "datetime", "not null" => "1"),
1106 "uid" => array("type" => "int(11) unsigned", "not null" => "1"),
1107 "password" => array("type" => "varchar(255)", "not null" => "1"),
1108 "language" => array("type" => "varchar(16)", "not null" => "1"),
1111 "PRIMARY" => array("id"),
1114 $database["search"] = array(
1116 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1117 "uid" => array("type" => "int(11)", "not null" => "1"),
1118 "term" => array("type" => "varchar(255)", "not null" => "1"),
1121 "PRIMARY" => array("id"),
1122 "uid" => array("uid"),
1123 "term" => array("term"),
1126 $database["session"] = array(
1128 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1129 "sid" => array("type" => "varchar(255)", "not null" => "1"),
1130 "data" => array("type" => "text", "not null" => "1"),
1131 "expire" => array("type" => "int(10) unsigned", "not null" => "1"),
1134 "PRIMARY" => array("id"),
1135 "sid" => array("sid"),
1136 "expire" => array("expire"),
1139 $database["sign"] = array(
1141 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1142 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1143 "retract_iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1144 "signed_text" => array("type" => "mediumtext", "not null" => "1"),
1145 "signature" => array("type" => "text", "not null" => "1"),
1146 "signer" => array("type" => "varchar(255)", "not null" => "1"),
1149 "PRIMARY" => array("id"),
1150 "iid" => array("iid"),
1151 "retract_iid" => array("retract_iid"),
1154 $database["spam"] = array(
1156 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1157 "uid" => array("type" => "int(11)", "not null" => "1"),
1158 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1159 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1160 "term" => array("type" => "varchar(255)", "not null" => "1"),
1161 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1164 "PRIMARY" => array("id"),
1165 "uid" => array("uid"),
1166 "spam" => array("spam"),
1167 "ham" => array("ham"),
1168 "term" => array("term"),
1171 $database["term"] = array(
1173 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1174 "oid" => array("type" => "int(10) unsigned", "not null" => "1"),
1175 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1"),
1176 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1"),
1177 "term" => array("type" => "varchar(255)", "not null" => "1"),
1178 "url" => array("type" => "varchar(255)", "not null" => "1"),
1179 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1180 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1183 "PRIMARY" => array("tid"),
1184 "oid_otype_type_term" => array("oid","otype","type","term"),
1185 "uid_term_tid" => array("uid","term","tid"),
1186 "type_term" => array("type","term"),
1187 "uid_otype_type_term_tid" => array("uid","otype","type","term","tid"),
1188 "otype_type_term_tid" => array("otype","type","term","tid"),
1191 $database["thread"] = array(
1193 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1194 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1195 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1196 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1197 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1198 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1199 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1200 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1201 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1202 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1203 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1204 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1205 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1206 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1207 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1208 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1209 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1210 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1211 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1212 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1213 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1214 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1215 "network" => array("type" => "varchar(32)", "not null" => "1"),
1218 "PRIMARY" => array("iid"),
1219 "created" => array("created"),
1220 "commented" => array("commented"),
1221 "uid_network_commented" => array("uid","network","commented"),
1222 "uid_network_created" => array("uid","network","created"),
1223 "uid_contactid_commented" => array("uid","contact-id","commented"),
1224 "uid_contactid_created" => array("uid","contact-id","created"),
1225 "wall_private_received" => array("wall","private","received"),
1226 "uid_created" => array("uid","created"),
1227 "uid_commented" => array("uid","commented"),
1230 $database["tokens"] = array(
1232 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1233 "secret" => array("type" => "text", "not null" => "1"),
1234 "client_id" => array("type" => "varchar(20)", "not null" => "1"),
1235 "expires" => array("type" => "int(11)", "not null" => "1"),
1236 "scope" => array("type" => "varchar(200)", "not null" => "1"),
1237 "uid" => array("type" => "int(11)", "not null" => "1"),
1240 "PRIMARY" => array("id"),
1243 $database["unique_contacts"] = array(
1245 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1246 "url" => array("type" => "varchar(255)", "not null" => "1"),
1247 "nick" => array("type" => "varchar(255)", "not null" => "1"),
1248 "name" => array("type" => "varchar(255)", "not null" => "1"),
1249 "avatar" => array("type" => "varchar(255)", "not null" => "1"),
1252 "PRIMARY" => array("id"),
1253 "url" => array("url"),
1256 $database["user"] = array(
1258 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1259 "guid" => array("type" => "varchar(64)", "not null" => "1"),
1260 "username" => array("type" => "varchar(255)", "not null" => "1"),
1261 "password" => array("type" => "varchar(255)", "not null" => "1"),
1262 "nickname" => array("type" => "varchar(255)", "not null" => "1"),
1263 "email" => array("type" => "varchar(255)", "not null" => "1"),
1264 "openid" => array("type" => "varchar(255)", "not null" => "1"),
1265 "timezone" => array("type" => "varchar(128)", "not null" => "1"),
1266 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1267 "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1268 "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1269 "default-location" => array("type" => "varchar(255)", "not null" => "1"),
1270 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1271 "theme" => array("type" => "varchar(255)", "not null" => "1"),
1272 "pubkey" => array("type" => "text", "not null" => "1"),
1273 "prvkey" => array("type" => "text", "not null" => "1"),
1274 "spubkey" => array("type" => "text", "not null" => "1"),
1275 "sprvkey" => array("type" => "text", "not null" => "1"),
1276 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1277 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1278 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1279 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1280 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1281 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1282 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1283 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1284 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1285 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1286 "pwdreset" => array("type" => "varchar(255)", "not null" => "1"),
1287 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1288 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1289 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1290 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1291 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1292 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1293 "service_class" => array("type" => "varchar(32)", "not null" => "1"),
1294 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1295 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
1296 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
1297 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
1298 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1299 "openidserver" => array("type" => "text", "not null" => "1"),
1302 "PRIMARY" => array("uid"),
1303 "nickname" => array("nickname"),
1306 $database["userd"] = array(
1308 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1309 "username" => array("type" => "varchar(255)", "not null" => "1"),
1312 "PRIMARY" => array("id"),
1313 "username" => array("username"),
1322 * run from command line
1324 function dbstructure_run(&$argv, &$argc) {
1332 @include(".htconfig.php");
1333 require_once("include/dba.php");
1334 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1335 unset($db_host, $db_user, $db_pass, $db_data);
1338 update_structure(true, true);
1341 if (array_search(__file__,get_included_files())===0){
1342 dbstructure_run($argv,$argc);