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);
68 function table_structure($table) {
69 $structures = q("DESCRIBE `%s`", $table);
71 $indexes = q("SHOW INDEX FROM `%s`", $table);
76 if (is_array($indexes))
77 foreach ($indexes AS $index) {
78 if ($index["Index_type"] == "FULLTEXT")
81 $column = $index["Column_name"];
82 if ($index["Sub_part"] != "")
83 $column .= "(".$index["Sub_part"].")";
85 $indexdata[$index["Key_name"]][] = $column;
88 if (is_array($structures)) {
89 foreach($structures AS $field) {
90 $fielddata[$field["Field"]]["type"] = $field["Type"];
91 if ($field["Null"] == "NO")
92 $fielddata[$field["Field"]]["not null"] = true;
94 if (isset($field["Default"]))
95 $fielddata[$field["Field"]]["default"] = $field["Default"];
97 if ($field["Extra"] != "")
98 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
100 if ($field["Key"] == "PRI")
101 $fielddata[$field["Field"]]["primary"] = true;
104 return(array("fields"=>$fielddata, "indexes"=>$indexdata));
107 function print_structure($database) {
108 echo "-- ------------------------------------------\n";
109 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
110 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
111 echo "-- ------------------------------------------\n\n\n";
112 foreach ($database AS $name => $structure) {
114 echo "-- TABLE $name\n";
116 db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
122 function update_structure($verbose, $action, $tables=null, $definition=null) {
127 logger('updating structure', LOGGER_DEBUG);
129 // Get the current structure
132 if (is_null($tables))
133 $tables = q("show tables");
135 foreach ($tables AS $table) {
136 $table = current($table);
138 $database[$table] = table_structure($table);
141 // Get the definition
142 if (is_null($definition))
143 $definition = db_definition();
147 foreach ($definition AS $name => $structure) {
148 $is_new_table = False;
150 if (!isset($database[$name])) {
151 $r = db_create_table($name, $structure["fields"], $verbose, $action, $structure['indexes']);
153 $errors .= t('Errors encountered creating database tables.').$name.EOL;
155 $is_new_table = True;
157 // Drop the index if it isn't present in the definition
158 // or the definition differ from current status
159 // and index name doesn't start with "local_"
160 foreach ($database[$name]["indexes"] AS $indexname => $fieldnames) {
161 $current_index_definition = implode(",",$fieldnames);
162 if (isset($structure["indexes"][$indexname])) {
163 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
165 $new_index_definition = "__NOT_SET__";
167 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
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;
199 // Create the index if the index don't exists in database
200 // or the definition differ from the current status.
201 // Don't create keys if table is new
202 if (!$is_new_table) {
203 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
204 if (isset($database[$name]["indexes"][$indexname])) {
205 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
207 $current_index_definition = "__NOT_SET__";
209 $new_index_definition = implode(",",$fieldnames);
210 if ($current_index_definition != $new_index_definition) {
211 $sql2=db_create_index($indexname, $fieldnames);
214 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
230 $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
238 function db_field_command($parameters, $create = true) {
239 $fieldstruct = $parameters["type"];
241 if ($parameters["not null"])
242 $fieldstruct .= " NOT NULL";
244 if (isset($parameters["default"])){
245 if (strpos(strtolower($parameters["type"]),"int")!==false) {
246 $fieldstruct .= " DEFAULT ".$parameters["default"];
248 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
251 if ($parameters["extra"] != "")
252 $fieldstruct .= " ".$parameters["extra"];
254 /*if (($parameters["primary"] != "") AND $create)
255 $fieldstruct .= " PRIMARY KEY";*/
257 return($fieldstruct);
260 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
263 if (isset($a->config["system"]["db_charset"]))
264 $charset = $a->config["system"]["db_charset"];
266 $charset = "utf8mb4";
275 $primary_keys = array();
276 foreach($fields AS $fieldname => $field) {
277 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
278 if (x($field,'primary') and $field['primary']!=''){
279 $primary_keys[] = $fieldname;
283 if (!is_null($indexes)) {
284 foreach ($indexes AS $indexname => $fieldnames) {
285 $sql_index = db_create_index($indexname, $fieldnames, "");
286 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
290 $sql = implode(",\n\t", $sql_rows);
292 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT CHARSET=".$charset;
302 function db_add_table_field($fieldname, $parameters) {
303 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
307 function db_modify_table_field($fieldname, $parameters) {
308 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
312 function db_drop_index($indexname) {
313 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
317 function db_create_index($indexname, $fieldnames, $method="ADD") {
319 $method = strtoupper(trim($method));
320 if ($method!="" && $method!="ADD") {
321 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
326 if ($indexname == "PRIMARY") {
327 return sprintf("%s PRIMARY KEY(`%s`)", $method, implode("`,`", $fieldnames));
331 foreach ($fieldnames AS $fieldname) {
335 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches))
336 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
338 $names .= "`".dbesc($fieldname)."`";
342 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
346 function db_definition() {
350 $database["addon"] = array(
352 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
353 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
354 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
355 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
356 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
357 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
358 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
361 "PRIMARY" => array("id"),
364 $database["attach"] = array(
366 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
367 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
368 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
369 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
370 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
371 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
372 "data" => array("type" => "longblob", "not null" => "1"),
373 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
374 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
375 "allow_cid" => array("type" => "mediumtext"),
376 "allow_gid" => array("type" => "mediumtext"),
377 "deny_cid" => array("type" => "mediumtext"),
378 "deny_gid" => array("type" => "mediumtext"),
381 "PRIMARY" => array("id"),
384 $database["auth_codes"] = array(
386 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
387 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
388 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
389 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
390 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
393 "PRIMARY" => array("id"),
396 $database["cache"] = array(
398 "k" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
399 "v" => array("type" => "text"),
400 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
401 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
404 "PRIMARY" => array("k"),
405 "updated" => array("updated"),
408 $database["challenge"] = array(
410 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
411 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
412 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
413 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
414 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
415 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
418 "PRIMARY" => array("id"),
421 $database["clients"] = array(
423 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
424 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
425 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
426 "name" => array("type" => "text"),
427 "icon" => array("type" => "text"),
428 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
431 "PRIMARY" => array("client_id"),
434 $database["config"] = array(
436 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
437 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
438 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
439 "v" => array("type" => "text"),
442 "PRIMARY" => array("id"),
443 "cat_k" => array("cat(30)","k(30)"),
446 $database["contact"] = array(
448 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
449 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
450 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
451 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
452 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
453 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
454 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
455 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
456 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
457 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
458 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
459 "about" => array("type" => "text"),
460 "keywords" => array("type" => "text"),
461 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
462 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
463 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
464 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
465 "photo" => array("type" => "text"),
466 "thumb" => array("type" => "text"),
467 "micro" => array("type" => "text"),
468 "site-pubkey" => array("type" => "text"),
469 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
470 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
471 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
472 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
473 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
474 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
475 "pubkey" => array("type" => "text"),
476 "prvkey" => array("type" => "text"),
477 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
478 "request" => array("type" => "text"),
479 "notify" => array("type" => "text"),
480 "poll" => array("type" => "text"),
481 "confirm" => array("type" => "text"),
482 "poco" => array("type" => "text"),
483 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
484 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
485 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
486 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
487 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
488 "last-update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
489 "success_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
490 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
491 "name-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
492 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
493 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
494 "term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
495 "last-item" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
496 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
497 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
498 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
499 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
500 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
501 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
502 "contact-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
503 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
504 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
505 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
506 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
507 "reason" => array("type" => "text"),
508 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
509 "info" => array("type" => "mediumtext"),
510 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
511 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
512 "bd" => array("type" => "date", "not null" => "1", "default" => "0000-00-00"),
513 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
514 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
515 "ffi_keyword_blacklist" => array("type" => "mediumtext"),
518 "PRIMARY" => array("id"),
519 "uid" => array("uid"),
520 "nurl" => array("nurl"),
523 $database["conv"] = array(
525 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
526 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
527 "recips" => array("type" => "mediumtext"),
528 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
529 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
530 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
531 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
532 "subject" => array("type" => "mediumtext"),
535 "PRIMARY" => array("id"),
536 "uid" => array("uid"),
539 $database["deliverq"] = array(
541 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
542 "cmd" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
543 "item" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
544 "contact" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
547 "PRIMARY" => array("id"),
550 $database["event"] = array(
552 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
553 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
554 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
555 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
556 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
557 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
558 "start" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
559 "finish" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
560 "summary" => array("type" => "text"),
561 "desc" => array("type" => "text"),
562 "location" => array("type" => "text"),
563 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
564 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
565 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
566 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
567 "allow_cid" => array("type" => "mediumtext"),
568 "allow_gid" => array("type" => "mediumtext"),
569 "deny_cid" => array("type" => "mediumtext"),
570 "deny_gid" => array("type" => "mediumtext"),
573 "PRIMARY" => array("id"),
574 "uid" => array("uid"),
577 $database["fcontact"] = array(
579 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
580 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
581 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
582 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
583 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
584 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
585 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
586 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
587 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
588 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
589 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
590 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
591 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
592 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
593 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
594 "pubkey" => array("type" => "text"),
595 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
598 "PRIMARY" => array("id"),
599 "addr" => array("addr"),
602 $database["ffinder"] = array(
604 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
605 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
606 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
607 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
610 "PRIMARY" => array("id"),
613 $database["fserver"] = array(
615 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
616 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
617 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
618 "key" => array("type" => "text"),
621 "PRIMARY" => array("id"),
622 "server" => array("server"),
625 $database["fsuggest"] = array(
627 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
628 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
629 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
630 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
631 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
632 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
633 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
634 "note" => array("type" => "text"),
635 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
638 "PRIMARY" => array("id"),
641 $database["gcign"] = array(
643 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
644 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
645 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
648 "PRIMARY" => array("id"),
649 "uid" => array("uid"),
650 "gcid" => array("gcid"),
653 $database["gcontact"] = array(
655 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
656 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
657 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
658 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
659 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
660 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
661 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
662 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
663 "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
664 "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
665 "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
666 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
667 "about" => array("type" => "text"),
668 "keywords" => array("type" => "text"),
669 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
670 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
671 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
672 "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
673 "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
674 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
675 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
676 "notify" => array("type" => "text"),
677 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
678 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
679 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
682 "PRIMARY" => array("id"),
683 "nurl" => array("nurl"),
684 "name" => array("name"),
685 "nick" => array("nick"),
686 "addr" => array("addr"),
687 "updated" => array("updated"),
690 $database["glink"] = array(
692 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
693 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
694 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
695 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
696 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
697 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
700 "PRIMARY" => array("id"),
701 "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
702 "gcid" => array("gcid"),
703 "zcid" => array("zcid"),
706 $database["group"] = array(
708 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
709 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
710 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
711 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
712 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
715 "PRIMARY" => array("id"),
716 "uid" => array("uid"),
719 $database["group_member"] = array(
721 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
722 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
723 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
724 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
727 "PRIMARY" => array("id"),
728 "uid_gid_contactid" => array("uid","gid","contact-id"),
731 $database["gserver"] = array(
733 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
734 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
735 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
736 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
737 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
738 "info" => array("type" => "text"),
739 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
740 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
741 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
742 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
743 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
744 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
745 "last_poco_query" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
746 "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
747 "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
750 "PRIMARY" => array("id"),
751 "nurl" => array("nurl"),
754 $database["hook"] = array(
756 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
757 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
758 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
759 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
760 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
763 "PRIMARY" => array("id"),
764 "hook_file_function" => array("hook(30)","file(60)","function(30)"),
767 $database["intro"] = array(
769 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
770 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
771 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
772 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
773 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
774 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
775 "note" => array("type" => "text"),
776 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
777 "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
778 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
779 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
782 "PRIMARY" => array("id"),
785 $database["item"] = array(
787 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
788 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
789 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
790 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
791 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
792 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
793 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
794 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
795 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
796 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
797 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
798 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
799 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
800 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
801 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
802 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
803 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
804 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
805 "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
806 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
807 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
808 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
809 "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
810 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
811 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
812 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
813 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
814 "body" => array("type" => "mediumtext"),
815 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
816 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
817 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
818 "object" => array("type" => "text"),
819 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
820 "target" => array("type" => "text"),
821 "postopts" => array("type" => "text"),
822 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
823 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
824 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
825 "tag" => array("type" => "mediumtext"),
826 "attach" => array("type" => "mediumtext"),
827 "inform" => array("type" => "mediumtext"),
828 "file" => array("type" => "mediumtext"),
829 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
830 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
831 "allow_cid" => array("type" => "mediumtext"),
832 "allow_gid" => array("type" => "mediumtext"),
833 "deny_cid" => array("type" => "mediumtext"),
834 "deny_gid" => array("type" => "mediumtext"),
835 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
836 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
837 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
838 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
839 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
840 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
841 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
842 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
843 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
844 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
845 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
846 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
847 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
848 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
849 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
850 "rendered-html" => array("type" => "mediumtext"),
851 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
854 "PRIMARY" => array("id"),
855 "guid" => array("guid"),
856 "uri" => array("uri"),
857 "parent" => array("parent"),
858 "parent-uri" => array("parent-uri"),
859 "extid" => array("extid"),
860 "uid_id" => array("uid","id"),
861 "uid_created" => array("uid","created"),
862 "uid_unseen_contactid" => array("uid","unseen","contact-id"),
863 "uid_network_received" => array("uid","network","received"),
864 "uid_received" => array("uid","received"),
865 "uid_network_commented" => array("uid","network","commented"),
866 "uid_commented" => array("uid","commented"),
867 "uid_title" => array("uid","title"),
868 "uid_thrparent" => array("uid","thr-parent"),
869 "uid_parenturi" => array("uid","parent-uri"),
870 "uid_contactid_id" => array("uid","contact-id","id"),
871 "uid_contactid_created" => array("uid","contact-id","created"),
872 "gcontactid_uid_created" => array("gcontact-id","uid","created"),
873 "authorid_created" => array("author-id","created"),
874 "ownerid_created" => array("owner-id","created"),
875 "wall_body" => array("wall","body(6)"),
876 "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
877 "uid_uri" => array("uid","uri"),
878 "uid_wall_created" => array("uid","wall","created"),
879 "resource-id" => array("resource-id"),
880 "uid_type" => array("uid","type"),
881 "uid_starred_id" => array("uid","starred", "id"),
882 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
883 "uid_wall_parent_created" => array("uid","wall","parent","created"),
884 "uid_type_changed" => array("uid","type","changed"),
885 "contactid_verb" => array("contact-id","verb"),
886 "deleted_changed" => array("deleted","changed"),
887 "uid_wall_changed" => array("uid","wall","changed"),
888 "uid_eventid" => array("uid","event-id"),
889 "uid_authorlink" => array("uid","author-link"),
890 "uid_ownerlink" => array("uid","owner-link"),
893 $database["item_id"] = array(
895 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
896 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
897 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
898 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
899 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
902 "PRIMARY" => array("id"),
903 "uid" => array("uid"),
904 "sid" => array("sid"),
905 "service" => array("service"),
906 "iid" => array("iid"),
909 $database["locks"] = array(
911 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
912 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
913 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
914 "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
917 "PRIMARY" => array("id"),
920 $database["mail"] = array(
922 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
923 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
924 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
925 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
926 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
927 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
928 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
929 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
930 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
931 "body" => array("type" => "mediumtext"),
932 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
933 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
934 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
935 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
936 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
937 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
938 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
941 "PRIMARY" => array("id"),
942 "uid" => array("uid"),
943 "guid" => array("guid"),
944 "convid" => array("convid"),
945 "reply" => array("reply"),
946 "uri" => array("uri"),
947 "parent-uri" => array("parent-uri"),
950 $database["mailacct"] = array(
952 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
953 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
954 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
955 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
956 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
957 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
958 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
959 "pass" => array("type" => "text"),
960 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
961 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
962 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
963 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
964 "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
967 "PRIMARY" => array("id"),
970 $database["manage"] = array(
972 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
973 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
974 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
977 "PRIMARY" => array("id"),
978 "uid_mid" => array("uid","mid"),
981 $database["notify"] = array(
983 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
984 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
985 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
986 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
987 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
988 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
989 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
990 "msg" => array("type" => "mediumtext"),
991 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
992 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
993 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
994 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
995 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
996 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
997 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1000 "PRIMARY" => array("id"),
1001 "uid" => array("uid"),
1004 $database["notify-threads"] = array(
1006 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1007 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1008 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1009 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1010 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1013 "PRIMARY" => array("id"),
1014 "master-parent-item" => array("master-parent-item"),
1015 "receiver-uid" => array("receiver-uid"),
1018 $database["oembed"] = array(
1020 "url" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
1021 "content" => array("type" => "text"),
1022 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1025 "PRIMARY" => array("url"),
1026 "created" => array("created"),
1029 $database["parsed_url"] = array(
1031 "url" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
1032 "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1033 "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1034 "content" => array("type" => "text"),
1035 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1038 "PRIMARY" => array("url", "guessing", "oembed"),
1039 "created" => array("created"),
1042 $database["pconfig"] = array(
1044 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1045 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1046 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1047 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1048 "v" => array("type" => "mediumtext"),
1051 "PRIMARY" => array("id"),
1052 "uid_cat_k" => array("uid","cat(30)","k(30)"),
1055 $database["photo"] = array(
1057 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1058 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1059 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1060 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1061 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1062 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1063 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1064 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1065 "desc" => array("type" => "text"),
1066 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1067 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1068 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1069 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1070 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1071 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1072 "data" => array("type" => "mediumblob", "not null" => "1"),
1073 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1074 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1075 "allow_cid" => array("type" => "mediumtext"),
1076 "allow_gid" => array("type" => "mediumtext"),
1077 "deny_cid" => array("type" => "mediumtext"),
1078 "deny_gid" => array("type" => "mediumtext"),
1081 "PRIMARY" => array("id"),
1082 "uid" => array("uid"),
1083 "resource-id" => array("resource-id"),
1084 "guid" => array("guid"),
1087 $database["poll"] = array(
1089 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1090 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1091 "q0" => array("type" => "mediumtext"),
1092 "q1" => array("type" => "mediumtext"),
1093 "q2" => array("type" => "mediumtext"),
1094 "q3" => array("type" => "mediumtext"),
1095 "q4" => array("type" => "mediumtext"),
1096 "q5" => array("type" => "mediumtext"),
1097 "q6" => array("type" => "mediumtext"),
1098 "q7" => array("type" => "mediumtext"),
1099 "q8" => array("type" => "mediumtext"),
1100 "q9" => array("type" => "mediumtext"),
1103 "PRIMARY" => array("id"),
1104 "uid" => array("uid"),
1107 $database["poll_result"] = array(
1109 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1110 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1111 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1114 "PRIMARY" => array("id"),
1115 "poll_id" => array("poll_id"),
1116 "choice" => array("choice"),
1119 $database["process"] = array(
1121 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
1122 "command" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1123 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1126 "PRIMARY" => array("pid"),
1127 "command" => array("command"),
1130 $database["profile"] = array(
1132 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1133 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1134 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1135 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1136 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1137 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1138 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1139 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1140 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1141 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1142 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1143 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1144 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1145 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1146 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1147 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1148 "with" => array("type" => "text"),
1149 "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1150 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1151 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1152 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1153 "pub_keywords" => array("type" => "text"),
1154 "prv_keywords" => array("type" => "text"),
1155 "likes" => array("type" => "text"),
1156 "dislikes" => array("type" => "text"),
1157 "about" => array("type" => "text"),
1158 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1159 "music" => array("type" => "text"),
1160 "book" => array("type" => "text"),
1161 "tv" => array("type" => "text"),
1162 "film" => array("type" => "text"),
1163 "interest" => array("type" => "text"),
1164 "romance" => array("type" => "text"),
1165 "work" => array("type" => "text"),
1166 "education" => array("type" => "text"),
1167 "contact" => array("type" => "text"),
1168 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1169 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1170 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1171 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1172 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1173 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1176 "PRIMARY" => array("id"),
1177 "hometown" => array("hometown"),
1180 $database["profile_check"] = array(
1182 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1183 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1184 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1185 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1186 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1187 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1190 "PRIMARY" => array("id"),
1193 $database["push_subscriber"] = array(
1195 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1196 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1197 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1198 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1199 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1200 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1201 "last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1202 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1205 "PRIMARY" => array("id"),
1208 $database["queue"] = array(
1210 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1211 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1212 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1213 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1214 "last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1215 "content" => array("type" => "mediumtext"),
1216 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1219 "PRIMARY" => array("id"),
1220 "cid" => array("cid"),
1221 "created" => array("created"),
1222 "last" => array("last"),
1223 "network" => array("network"),
1224 "batch" => array("batch"),
1227 $database["register"] = array(
1229 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1230 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1231 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1232 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1233 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1234 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1237 "PRIMARY" => array("id"),
1240 $database["search"] = array(
1242 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1243 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1244 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1247 "PRIMARY" => array("id"),
1248 "uid" => array("uid"),
1249 "term" => array("term"),
1252 $database["session"] = array(
1254 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1255 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1256 "data" => array("type" => "text"),
1257 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1260 "PRIMARY" => array("id"),
1261 "sid" => array("sid"),
1262 "expire" => array("expire"),
1265 $database["sign"] = array(
1267 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1268 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1269 "signed_text" => array("type" => "mediumtext"),
1270 "signature" => array("type" => "text"),
1271 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1274 "PRIMARY" => array("id"),
1275 "iid" => array("iid"),
1278 $database["spam"] = array(
1280 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1281 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1282 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1283 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1284 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1285 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1288 "PRIMARY" => array("id"),
1289 "uid" => array("uid"),
1290 "spam" => array("spam"),
1291 "ham" => array("ham"),
1292 "term" => array("term"),
1295 $database["term"] = array(
1297 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1298 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1299 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1300 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1301 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1302 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1303 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1304 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1305 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1306 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1307 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1308 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1311 "PRIMARY" => array("tid"),
1312 "oid_otype_type_term" => array("oid","otype","type","term"),
1313 "uid_term_tid" => array("uid","term","tid"),
1314 "type_term" => array("type","term"),
1315 "uid_otype_type_term_global_created" => array("uid","otype","type","term","global","created"),
1316 "otype_type_term_tid" => array("otype","type","term","tid"),
1317 "guid" => array("guid"),
1320 $database["thread"] = array(
1322 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1323 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1324 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1325 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1326 "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1327 "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1328 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1329 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1330 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1331 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1332 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1333 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1334 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1335 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1336 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1337 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1338 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1339 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1340 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1341 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1342 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1343 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1344 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1345 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1346 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1347 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1350 "PRIMARY" => array("iid"),
1351 "created" => array("created"),
1352 "commented" => array("commented"),
1353 "uid_network_commented" => array("uid","network","commented"),
1354 "uid_network_created" => array("uid","network","created"),
1355 "uid_contactid_commented" => array("uid","contact-id","commented"),
1356 "uid_contactid_created" => array("uid","contact-id","created"),
1357 "uid_gcontactid_commented" => array("uid","gcontact-id","commented"),
1358 "uid_gcontactid_created" => array("uid","gcontact-id","created"),
1359 "wall_private_received" => array("wall","private","received"),
1360 "uid_created" => array("uid","created"),
1361 "uid_commented" => array("uid","commented"),
1364 $database["tokens"] = array(
1366 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1367 "secret" => array("type" => "text"),
1368 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1369 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1370 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1371 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1374 "PRIMARY" => array("id"),
1377 $database["user"] = array(
1379 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1380 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1381 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1382 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1383 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1384 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1385 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1386 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1387 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1388 "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1389 "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1390 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1391 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1392 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1393 "pubkey" => array("type" => "text"),
1394 "prvkey" => array("type" => "text"),
1395 "spubkey" => array("type" => "text"),
1396 "sprvkey" => array("type" => "text"),
1397 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1398 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1399 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1400 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1401 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1402 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1403 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1404 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1405 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1406 "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1407 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1408 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1409 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1410 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1411 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1412 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1413 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1414 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1415 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1416 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1417 "allow_cid" => array("type" => "mediumtext"),
1418 "allow_gid" => array("type" => "mediumtext"),
1419 "deny_cid" => array("type" => "mediumtext"),
1420 "deny_gid" => array("type" => "mediumtext"),
1421 "openidserver" => array("type" => "text"),
1424 "PRIMARY" => array("uid"),
1425 "nickname" => array("nickname"),
1428 $database["userd"] = array(
1430 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1431 "username" => array("type" => "varchar(255)", "not null" => "1"),
1434 "PRIMARY" => array("id"),
1435 "username" => array("username"),
1438 $database["workerqueue"] = array(
1440 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1441 "parameter" => array("type" => "text"),
1442 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1443 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1444 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1445 "executed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1448 "PRIMARY" => array("id"),
1449 "created" => array("created"),
1458 * run from command line
1460 function dbstructure_run(&$argv, &$argc) {
1468 @include(".htconfig.php");
1469 require_once("include/dba.php");
1470 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1471 unset($db_host, $db_user, $db_pass, $db_data);
1477 update_structure(true, true);
1478 set_config('system','build',DB_UPDATE_VERSION);
1481 print_structure(db_definition());
1488 echo $argv[0]." <command>\n";
1491 echo "update update database schema\n";
1492 echo "dumpsql dump database schema\n";
1500 if (array_search(__file__,get_included_files())===0){
1501 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);