4 use Friendica\Core\Config;
6 require_once "boot.php";
7 require_once "include/text.php";
9 define('NEW_UPDATE_ROUTINE_VERSION', 1170);
11 const DB_UPDATE_NOT_CHECKED = 0; // Database check wasn't executed before
12 const DB_UPDATE_SUCCESSFUL = 1; // Database check was successful
13 const DB_UPDATE_FAILED = 2; // Database check failed
16 * Converts all tables from MyISAM to InnoDB
18 function convert_to_innodb() {
21 $r = q("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `engine` = 'MyISAM' AND `table_schema` = '%s'",
22 dbesc($db->database_name()));
24 if (!dbm::is_result($r)) {
25 echo t('There are no tables on MyISAM.')."\n";
29 foreach ($r AS $table) {
30 $sql = sprintf("ALTER TABLE `%s` engine=InnoDB;", dbesc($table['TABLE_NAME']));
33 $result = @$db->q($sql);
34 if (!dbm::is_result($result)) {
35 print_update_error($db, $sql);
41 * send the email and do what is needed to do on update fails
43 * @param update_id (int) number of failed update
44 * @param error_message (str) error message
46 function update_fail($update_id, $error_message) {
47 //send the administrators an e-mail
48 $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
49 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
54 if (!dbm::is_result($adminlist)) {
55 logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_WARNING);
61 // every admin could had different language
62 foreach ($adminlist as $admin) {
63 $lang = (($admin['language'])?$admin['language']:'en');
66 $preamble = deindent(t("
67 The friendica developers released update %s recently,
68 but when I tried to install it, something went terribly wrong.
69 This needs to be fixed soon and I can't do it alone. Please contact a
70 friendica developer if you can not help me on your own. My database might be invalid."));
71 $body = t("The error message is\n[pre]%s[/pre]");
72 $preamble = sprintf($preamble, $update_id);
73 $body = sprintf($body, $error_message);
76 'type' => "SYSTEM_EMAIL",
77 'to_email' => $admin['email'],
78 'preamble' => $preamble,
88 $email_tpl = get_intltext_template("update_fail_eml.tpl");
89 $email_msg = replace_macros($email_tpl, array(
90 '$sitename' => $a->config['sitename'],
91 '$siteurl' => App::get_baseurl(),
92 '$update' => DB_UPDATE_VERSION,
93 '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
95 $subject=sprintf(t('Update Error at %s'), App::get_baseurl());
96 require_once('include/email.php');
97 $subject = email_header_encode($subject,'UTF-8');
98 mail($a->config['admin_email'], $subject, $email_msg,
99 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
100 .'Content-type: text/plain; charset=UTF-8'."\n"
101 .'Content-transfer-encoding: 8bit');
104 logger("CRITICAL: Database structure update failed: ".$retval);
108 function table_structure($table) {
109 $structures = q("DESCRIBE `%s`", $table);
111 $full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table);
113 $indexes = q("SHOW INDEX FROM `%s`", $table);
115 $table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table);
117 if (dbm::is_result($table_status)) {
118 $table_status = $table_status[0];
120 $table_status = array();
123 $fielddata = array();
124 $indexdata = array();
126 if (dbm::is_result($indexes))
127 foreach ($indexes AS $index) {
128 if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
129 $indexdata[$index["Key_name"]] = array('UNIQUE');
132 $column = $index["Column_name"];
133 // On utf8mb4 a varchar index can only have a length of 191
134 // The "show index" command sometimes returns this value although this value wasn't added manually.
135 // Because we don't want to add this number to every index, we ignore bigger numbers
136 if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 191) OR ($index["Key_name"] == "PRIMARY"))) {
137 $column .= "(".$index["Sub_part"].")";
140 $indexdata[$index["Key_name"]][] = $column;
142 if (dbm::is_result($structures)) {
143 foreach ($structures AS $field) {
144 $fielddata[$field["Field"]]["type"] = $field["Type"];
145 if ($field["Null"] == "NO") {
146 $fielddata[$field["Field"]]["not null"] = true;
149 if (isset($field["Default"])) {
150 $fielddata[$field["Field"]]["default"] = $field["Default"];
153 if ($field["Extra"] != "") {
154 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
157 if ($field["Key"] == "PRI") {
158 $fielddata[$field["Field"]]["primary"] = true;
162 if (dbm::is_result($full_columns)) {
163 foreach ($full_columns AS $column) {
164 $fielddata[$column["Field"]]["Collation"] = $column["Collation"];
168 return array("fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status);
171 function print_structure($database) {
172 echo "-- ------------------------------------------\n";
173 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
174 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
175 echo "-- ------------------------------------------\n\n\n";
176 foreach ($database AS $name => $structure) {
178 echo "-- TABLE $name\n";
180 db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
187 * @brief Print out database error messages
189 * @param object $db Database object
190 * @param string $message Message to be added to the error message
192 * @return string Error message
194 function print_update_error($db, $message) {
195 echo sprintf(t("\nError %d occurred during database update:\n%s\n"),
196 $db->errorno, $db->error);
198 return t('Errors encountered performing database changes: ').$message.EOL;
201 function update_structure($verbose, $action, $tables=null, $definition=null) {
205 Config::set('system', 'maintenance', 1);
206 Config::set('system', 'maintenance_reason', sprintf(t(': Database update'), dbm::date().' '.date('e')));
211 logger('updating structure', LOGGER_DEBUG);
213 // Get the current structure
216 if (is_null($tables)) {
217 $tables = q("SHOW TABLES");
220 if (dbm::is_result($tables)) {
221 foreach ($tables AS $table) {
222 $table = current($table);
224 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
225 $database[$table] = table_structure($table);
229 // Get the definition
230 if (is_null($definition)) {
231 $definition = db_definition();
234 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
235 if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
236 !(strpos($db->server_info(), 'MariaDB') !== false)) {
243 foreach ($definition AS $name => $structure) {
244 $is_new_table = False;
247 if (!isset($database[$name])) {
248 $r = db_create_table($name, $structure["fields"], $verbose, $action, $structure['indexes']);
249 if (!dbm::is_result($r)) {
250 $errors .= print_update_error($db, $name);
252 $is_new_table = True;
257 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
258 if (isset($database[$name]["indexes"][$indexname])) {
259 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
261 $current_index_definition = "__NOT_SET__";
263 $new_index_definition = implode(",",$fieldnames);
264 if ($current_index_definition != $new_index_definition) {
265 if ($fieldnames[0] == "UNIQUE") {
268 $temp_name = "temp-".$name;
275 * Drop the index if it isn't present in the definition
276 * or the definition differ from current status
277 * and index name doesn't start with "local_"
279 foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
280 $current_index_definition = implode(",",$fieldnames);
281 if (isset($structure["indexes"][$indexname])) {
282 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
284 $new_index_definition = "__NOT_SET__";
286 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
287 $sql2=db_drop_index($indexname);
289 $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
295 // Compare the field structure field by field
296 foreach ($structure["fields"] AS $fieldname => $parameters) {
297 if (!isset($database[$name]["fields"][$fieldname])) {
298 $sql2=db_add_table_field($fieldname, $parameters);
300 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
305 // Compare the field definition
306 $field_definition = $database[$name]["fields"][$fieldname];
308 // Remove the relation data that is used for the referential integrity
309 unset($parameters['relation']);
311 // We change the collation after the indexes had been changed.
312 // This is done to avoid index length problems.
313 // So here we always ensure that there is no need to change it.
314 unset($parameters['Collation']);
315 unset($field_definition['Collation']);
317 $current_field_definition = implode(",", $field_definition);
318 $new_field_definition = implode(",", $parameters);
319 if ($current_field_definition != $new_field_definition) {
320 $sql2 = db_modify_table_field($fieldname, $parameters);
322 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
332 * Create the index if the index don't exists in database
333 * or the definition differ from the current status.
334 * Don't create keys if table is new
336 if (!$is_new_table) {
337 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
338 if (isset($database[$name]["indexes"][$indexname])) {
339 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
341 $current_index_definition = "__NOT_SET__";
343 $new_index_definition = implode(",",$fieldnames);
344 if ($current_index_definition != $new_index_definition) {
345 $sql2 = db_create_index($indexname, $fieldnames);
347 // Fetch the "group by" fields for unique indexes
348 if ($fieldnames[0] == "UNIQUE") {
349 $group_by = db_group_by($indexname, $fieldnames);
353 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
361 if (isset($database[$name]["table_status"]["Collation"])) {
362 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
363 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
366 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
377 // Now have a look at the field collations
378 // Compare the field structure field by field
379 foreach ($structure["fields"] AS $fieldname => $parameters) {
380 // Compare the field definition
381 $field_definition = $database[$name]["fields"][$fieldname];
383 // Define the default collation if not given
384 if (!isset($parameters['Collation']) AND !is_null($field_definition['Collation'])) {
385 $parameters['Collation'] = 'utf8mb4_general_ci';
387 $parameters['Collation'] = null;
390 if ($field_definition['Collation'] != $parameters['Collation']) {
391 $sql2 = db_modify_table_field($fieldname, $parameters);
392 if (($sql3 == "") OR (substr($sql3, -2, 2) == "; ")) {
393 $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
402 if (substr($sql3, -2, 2) != "; ") {
407 if ($is_unique && $ignore == '') {
408 foreach ($structure['fields'] AS $fieldname => $parameters) {
409 $field_list .= 'ANY_VALUE(`' . $fieldname . '`),';
411 $field_list = rtrim($field_list, ',');
415 // Ensure index conversion to unique removes duplicates
418 echo "SET session old_alter_table=1;\n";
420 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
428 echo "SET session old_alter_table=0;\n";
430 echo "INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";\n";
431 echo "DROP TABLE `".$name."`;\n";
432 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
438 Config::set('system', 'maintenance_reason', sprintf(t('%s: updating %s table.'), dbm::date().' '.date('e'), $name));
440 // Ensure index conversion to unique removes duplicates
443 $db->q("SET session old_alter_table=1;");
445 $r = $db->q("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
446 if (!dbm::is_result($r)) {
447 $errors .= print_update_error($db, $sql3);
454 if (!dbm::is_result($r)) {
455 $errors .= print_update_error($db, $sql3);
459 $db->q("SET session old_alter_table=0;");
461 $r = $db->q("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
462 if (!dbm::is_result($r)) {
463 $errors .= print_update_error($db, $sql3);
466 $r = $db->q("DROP TABLE `".$name."`;");
467 if (!dbm::is_result($r)) {
468 $errors .= print_update_error($db, $sql3);
471 $r = $db->q("RENAME TABLE `".$temp_name."` TO `".$name."`;");
472 if (!dbm::is_result($r)) {
473 $errors .= print_update_error($db, $sql3);
483 Config::set('system', 'maintenance', 0);
484 Config::set('system', 'maintenance_reason', '');
488 Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
490 Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
496 function db_field_command($parameters, $create = true) {
497 $fieldstruct = $parameters["type"];
499 if (!is_null($parameters["Collation"])) {
500 $fieldstruct .= " COLLATE ".$parameters["Collation"];
503 if ($parameters["not null"])
504 $fieldstruct .= " NOT NULL";
506 if (isset($parameters["default"])) {
507 if (strpos(strtolower($parameters["type"]),"int")!==false) {
508 $fieldstruct .= " DEFAULT ".$parameters["default"];
510 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
513 if ($parameters["extra"] != "")
514 $fieldstruct .= " ".$parameters["extra"];
516 /*if (($parameters["primary"] != "") AND $create)
517 $fieldstruct .= " PRIMARY KEY";*/
519 return($fieldstruct);
522 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
530 $primary_keys = array();
531 foreach ($fields AS $fieldname => $field) {
532 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
533 if (x($field,'primary') and $field['primary']!='') {
534 $primary_keys[] = $fieldname;
538 if (!is_null($indexes)) {
539 foreach ($indexes AS $indexname => $fieldnames) {
540 $sql_index = db_create_index($indexname, $fieldnames, "");
541 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
545 $sql = implode(",\n\t", $sql_rows);
547 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
557 function db_add_table_field($fieldname, $parameters) {
558 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
562 function db_modify_table_field($fieldname, $parameters) {
563 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
567 function db_drop_index($indexname) {
568 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
572 function db_create_index($indexname, $fieldnames, $method="ADD") {
574 $method = strtoupper(trim($method));
575 if ($method!="" && $method!="ADD") {
576 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
580 if ($fieldnames[0] == "UNIQUE") {
581 array_shift($fieldnames);
582 $method .= ' UNIQUE';
586 foreach ($fieldnames AS $fieldname) {
590 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
591 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
593 $names .= "`".dbesc($fieldname)."`";
597 if ($indexname == "PRIMARY") {
598 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
602 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
606 function db_group_by($indexname, $fieldnames) {
608 if ($fieldnames[0] != "UNIQUE") {
612 array_shift($fieldnames);
615 foreach ($fieldnames AS $fieldname) {
619 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
620 $names .= "`".dbesc($matches[1])."`";
622 $names .= "`".dbesc($fieldname)."`";
626 $sql = sprintf(" GROUP BY %s", $names);
630 function db_definition() {
634 $database["addon"] = array(
636 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
637 "name" => array("type" => "varchar(190)", "not null" => "1", "default" => ""),
638 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
639 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
640 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
641 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
642 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
645 "PRIMARY" => array("id"),
646 "name" => array("UNIQUE", "name"),
649 $database["attach"] = array(
651 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
652 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
653 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
654 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
655 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
656 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
657 "data" => array("type" => "longblob", "not null" => "1"),
658 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
659 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
660 "allow_cid" => array("type" => "mediumtext"),
661 "allow_gid" => array("type" => "mediumtext"),
662 "deny_cid" => array("type" => "mediumtext"),
663 "deny_gid" => array("type" => "mediumtext"),
666 "PRIMARY" => array("id"),
669 $database["auth_codes"] = array(
671 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
672 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
673 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
674 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
675 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
678 "PRIMARY" => array("id"),
681 $database["cache"] = array(
683 "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
684 "v" => array("type" => "mediumtext"),
685 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
686 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
689 "PRIMARY" => array("k"),
690 "expire_mode_updated" => array("expire_mode", "updated"),
693 $database["challenge"] = array(
695 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
696 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
697 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
698 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
699 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
700 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
703 "PRIMARY" => array("id"),
706 $database["clients"] = array(
708 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
709 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
710 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
711 "name" => array("type" => "text"),
712 "icon" => array("type" => "text"),
713 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
716 "PRIMARY" => array("client_id"),
719 $database["config"] = array(
721 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
722 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
723 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
724 "v" => array("type" => "mediumtext"),
727 "PRIMARY" => array("id"),
728 "cat_k" => array("UNIQUE", "cat", "k"),
731 $database["contact"] = array(
733 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
734 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
735 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
736 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
737 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
738 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
739 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
740 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
741 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
742 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
743 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
744 "about" => array("type" => "text"),
745 "keywords" => array("type" => "text"),
746 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
747 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
748 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
749 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
750 "photo" => array("type" => "text"),
751 "thumb" => array("type" => "text"),
752 "micro" => array("type" => "text"),
753 "site-pubkey" => array("type" => "text"),
754 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
755 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
756 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
757 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
758 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
759 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
760 "pubkey" => array("type" => "text"),
761 "prvkey" => array("type" => "text"),
762 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
763 "request" => array("type" => "text"),
764 "notify" => array("type" => "text"),
765 "poll" => array("type" => "text"),
766 "confirm" => array("type" => "text"),
767 "poco" => array("type" => "text"),
768 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
769 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
770 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
771 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
772 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
773 "last-update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
774 "success_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
775 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
776 "name-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
777 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
778 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
779 "term-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
780 "last-item" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
781 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
782 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
783 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
784 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
785 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
786 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
787 "contact-type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
788 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
789 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
790 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
791 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
792 "reason" => array("type" => "text"),
793 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
794 "info" => array("type" => "mediumtext"),
795 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
796 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
797 "bd" => array("type" => "date", "not null" => "1", "default" => "0001-01-01"),
798 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
799 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
800 "ffi_keyword_blacklist" => array("type" => "text"),
803 "PRIMARY" => array("id"),
804 "uid_name" => array("uid", "name(190)"),
805 "self_uid" => array("self", "uid"),
806 "alias_uid" => array("alias(32)", "uid"),
807 "pending_uid" => array("pending", "uid"),
808 "blocked_uid" => array("blocked", "uid"),
809 "uid_rel_network_poll" => array("uid", "rel", "network(4)", "poll(64)", "archive"),
810 "uid_network_batch" => array("uid", "network(4)", "batch(64)"),
811 "addr_uid" => array("addr(32)", "uid"),
812 "nurl_uid" => array("nurl(32)", "uid"),
813 "nick_uid" => array("nick(32)", "uid"),
814 "dfrn-id" => array("dfrn-id"),
815 "issued-id" => array("issued-id"),
818 $database["conv"] = array(
820 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
821 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
822 "recips" => array("type" => "text"),
823 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
824 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
825 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
826 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
827 "subject" => array("type" => "text"),
830 "PRIMARY" => array("id"),
831 "uid" => array("uid"),
834 $database["conversation"] = array(
836 "item-uri" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
837 "reply-to-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
838 "conversation-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
839 "conversation-href" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
840 "protocol" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
841 "source" => array("type" => "mediumtext"),
842 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
845 "PRIMARY" => array("item-uri"),
846 "conversation-uri" => array("conversation-uri"),
849 $database["event"] = array(
851 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
852 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
853 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
854 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
855 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
856 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
857 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
858 "start" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
859 "finish" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
860 "summary" => array("type" => "text"),
861 "desc" => array("type" => "text"),
862 "location" => array("type" => "text"),
863 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
864 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
865 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
866 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
867 "allow_cid" => array("type" => "mediumtext"),
868 "allow_gid" => array("type" => "mediumtext"),
869 "deny_cid" => array("type" => "mediumtext"),
870 "deny_gid" => array("type" => "mediumtext"),
873 "PRIMARY" => array("id"),
874 "uid_start" => array("uid", "start"),
877 $database["fcontact"] = array(
879 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
880 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
881 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
882 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
883 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
884 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
885 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
886 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
887 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
888 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
889 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
890 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
891 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
892 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
893 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
894 "pubkey" => array("type" => "text"),
895 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
898 "PRIMARY" => array("id"),
899 "addr" => array("addr(32)"),
900 "url" => array("UNIQUE", "url(190)"),
903 $database["ffinder"] = array(
905 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
906 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
907 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
908 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
911 "PRIMARY" => array("id"),
914 $database["fserver"] = array(
916 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
917 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
918 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
919 "key" => array("type" => "text"),
922 "PRIMARY" => array("id"),
923 "server" => array("server(32)"),
926 $database["fsuggest"] = array(
928 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
929 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
930 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
931 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
932 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
933 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
934 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
935 "note" => array("type" => "text"),
936 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
939 "PRIMARY" => array("id"),
942 $database["gcign"] = array(
944 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
945 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
946 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
949 "PRIMARY" => array("id"),
950 "uid" => array("uid"),
951 "gcid" => array("gcid"),
954 $database["gcontact"] = array(
956 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
957 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
958 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
959 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
960 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
961 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
962 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
963 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
964 "updated" => array("type" => "datetime", "default" => NULL_DATE),
965 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
966 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
967 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
968 "about" => array("type" => "text"),
969 "keywords" => array("type" => "text"),
970 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
971 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
972 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
973 "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
974 "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
975 "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
976 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
977 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
978 "notify" => array("type" => "text"),
979 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
980 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
981 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
984 "PRIMARY" => array("id"),
985 "nurl" => array("UNIQUE", "nurl(190)"),
986 "name" => array("name(64)"),
987 "nick" => array("nick(32)"),
988 "addr" => array("addr(64)"),
989 "hide_network_updated" => array("hide", "network(4)", "updated"),
990 "updated" => array("updated"),
993 $database["glink"] = array(
995 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
996 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
997 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
998 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
999 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1000 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1003 "PRIMARY" => array("id"),
1004 "cid_uid_gcid_zcid" => array("UNIQUE", "cid","uid","gcid","zcid"),
1005 "gcid" => array("gcid"),
1008 $database["group"] = array(
1010 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1011 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1012 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1013 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1014 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1017 "PRIMARY" => array("id"),
1018 "uid" => array("uid"),
1021 $database["group_member"] = array(
1023 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1024 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1025 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("group" => "id")),
1026 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1029 "PRIMARY" => array("id"),
1030 "contactid" => array("contact-id"),
1031 "gid_contactid" => array("gid", "contact-id"),
1032 "uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"),
1035 $database["gserver"] = array(
1037 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1038 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1039 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1040 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1041 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1042 "info" => array("type" => "text"),
1043 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1044 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1045 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1046 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1047 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1048 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1049 "last_poco_query" => array("type" => "datetime", "default" => NULL_DATE),
1050 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
1051 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
1054 "PRIMARY" => array("id"),
1055 "nurl" => array("UNIQUE", "nurl(190)"),
1058 $database["hook"] = array(
1060 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1061 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1062 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1063 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1064 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1067 "PRIMARY" => array("id"),
1068 "hook_file_function" => array("UNIQUE", "hook(50)","file(80)","function(60)"),
1071 $database["intro"] = array(
1073 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1074 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1075 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
1076 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1077 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1078 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1079 "note" => array("type" => "text"),
1080 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1081 "datetime" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1082 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1083 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1086 "PRIMARY" => array("id"),
1089 $database["item"] = array(
1091 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => array("thread" => "iid")),
1092 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1093 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1094 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1095 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1096 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1097 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1098 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1099 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1100 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1101 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1102 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1103 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1104 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1105 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1106 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1107 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1108 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1109 "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1110 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1111 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1112 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1113 "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1114 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1115 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1116 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1117 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1118 "body" => array("type" => "mediumtext"),
1119 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1120 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1121 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1122 "object" => array("type" => "text"),
1123 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1124 "target" => array("type" => "text"),
1125 "postopts" => array("type" => "text"),
1126 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1127 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1128 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("event" => "id")),
1129 "tag" => array("type" => "mediumtext"),
1130 "attach" => array("type" => "mediumtext"),
1131 "inform" => array("type" => "mediumtext"),
1132 "file" => array("type" => "mediumtext"),
1133 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1134 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1135 "allow_cid" => array("type" => "mediumtext"),
1136 "allow_gid" => array("type" => "mediumtext"),
1137 "deny_cid" => array("type" => "mediumtext"),
1138 "deny_gid" => array("type" => "mediumtext"),
1139 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1140 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1141 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1142 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1143 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1144 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1145 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1146 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1147 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1148 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1149 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1150 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
1151 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1152 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1153 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1154 "rendered-html" => array("type" => "mediumtext"),
1155 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1158 "PRIMARY" => array("id"),
1159 "guid" => array("guid"),
1160 "uri" => array("uri"),
1161 "parent" => array("parent"),
1162 "parent-uri" => array("parent-uri"),
1163 "extid" => array("extid"),
1164 "uid_id" => array("uid","id"),
1165 "uid_contactid_id" => array("uid","contact-id","id"),
1166 "uid_created" => array("uid","created"),
1167 "uid_unseen_contactid" => array("uid","unseen","contact-id"),
1168 "uid_network_received" => array("uid","network(4)","received"),
1169 "uid_network_commented" => array("uid","network(4)","commented"),
1170 "uid_thrparent" => array("uid","thr-parent(190)"),
1171 "uid_parenturi" => array("uid","parent-uri(190)"),
1172 "uid_contactid_created" => array("uid","contact-id","created"),
1173 "authorid_created" => array("author-id","created"),
1174 "ownerid" => array("owner-id"),
1175 "uid_uri" => array("uid", "uri(190)"),
1176 "resource-id" => array("resource-id"),
1177 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
1178 "uid_type_changed" => array("uid","type(190)","changed"),
1179 "contactid_verb" => array("contact-id","verb(190)"),
1180 "deleted_changed" => array("deleted","changed"),
1181 "uid_wall_changed" => array("uid","wall","changed"),
1182 "uid_eventid" => array("uid","event-id"),
1183 "uid_authorlink" => array("uid","author-link(190)"),
1184 "uid_ownerlink" => array("uid","owner-link(190)"),
1187 $database["item_id"] = array(
1189 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1190 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1191 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1192 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1193 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1196 "PRIMARY" => array("id"),
1197 "uid" => array("uid"),
1198 "sid" => array("sid"),
1199 "service" => array("service(32)"),
1200 "iid" => array("iid"),
1203 $database["locks"] = array(
1205 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1206 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1207 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1208 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1211 "PRIMARY" => array("id"),
1214 $database["mail"] = array(
1216 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1217 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1218 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1219 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1220 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1221 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1222 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => array("contact" => "id")),
1223 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("conv" => "id")),
1224 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1225 "body" => array("type" => "mediumtext"),
1226 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1227 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1228 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1229 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1230 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1231 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1232 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1235 "PRIMARY" => array("id"),
1236 "uid_seen" => array("uid", "seen"),
1237 "convid" => array("convid"),
1238 "uri" => array("uri(64)"),
1239 "parent-uri" => array("parent-uri(64)"),
1240 "contactid" => array("contact-id"),
1243 $database["mailacct"] = array(
1245 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1246 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1247 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1248 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1249 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1250 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1251 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1252 "pass" => array("type" => "text"),
1253 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1254 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1255 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1256 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1257 "last_check" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1260 "PRIMARY" => array("id"),
1263 $database["manage"] = array(
1265 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1266 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1267 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1270 "PRIMARY" => array("id"),
1271 "uid_mid" => array("UNIQUE", "uid","mid"),
1274 $database["notify"] = array(
1276 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1277 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1278 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1279 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1280 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1281 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1282 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1283 "msg" => array("type" => "mediumtext"),
1284 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1285 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1286 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1287 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1288 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1289 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1290 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1291 "name_cache" => array("type" => "tinytext"),
1292 "msg_cache" => array("type" => "mediumtext")
1295 "PRIMARY" => array("id"),
1296 "hash_uid" => array("hash", "uid"),
1297 "seen_uid_date" => array("seen", "uid", "date"),
1298 "uid_date" => array("uid", "date"),
1299 "uid_type_link" => array("uid", "type", "link(190)"),
1302 $database["notify-threads"] = array(
1304 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1305 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("notify" => "id")),
1306 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1307 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1308 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1311 "PRIMARY" => array("id"),
1314 $database["oembed"] = array(
1316 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1317 "content" => array("type" => "mediumtext"),
1318 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1321 "PRIMARY" => array("url"),
1322 "created" => array("created"),
1325 $database["parsed_url"] = array(
1327 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1328 "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1329 "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1330 "content" => array("type" => "mediumtext"),
1331 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1334 "PRIMARY" => array("url", "guessing", "oembed"),
1335 "created" => array("created"),
1338 $database["pconfig"] = array(
1340 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1341 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1342 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1343 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1344 "v" => array("type" => "mediumtext"),
1347 "PRIMARY" => array("id"),
1348 "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
1351 $database["photo"] = array(
1353 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1354 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1355 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1356 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1357 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1358 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1359 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1360 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1361 "desc" => array("type" => "text"),
1362 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1363 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1364 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1365 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1366 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1367 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1368 "data" => array("type" => "mediumblob", "not null" => "1"),
1369 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1370 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1371 "allow_cid" => array("type" => "mediumtext"),
1372 "allow_gid" => array("type" => "mediumtext"),
1373 "deny_cid" => array("type" => "mediumtext"),
1374 "deny_gid" => array("type" => "mediumtext"),
1377 "PRIMARY" => array("id"),
1378 "contactid" => array("contact-id"),
1379 "uid_contactid" => array("uid", "contact-id"),
1380 "uid_profile" => array("uid", "profile"),
1381 "uid_album_scale_created" => array("uid", "album(32)", "scale", "created"),
1382 "uid_album_resource-id_created" => array("uid", "album(32)", "resource-id(64)", "created"),
1383 "resource-id" => array("resource-id(64)"),
1386 $database["poll"] = array(
1388 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1389 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1390 "q0" => array("type" => "text"),
1391 "q1" => array("type" => "text"),
1392 "q2" => array("type" => "text"),
1393 "q3" => array("type" => "text"),
1394 "q4" => array("type" => "text"),
1395 "q5" => array("type" => "text"),
1396 "q6" => array("type" => "text"),
1397 "q7" => array("type" => "text"),
1398 "q8" => array("type" => "text"),
1399 "q9" => array("type" => "text"),
1402 "PRIMARY" => array("id"),
1403 "uid" => array("uid"),
1406 $database["poll_result"] = array(
1408 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1409 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("poll" => "id")),
1410 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1413 "PRIMARY" => array("id"),
1414 "poll_id" => array("poll_id"),
1415 "choice" => array("choice"),
1418 $database["process"] = array(
1420 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
1421 "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
1422 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1425 "PRIMARY" => array("pid"),
1426 "command" => array("command"),
1429 $database["profile"] = array(
1431 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1432 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1433 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1434 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1435 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1436 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1437 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1438 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
1439 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1440 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1441 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1442 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1443 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1444 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1445 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1446 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1447 "with" => array("type" => "text"),
1448 "howlong" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1449 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1450 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1451 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1452 "pub_keywords" => array("type" => "text"),
1453 "prv_keywords" => array("type" => "text"),
1454 "likes" => array("type" => "text"),
1455 "dislikes" => array("type" => "text"),
1456 "about" => array("type" => "text"),
1457 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1458 "music" => array("type" => "text"),
1459 "book" => array("type" => "text"),
1460 "tv" => array("type" => "text"),
1461 "film" => array("type" => "text"),
1462 "interest" => array("type" => "text"),
1463 "romance" => array("type" => "text"),
1464 "work" => array("type" => "text"),
1465 "education" => array("type" => "text"),
1466 "contact" => array("type" => "text"),
1467 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1468 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1469 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1470 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1471 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1472 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1475 "PRIMARY" => array("id"),
1476 "uid_is-default" => array("uid", "is-default"),
1479 $database["profile_check"] = array(
1481 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1482 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1483 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1484 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1485 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1486 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1489 "PRIMARY" => array("id"),
1492 $database["push_subscriber"] = array(
1494 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1495 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1496 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1497 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1498 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1499 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1500 "last_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1501 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1504 "PRIMARY" => array("id"),
1507 $database["queue"] = array(
1509 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1510 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1511 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1512 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1513 "last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1514 "content" => array("type" => "mediumtext"),
1515 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1518 "PRIMARY" => array("id"),
1519 "cid" => array("cid"),
1520 "created" => array("created"),
1521 "last" => array("last"),
1522 "network" => array("network"),
1523 "batch" => array("batch"),
1526 $database["register"] = array(
1528 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1529 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1530 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1531 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1532 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1533 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1534 "note" => array("type" => "text"),
1537 "PRIMARY" => array("id"),
1540 $database["search"] = array(
1542 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1543 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1544 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1547 "PRIMARY" => array("id"),
1548 "uid" => array("uid"),
1551 $database["session"] = array(
1553 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1554 "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1555 "data" => array("type" => "text"),
1556 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1559 "PRIMARY" => array("id"),
1560 "sid" => array("sid(64)"),
1561 "expire" => array("expire"),
1564 $database["sign"] = array(
1566 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1567 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1568 "signed_text" => array("type" => "mediumtext"),
1569 "signature" => array("type" => "text"),
1570 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1573 "PRIMARY" => array("id"),
1574 "iid" => array("iid"),
1577 $database["spam"] = array(
1579 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1580 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1581 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1582 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1583 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1584 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1587 "PRIMARY" => array("id"),
1588 "uid" => array("uid"),
1589 "spam" => array("spam"),
1590 "ham" => array("ham"),
1591 "term" => array("term"),
1594 $database["term"] = array(
1596 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1597 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1598 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1599 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1600 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1601 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1602 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1603 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1604 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1605 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1606 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1607 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1610 "PRIMARY" => array("tid"),
1611 "oid_otype_type_term" => array("oid","otype","type","term(32)"),
1612 "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"),
1613 "uid_otype_type_url" => array("uid","otype","type","url(64)"),
1614 "guid" => array("guid(64)"),
1617 $database["thread"] = array(
1619 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => array("item" => "id")),
1620 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1621 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1622 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1623 "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1624 "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1625 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1626 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1627 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1628 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1629 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1630 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1631 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1632 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1633 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1634 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1635 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1636 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1637 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1638 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1639 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1640 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1641 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1642 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1643 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1644 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1647 "PRIMARY" => array("iid"),
1648 "uid_network_commented" => array("uid","network","commented"),
1649 "uid_network_created" => array("uid","network","created"),
1650 "uid_contactid_commented" => array("uid","contact-id","commented"),
1651 "uid_contactid_created" => array("uid","contact-id","created"),
1652 "contactid" => array("contact-id"),
1653 "ownerid" => array("owner-id"),
1654 "authorid" => array("author-id"),
1655 "uid_created" => array("uid","created"),
1656 "uid_commented" => array("uid","commented"),
1657 "uid_wall_created" => array("uid","wall","created"),
1660 $database["tokens"] = array(
1662 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1663 "secret" => array("type" => "text"),
1664 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
1665 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1666 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1667 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1670 "PRIMARY" => array("id"),
1673 $database["user"] = array(
1675 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1676 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1677 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1678 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1679 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1680 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1681 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1682 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1683 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1684 "register_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1685 "login_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1686 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1687 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1688 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1689 "pubkey" => array("type" => "text"),
1690 "prvkey" => array("type" => "text"),
1691 "spubkey" => array("type" => "text"),
1692 "sprvkey" => array("type" => "text"),
1693 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1694 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1695 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1696 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1697 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1698 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1699 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1700 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1701 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1702 "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1703 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1704 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1705 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1706 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1707 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1708 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1709 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1710 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1711 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1712 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1713 "allow_cid" => array("type" => "mediumtext"),
1714 "allow_gid" => array("type" => "mediumtext"),
1715 "deny_cid" => array("type" => "mediumtext"),
1716 "deny_gid" => array("type" => "mediumtext"),
1717 "openidserver" => array("type" => "text"),
1720 "PRIMARY" => array("uid"),
1721 "nickname" => array("nickname(32)"),
1724 $database["userd"] = array(
1726 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1727 "username" => array("type" => "varchar(255)", "not null" => "1"),
1730 "PRIMARY" => array("id"),
1731 "username" => array("username(32)"),
1734 $database["workerqueue"] = array(
1736 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1737 "parameter" => array("type" => "text"),
1738 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1739 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1740 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1741 "executed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1744 "PRIMARY" => array("id"),
1745 "pid" => array("pid"),
1746 "parameter" => array("parameter(64)"),
1747 "priority_created" => array("priority", "created"),
1756 * run from command line
1758 function dbstructure_run(&$argv, &$argc) {
1762 $a = new App(dirname(__DIR__));
1766 @include(".htconfig.php");
1767 require_once("include/dba.php");
1768 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1769 unset($db_host, $db_user, $db_pass, $db_data);
1775 update_structure(true, false);
1778 update_structure(true, true);
1780 $build = get_config('system','build');
1782 set_config('system', 'build', DB_UPDATE_VERSION);
1783 $build = DB_UPDATE_VERSION;
1786 $stored = intval($build);
1787 $current = intval(DB_UPDATE_VERSION);
1789 // run any left update_nnnn functions in update.php
1790 for ($x = $stored; $x < $current; $x ++) {
1791 $r = run_update_function($x);
1797 set_config('system','build',DB_UPDATE_VERSION);
1800 print_structure(db_definition());
1803 convert_to_innodb();
1810 echo $argv[0]." <command>\n";
1813 echo "dryrun show database update schema queries without running them\n";
1814 echo "update update database schema\n";
1815 echo "dumpsql dump database schema\n";
1816 echo "toinnodb convert all tables from MyISAM to InnoDB\n";
1821 if (array_search(__FILE__,get_included_files())===0) {
1822 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);