4 use Friendica\Core\Config;
6 require_once("boot.php");
7 require_once("include/text.php");
9 define('NEW_UPDATE_ROUTINE_VERSION', 1170);
12 * Converts all tables from MyISAM to InnoDB
14 function convert_to_innodb() {
17 $r = q("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `engine` = 'MyISAM' AND `table_schema` = '%s'",
18 dbesc($db->database_name()));
20 if (!dbm::is_result($r)) {
21 echo t('There are no tables on MyISAM.')."\n";
25 foreach ($r AS $table) {
26 $sql = sprintf("ALTER TABLE `%s` engine=InnoDB;", dbesc($table['TABLE_NAME']));
29 $result = @$db->q($sql);
30 if (!dbm::is_result($result)) {
31 print_update_error($db, $sql);
37 * send the email and do what is needed to do on update fails
39 * @param update_id (int) number of failed update
40 * @param error_message (str) error message
42 function update_fail($update_id, $error_message) {
43 //send the administrators an e-mail
44 $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
45 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
50 if (!dbm::is_result($adminlist)) {
51 logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_WARNING);
57 // every admin could had different language
58 foreach ($adminlist as $admin) {
59 $lang = (($admin['language'])?$admin['language']:'en');
62 $preamble = deindent(t("
63 The friendica developers released update %s recently,
64 but when I tried to install it, something went terribly wrong.
65 This needs to be fixed soon and I can't do it alone. Please contact a
66 friendica developer if you can not help me on your own. My database might be invalid."));
67 $body = t("The error message is\n[pre]%s[/pre]");
68 $preamble = sprintf($preamble, $update_id);
69 $body = sprintf($body, $error_message);
72 'type' => "SYSTEM_EMAIL",
73 'to_email' => $admin['email'],
74 'preamble' => $preamble,
84 $email_tpl = get_intltext_template("update_fail_eml.tpl");
85 $email_msg = replace_macros($email_tpl, array(
86 '$sitename' => $a->config['sitename'],
87 '$siteurl' => App::get_baseurl(),
88 '$update' => DB_UPDATE_VERSION,
89 '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
91 $subject=sprintf(t('Update Error at %s'), App::get_baseurl());
92 require_once('include/email.php');
93 $subject = email_header_encode($subject,'UTF-8');
94 mail($a->config['admin_email'], $subject, $email_msg,
95 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
96 .'Content-type: text/plain; charset=UTF-8'."\n"
97 .'Content-transfer-encoding: 8bit');
100 logger("CRITICAL: Database structure update failed: ".$retval);
104 function table_structure($table) {
105 $structures = q("DESCRIBE `%s`", $table);
107 $full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table);
109 $indexes = q("SHOW INDEX FROM `%s`", $table);
111 $table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table);
113 if (dbm::is_result($table_status)) {
114 $table_status = $table_status[0];
116 $table_status = array();
119 $fielddata = array();
120 $indexdata = array();
122 if (dbm::is_result($indexes))
123 foreach ($indexes AS $index) {
124 if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
125 $indexdata[$index["Key_name"]] = array('UNIQUE');
128 $column = $index["Column_name"];
129 // On utf8mb4 a varchar index can only have a length of 191
130 // The "show index" command sometimes returns this value although this value wasn't added manually.
131 // Because we don't want to add this number to every index, we ignore bigger numbers
132 if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 191) OR ($index["Key_name"] == "PRIMARY"))) {
133 $column .= "(".$index["Sub_part"].")";
136 $indexdata[$index["Key_name"]][] = $column;
138 if (dbm::is_result($structures)) {
139 foreach ($structures AS $field) {
140 $fielddata[$field["Field"]]["type"] = $field["Type"];
141 if ($field["Null"] == "NO") {
142 $fielddata[$field["Field"]]["not null"] = true;
145 if (isset($field["Default"])) {
146 $fielddata[$field["Field"]]["default"] = $field["Default"];
149 if ($field["Extra"] != "") {
150 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
153 if ($field["Key"] == "PRI") {
154 $fielddata[$field["Field"]]["primary"] = true;
158 if (dbm::is_result($full_columns)) {
159 foreach ($full_columns AS $column) {
160 $fielddata[$column["Field"]]["Collation"] = $column["Collation"];
164 return array("fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status);
167 function print_structure($database) {
168 echo "-- ------------------------------------------\n";
169 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
170 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
171 echo "-- ------------------------------------------\n\n\n";
172 foreach ($database AS $name => $structure) {
174 echo "-- TABLE $name\n";
176 db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
183 * @brief Print out database error messages
185 * @param object $db Database object
186 * @param string $message Message to be added to the error message
188 * @return string Error message
190 function print_update_error($db, $message) {
191 echo sprintf(t("\nError %d occurred during database update:\n%s\n"),
192 $db->errorno, $db->error);
194 return t('Errors encountered performing database changes: ').$message.EOL;
197 function update_structure($verbose, $action, $tables=null, $definition=null) {
201 Config::set('system', 'maintenance', 1);
202 Config::set('system', 'maintenance_reason', sprintf(t(': Database update'), dbm::date().' '.date('e')));
207 logger('updating structure', LOGGER_DEBUG);
209 // Get the current structure
212 if (is_null($tables)) {
213 $tables = q("SHOW TABLES");
216 if (dbm::is_result($tables)) {
217 foreach ($tables AS $table) {
218 $table = current($table);
220 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
221 $database[$table] = table_structure($table);
225 // Get the definition
226 if (is_null($definition)) {
227 $definition = db_definition();
230 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
231 if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
232 !(strpos($db->server_info(), 'MariaDB') !== false)) {
239 foreach ($definition AS $name => $structure) {
240 $is_new_table = False;
243 if (!isset($database[$name])) {
244 $r = db_create_table($name, $structure["fields"], $verbose, $action, $structure['indexes']);
245 if (!dbm::is_result($r)) {
246 $errors .= print_update_error($db, $name);
248 $is_new_table = True;
253 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
254 if (isset($database[$name]["indexes"][$indexname])) {
255 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
257 $current_index_definition = "__NOT_SET__";
259 $new_index_definition = implode(",",$fieldnames);
260 if ($current_index_definition != $new_index_definition) {
261 if ($fieldnames[0] == "UNIQUE") {
264 $temp_name = "temp-".$name;
271 * Drop the index if it isn't present in the definition
272 * or the definition differ from current status
273 * and index name doesn't start with "local_"
275 foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
276 $current_index_definition = implode(",",$fieldnames);
277 if (isset($structure["indexes"][$indexname])) {
278 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
280 $new_index_definition = "__NOT_SET__";
282 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
283 $sql2=db_drop_index($indexname);
285 $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
291 // Compare the field structure field by field
292 foreach ($structure["fields"] AS $fieldname => $parameters) {
293 if (!isset($database[$name]["fields"][$fieldname])) {
294 $sql2=db_add_table_field($fieldname, $parameters);
296 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
301 // Compare the field definition
302 $field_definition = $database[$name]["fields"][$fieldname];
304 // Remove the relation data that is used for the referential integrity
305 unset($parameters['relation']);
307 // We change the collation after the indexes had been changed.
308 // This is done to avoid index length problems.
309 // So here we always ensure that there is no need to change it.
310 unset($parameters['Collation']);
311 unset($field_definition['Collation']);
313 $current_field_definition = implode(",", $field_definition);
314 $new_field_definition = implode(",", $parameters);
315 if ($current_field_definition != $new_field_definition) {
316 $sql2 = db_modify_table_field($fieldname, $parameters);
318 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
328 * Create the index if the index don't exists in database
329 * or the definition differ from the current status.
330 * Don't create keys if table is new
332 if (!$is_new_table) {
333 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
334 if (isset($database[$name]["indexes"][$indexname])) {
335 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
337 $current_index_definition = "__NOT_SET__";
339 $new_index_definition = implode(",",$fieldnames);
340 if ($current_index_definition != $new_index_definition) {
341 $sql2 = db_create_index($indexname, $fieldnames);
343 // Fetch the "group by" fields for unique indexes
344 if ($fieldnames[0] == "UNIQUE") {
345 $group_by = db_group_by($indexname, $fieldnames);
349 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
357 if (isset($database[$name]["table_status"]["Collation"])) {
358 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
359 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
362 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
373 // Now have a look at the field collations
374 // Compare the field structure field by field
375 foreach ($structure["fields"] AS $fieldname => $parameters) {
376 // Compare the field definition
377 $field_definition = $database[$name]["fields"][$fieldname];
379 // Define the default collation if not given
380 if (!isset($parameters['Collation']) AND !is_null($field_definition['Collation'])) {
381 $parameters['Collation'] = 'utf8mb4_general_ci';
383 $parameters['Collation'] = null;
386 if ($field_definition['Collation'] != $parameters['Collation']) {
387 $sql2 = db_modify_table_field($fieldname, $parameters);
388 if (($sql3 == "") OR (substr($sql3, -2, 2) == "; ")) {
389 $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
398 if (substr($sql3, -2, 2) != "; ") {
403 // Ensure index conversion to unique removes duplicates
406 echo "SET session old_alter_table=1;\n";
408 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
416 echo "SET session old_alter_table=0;\n";
418 echo "INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";\n";
419 echo "DROP TABLE `".$name."`;\n";
420 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
426 Config::set('system', 'maintenance_reason', sprintf(t('%s: updating %s table.'), dbm::date().' '.date('e'), $name));
428 // Ensure index conversion to unique removes duplicates
431 $db->q("SET session old_alter_table=1;");
433 $r = $db->q("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
434 if (!dbm::is_result($r)) {
435 $errors .= print_update_error($db, $sql3);
442 if (!dbm::is_result($r)) {
443 $errors .= print_update_error($db, $sql3);
447 $db->q("SET session old_alter_table=0;");
449 $r = $db->q("INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";");
450 if (!dbm::is_result($r)) {
451 $errors .= print_update_error($db, $sql3);
454 $r = $db->q("DROP TABLE `".$name."`;");
455 if (!dbm::is_result($r)) {
456 $errors .= print_update_error($db, $sql3);
459 $r = $db->q("RENAME TABLE `".$temp_name."` TO `".$name."`;");
460 if (!dbm::is_result($r)) {
461 $errors .= print_update_error($db, $sql3);
471 Config::set('system', 'maintenance', 0);
472 Config::set('system', 'maintenance_reason', '');
478 function db_field_command($parameters, $create = true) {
479 $fieldstruct = $parameters["type"];
481 if (!is_null($parameters["Collation"])) {
482 $fieldstruct .= " COLLATE ".$parameters["Collation"];
485 if ($parameters["not null"])
486 $fieldstruct .= " NOT NULL";
488 if (isset($parameters["default"])) {
489 if (strpos(strtolower($parameters["type"]),"int")!==false) {
490 $fieldstruct .= " DEFAULT ".$parameters["default"];
492 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
495 if ($parameters["extra"] != "")
496 $fieldstruct .= " ".$parameters["extra"];
498 /*if (($parameters["primary"] != "") AND $create)
499 $fieldstruct .= " PRIMARY KEY";*/
501 return($fieldstruct);
504 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
512 $primary_keys = array();
513 foreach ($fields AS $fieldname => $field) {
514 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
515 if (x($field,'primary') and $field['primary']!='') {
516 $primary_keys[] = $fieldname;
520 if (!is_null($indexes)) {
521 foreach ($indexes AS $indexname => $fieldnames) {
522 $sql_index = db_create_index($indexname, $fieldnames, "");
523 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
527 $sql = implode(",\n\t", $sql_rows);
529 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
539 function db_add_table_field($fieldname, $parameters) {
540 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
544 function db_modify_table_field($fieldname, $parameters) {
545 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
549 function db_drop_index($indexname) {
550 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
554 function db_create_index($indexname, $fieldnames, $method="ADD") {
556 $method = strtoupper(trim($method));
557 if ($method!="" && $method!="ADD") {
558 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
562 if ($fieldnames[0] == "UNIQUE") {
563 array_shift($fieldnames);
564 $method .= ' UNIQUE';
568 foreach ($fieldnames AS $fieldname) {
572 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
573 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
575 $names .= "`".dbesc($fieldname)."`";
579 if ($indexname == "PRIMARY") {
580 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
584 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
588 function db_group_by($indexname, $fieldnames) {
590 if ($fieldnames[0] != "UNIQUE") {
594 array_shift($fieldnames);
597 foreach ($fieldnames AS $fieldname) {
601 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
602 $names .= "`".dbesc($matches[1])."`";
604 $names .= "`".dbesc($fieldname)."`";
608 $sql = sprintf(" GROUP BY %s", $names);
612 function db_definition() {
616 $database["addon"] = array(
618 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
619 "name" => array("type" => "varchar(190)", "not null" => "1", "default" => ""),
620 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
621 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
622 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
623 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
624 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
627 "PRIMARY" => array("id"),
628 "name" => array("UNIQUE", "name"),
631 $database["attach"] = array(
633 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
634 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
635 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
636 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
637 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
638 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
639 "data" => array("type" => "longblob", "not null" => "1"),
640 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
641 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
642 "allow_cid" => array("type" => "mediumtext"),
643 "allow_gid" => array("type" => "mediumtext"),
644 "deny_cid" => array("type" => "mediumtext"),
645 "deny_gid" => array("type" => "mediumtext"),
648 "PRIMARY" => array("id"),
651 $database["auth_codes"] = array(
653 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
654 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
655 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
656 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
657 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
660 "PRIMARY" => array("id"),
663 $database["cache"] = array(
665 "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
666 "v" => array("type" => "mediumtext"),
667 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
668 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
671 "PRIMARY" => array("k"),
672 "expire_mode_updated" => array("expire_mode", "updated"),
675 $database["challenge"] = array(
677 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
678 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
679 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
680 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
681 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
682 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
685 "PRIMARY" => array("id"),
688 $database["clients"] = array(
690 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
691 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
692 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
693 "name" => array("type" => "text"),
694 "icon" => array("type" => "text"),
695 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
698 "PRIMARY" => array("client_id"),
701 $database["config"] = array(
703 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
704 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
705 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
706 "v" => array("type" => "mediumtext"),
709 "PRIMARY" => array("id"),
710 "cat_k" => array("UNIQUE", "cat", "k"),
713 $database["contact"] = array(
715 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
716 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
717 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
718 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
719 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
720 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
721 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
722 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
723 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
724 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
725 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
726 "about" => array("type" => "text"),
727 "keywords" => array("type" => "text"),
728 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
729 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
730 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
731 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
732 "photo" => array("type" => "text"),
733 "thumb" => array("type" => "text"),
734 "micro" => array("type" => "text"),
735 "site-pubkey" => array("type" => "text"),
736 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
737 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
738 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
739 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
740 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
741 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
742 "pubkey" => array("type" => "text"),
743 "prvkey" => array("type" => "text"),
744 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
745 "request" => array("type" => "text"),
746 "notify" => array("type" => "text"),
747 "poll" => array("type" => "text"),
748 "confirm" => array("type" => "text"),
749 "poco" => array("type" => "text"),
750 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
751 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
752 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
753 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
754 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
755 "last-update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
756 "success_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
757 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
758 "name-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
759 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
760 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
761 "term-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
762 "last-item" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
763 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
764 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
765 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
766 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
767 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
768 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
769 "contact-type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
770 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
771 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
772 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
773 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
774 "reason" => array("type" => "text"),
775 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
776 "info" => array("type" => "mediumtext"),
777 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
778 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
779 "bd" => array("type" => "date", "not null" => "1", "default" => "0001-01-01"),
780 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
781 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
782 "ffi_keyword_blacklist" => array("type" => "text"),
785 "PRIMARY" => array("id"),
786 "uid_name" => array("uid", "name(190)"),
787 "self_uid" => array("self", "uid"),
788 "alias_uid" => array("alias(32)", "uid"),
789 "pending_uid" => array("pending", "uid"),
790 "blocked_uid" => array("blocked", "uid"),
791 "uid_rel_network_poll" => array("uid", "rel", "network(4)", "poll(64)", "archive"),
792 "uid_network_batch" => array("uid", "network(4)", "batch(64)"),
793 "addr_uid" => array("addr(32)", "uid"),
794 "nurl_uid" => array("nurl(32)", "uid"),
795 "nick_uid" => array("nick(32)", "uid"),
796 "dfrn-id" => array("dfrn-id"),
797 "issued-id" => array("issued-id"),
800 $database["conv"] = array(
802 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
803 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
804 "recips" => array("type" => "text"),
805 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
806 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
807 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
808 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
809 "subject" => array("type" => "text"),
812 "PRIMARY" => array("id"),
813 "uid" => array("uid"),
816 $database["conversation"] = array(
818 "item-uri" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
819 "reply-to-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
820 "conversation-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
821 "conversation-href" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
822 "protocol" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
823 "source" => array("type" => "mediumtext"),
824 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
827 "PRIMARY" => array("item-uri"),
828 "conversation-uri" => array("conversation-uri"),
831 $database["event"] = array(
833 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
834 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
835 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
836 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
837 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
838 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
839 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
840 "start" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
841 "finish" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
842 "summary" => array("type" => "text"),
843 "desc" => array("type" => "text"),
844 "location" => array("type" => "text"),
845 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
846 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
847 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
848 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
849 "allow_cid" => array("type" => "mediumtext"),
850 "allow_gid" => array("type" => "mediumtext"),
851 "deny_cid" => array("type" => "mediumtext"),
852 "deny_gid" => array("type" => "mediumtext"),
855 "PRIMARY" => array("id"),
856 "uid_start" => array("uid", "start"),
859 $database["fcontact"] = array(
861 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
862 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
863 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
864 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
865 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
866 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
867 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
868 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
869 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
870 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
871 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
872 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
873 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
874 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
875 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
876 "pubkey" => array("type" => "text"),
877 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
880 "PRIMARY" => array("id"),
881 "addr" => array("addr(32)"),
882 "url" => array("url"),
885 $database["ffinder"] = array(
887 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
888 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
889 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
890 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
893 "PRIMARY" => array("id"),
896 $database["fserver"] = array(
898 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
899 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
900 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
901 "key" => array("type" => "text"),
904 "PRIMARY" => array("id"),
905 "server" => array("server(32)"),
908 $database["fsuggest"] = array(
910 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
911 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
912 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
913 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
914 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
915 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
916 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
917 "note" => array("type" => "text"),
918 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
921 "PRIMARY" => array("id"),
924 $database["gcign"] = array(
926 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
927 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
928 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
931 "PRIMARY" => array("id"),
932 "uid" => array("uid"),
933 "gcid" => array("gcid"),
936 $database["gcontact"] = array(
938 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
939 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
940 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
941 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
942 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
943 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
944 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
945 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
946 "updated" => array("type" => "datetime", "default" => NULL_DATE),
947 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
948 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
949 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
950 "about" => array("type" => "text"),
951 "keywords" => array("type" => "text"),
952 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
953 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
954 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
955 "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
956 "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
957 "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
958 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
959 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
960 "notify" => array("type" => "text"),
961 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
962 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
963 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
966 "PRIMARY" => array("id"),
967 "nurl" => array("nurl(64)"),
968 "name" => array("name(64)"),
969 "nick" => array("nick(32)"),
970 "addr" => array("addr(64)"),
971 "hide_network_updated" => array("hide", "network(4)", "updated"),
972 "updated" => array("updated"),
975 $database["glink"] = array(
977 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
978 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
979 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
980 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
981 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
982 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
985 "PRIMARY" => array("id"),
986 "cid_uid_gcid_zcid" => array("UNIQUE", "cid","uid","gcid","zcid"),
987 "gcid" => array("gcid"),
990 $database["group"] = array(
992 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
993 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
994 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
995 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
996 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
999 "PRIMARY" => array("id"),
1000 "uid" => array("uid"),
1003 $database["group_member"] = array(
1005 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1006 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1007 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("group" => "id")),
1008 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1011 "PRIMARY" => array("id"),
1012 "contactid" => array("contact-id"),
1013 "gid_contactid" => array("gid", "contact-id"),
1014 "uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"),
1017 $database["gserver"] = array(
1019 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1020 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1021 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1022 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1023 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1024 "info" => array("type" => "text"),
1025 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1026 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1027 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1028 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1029 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1030 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1031 "last_poco_query" => array("type" => "datetime", "default" => NULL_DATE),
1032 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
1033 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
1036 "PRIMARY" => array("id"),
1037 "nurl" => array("nurl(32)"),
1040 $database["hook"] = array(
1042 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1043 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1044 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1045 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1046 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1049 "PRIMARY" => array("id"),
1050 "hook_file_function" => array("UNIQUE", "hook(50)","file(80)","function(60)"),
1053 $database["intro"] = array(
1055 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1056 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1057 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
1058 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1059 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1060 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1061 "note" => array("type" => "text"),
1062 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1063 "datetime" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1064 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1065 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1068 "PRIMARY" => array("id"),
1071 $database["item"] = array(
1073 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => array("thread" => "iid")),
1074 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1075 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1076 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1077 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1078 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1079 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1080 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1081 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1082 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1083 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1084 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1085 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1086 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1087 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1088 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1089 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1090 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1091 "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1092 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1093 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1094 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1095 "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1096 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1097 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1098 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1099 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1100 "body" => array("type" => "mediumtext"),
1101 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1102 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1103 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1104 "object" => array("type" => "text"),
1105 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1106 "target" => array("type" => "text"),
1107 "postopts" => array("type" => "text"),
1108 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1109 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1110 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("event" => "id")),
1111 "tag" => array("type" => "mediumtext"),
1112 "attach" => array("type" => "mediumtext"),
1113 "inform" => array("type" => "mediumtext"),
1114 "file" => array("type" => "mediumtext"),
1115 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1116 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1117 "allow_cid" => array("type" => "mediumtext"),
1118 "allow_gid" => array("type" => "mediumtext"),
1119 "deny_cid" => array("type" => "mediumtext"),
1120 "deny_gid" => array("type" => "mediumtext"),
1121 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1122 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1123 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1124 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1125 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1126 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1127 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1128 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1129 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1130 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1131 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1132 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
1133 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1134 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1135 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1136 "rendered-html" => array("type" => "mediumtext"),
1137 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1140 "PRIMARY" => array("id"),
1141 "guid" => array("guid"),
1142 "uri" => array("uri"),
1143 "parent" => array("parent"),
1144 "parent-uri" => array("parent-uri"),
1145 "extid" => array("extid"),
1146 "uid_id" => array("uid","id"),
1147 "uid_contactid_id" => array("uid","contact-id","id"),
1148 "uid_created" => array("uid","created"),
1149 "uid_unseen_contactid" => array("uid","unseen","contact-id"),
1150 "uid_network_received" => array("uid","network(4)","received"),
1151 "uid_network_commented" => array("uid","network(4)","commented"),
1152 "uid_thrparent" => array("uid","thr-parent(190)"),
1153 "uid_parenturi" => array("uid","parent-uri(190)"),
1154 "uid_contactid_created" => array("uid","contact-id","created"),
1155 "authorid_created" => array("author-id","created"),
1156 "ownerid" => array("owner-id"),
1157 "uid_uri" => array("uid", "uri(190)"),
1158 "resource-id" => array("resource-id"),
1159 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
1160 "uid_type_changed" => array("uid","type(190)","changed"),
1161 "contactid_verb" => array("contact-id","verb(190)"),
1162 "deleted_changed" => array("deleted","changed"),
1163 "uid_wall_changed" => array("uid","wall","changed"),
1164 "uid_eventid" => array("uid","event-id"),
1165 "uid_authorlink" => array("uid","author-link(190)"),
1166 "uid_ownerlink" => array("uid","owner-link(190)"),
1169 $database["item_id"] = array(
1171 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1172 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1173 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1174 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1175 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1178 "PRIMARY" => array("id"),
1179 "uid" => array("uid"),
1180 "sid" => array("sid"),
1181 "service" => array("service(32)"),
1182 "iid" => array("iid"),
1185 $database["locks"] = array(
1187 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1188 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1189 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1190 "created" => array("type" => "datetime", "default" => NULL_DATE),
1193 "PRIMARY" => array("id"),
1196 $database["mail"] = array(
1198 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1199 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1200 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1201 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1202 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1203 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1204 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => array("contact" => "id")),
1205 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("conv" => "id")),
1206 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1207 "body" => array("type" => "mediumtext"),
1208 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1209 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1210 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1211 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1212 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1213 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1214 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1217 "PRIMARY" => array("id"),
1218 "uid_seen" => array("uid", "seen"),
1219 "convid" => array("convid"),
1220 "uri" => array("uri(64)"),
1221 "parent-uri" => array("parent-uri(64)"),
1224 $database["mailacct"] = array(
1226 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1227 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1228 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1229 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1230 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1231 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1232 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1233 "pass" => array("type" => "text"),
1234 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1235 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1236 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1237 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1238 "last_check" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1241 "PRIMARY" => array("id"),
1244 $database["manage"] = array(
1246 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1247 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1248 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1251 "PRIMARY" => array("id"),
1252 "uid_mid" => array("UNIQUE", "uid","mid"),
1255 $database["notify"] = array(
1257 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1258 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1259 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1260 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1261 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1262 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1263 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1264 "msg" => array("type" => "mediumtext"),
1265 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1266 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1267 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1268 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1269 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1270 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1271 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1272 "name_cache" => array("type" => "tinytext"),
1273 "msg_cache" => array("type" => "mediumtext")
1276 "PRIMARY" => array("id"),
1277 "hash_uid" => array("hash", "uid"),
1278 "seen_uid_date" => array("seen", "uid", "date"),
1279 "uid_date" => array("uid", "date"),
1280 "uid_type_link" => array("uid", "type", "link(190)"),
1283 $database["notify-threads"] = array(
1285 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1286 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("notify" => "id")),
1287 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1288 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1289 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1292 "PRIMARY" => array("id"),
1295 $database["oembed"] = array(
1297 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1298 "content" => array("type" => "mediumtext"),
1299 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1302 "PRIMARY" => array("url"),
1303 "created" => array("created"),
1306 $database["parsed_url"] = array(
1308 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1309 "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1310 "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1311 "content" => array("type" => "mediumtext"),
1312 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1315 "PRIMARY" => array("url", "guessing", "oembed"),
1316 "created" => array("created"),
1319 $database["pconfig"] = array(
1321 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1322 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1323 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1324 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1325 "v" => array("type" => "mediumtext"),
1328 "PRIMARY" => array("id"),
1329 "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
1332 $database["photo"] = array(
1334 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1335 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1336 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1337 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1338 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1339 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1340 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1341 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1342 "desc" => array("type" => "text"),
1343 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1344 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1345 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1346 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1347 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1348 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1349 "data" => array("type" => "mediumblob", "not null" => "1"),
1350 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1351 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1352 "allow_cid" => array("type" => "mediumtext"),
1353 "allow_gid" => array("type" => "mediumtext"),
1354 "deny_cid" => array("type" => "mediumtext"),
1355 "deny_gid" => array("type" => "mediumtext"),
1358 "PRIMARY" => array("id"),
1359 "uid_contactid" => array("uid", "contact-id"),
1360 "uid_profile" => array("uid", "profile"),
1361 "uid_album_scale_created" => array("uid", "album(32)", "scale", "created"),
1362 "uid_album_resource-id_created" => array("uid", "album(32)", "resource-id(64)", "created"),
1363 "resource-id" => array("resource-id(64)"),
1366 $database["poll"] = array(
1368 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1369 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1370 "q0" => array("type" => "text"),
1371 "q1" => array("type" => "text"),
1372 "q2" => array("type" => "text"),
1373 "q3" => array("type" => "text"),
1374 "q4" => array("type" => "text"),
1375 "q5" => array("type" => "text"),
1376 "q6" => array("type" => "text"),
1377 "q7" => array("type" => "text"),
1378 "q8" => array("type" => "text"),
1379 "q9" => array("type" => "text"),
1382 "PRIMARY" => array("id"),
1383 "uid" => array("uid"),
1386 $database["poll_result"] = array(
1388 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1389 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("poll" => "id")),
1390 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1393 "PRIMARY" => array("id"),
1394 "poll_id" => array("poll_id"),
1395 "choice" => array("choice"),
1398 $database["process"] = array(
1400 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
1401 "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
1402 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1405 "PRIMARY" => array("pid"),
1406 "command" => array("command"),
1409 $database["profile"] = array(
1411 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1412 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1413 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1414 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1415 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1416 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1417 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1418 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
1419 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1420 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1421 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1422 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1423 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1424 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1425 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1426 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1427 "with" => array("type" => "text"),
1428 "howlong" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1429 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1430 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1431 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1432 "pub_keywords" => array("type" => "text"),
1433 "prv_keywords" => array("type" => "text"),
1434 "likes" => array("type" => "text"),
1435 "dislikes" => array("type" => "text"),
1436 "about" => array("type" => "text"),
1437 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1438 "music" => array("type" => "text"),
1439 "book" => array("type" => "text"),
1440 "tv" => array("type" => "text"),
1441 "film" => array("type" => "text"),
1442 "interest" => array("type" => "text"),
1443 "romance" => array("type" => "text"),
1444 "work" => array("type" => "text"),
1445 "education" => array("type" => "text"),
1446 "contact" => array("type" => "text"),
1447 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1448 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1449 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1450 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1451 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1452 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1455 "PRIMARY" => array("id"),
1456 "uid_is-default" => array("uid", "is-default"),
1459 $database["profile_check"] = array(
1461 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1462 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1463 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1464 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1465 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1466 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1469 "PRIMARY" => array("id"),
1472 $database["push_subscriber"] = array(
1474 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1475 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1476 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1477 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1478 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1479 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1480 "last_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1481 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1484 "PRIMARY" => array("id"),
1487 $database["queue"] = array(
1489 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1490 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1491 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1492 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1493 "last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1494 "content" => array("type" => "mediumtext"),
1495 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1498 "PRIMARY" => array("id"),
1499 "cid" => array("cid"),
1500 "created" => array("created"),
1501 "last" => array("last"),
1502 "network" => array("network"),
1503 "batch" => array("batch"),
1506 $database["register"] = array(
1508 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1509 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1510 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1511 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1512 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1513 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1514 "note" => array("type" => "text"),
1517 "PRIMARY" => array("id"),
1520 $database["search"] = array(
1522 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1523 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1524 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1527 "PRIMARY" => array("id"),
1528 "uid" => array("uid"),
1531 $database["session"] = array(
1533 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1534 "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1535 "data" => array("type" => "text"),
1536 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1539 "PRIMARY" => array("id"),
1540 "sid" => array("sid(64)"),
1541 "expire" => array("expire"),
1544 $database["sign"] = array(
1546 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1547 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1548 "signed_text" => array("type" => "mediumtext"),
1549 "signature" => array("type" => "text"),
1550 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1553 "PRIMARY" => array("id"),
1554 "iid" => array("iid"),
1557 $database["spam"] = array(
1559 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1560 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1561 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1562 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1563 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1564 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1567 "PRIMARY" => array("id"),
1568 "uid" => array("uid"),
1569 "spam" => array("spam"),
1570 "ham" => array("ham"),
1571 "term" => array("term"),
1574 $database["term"] = array(
1576 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1577 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1578 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1579 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1580 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1581 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1582 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1583 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1584 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1585 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1586 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1587 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1590 "PRIMARY" => array("tid"),
1591 "oid_otype_type_term" => array("oid","otype","type","term(32)"),
1592 "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"),
1593 "uid_otype_type_url" => array("uid","otype","type","url(64)"),
1594 "guid" => array("guid(64)"),
1597 $database["thread"] = array(
1599 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => array("item" => "id")),
1600 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1601 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1602 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1603 "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1604 "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1605 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1606 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1607 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1608 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1609 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1610 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1611 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1612 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1613 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1614 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1615 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1616 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1617 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1618 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1619 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1620 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1621 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1622 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1623 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1624 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1627 "PRIMARY" => array("iid"),
1628 "uid_network_commented" => array("uid","network","commented"),
1629 "uid_network_created" => array("uid","network","created"),
1630 "uid_contactid_commented" => array("uid","contact-id","commented"),
1631 "uid_contactid_created" => array("uid","contact-id","created"),
1632 "contactid" => array("contact-id"),
1633 "ownerid" => array("owner-id"),
1634 "authorid" => array("author-id"),
1635 "uid_created" => array("uid","created"),
1636 "uid_commented" => array("uid","commented"),
1637 "uid_wall_created" => array("uid","wall","created"),
1640 $database["tokens"] = array(
1642 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1643 "secret" => array("type" => "text"),
1644 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
1645 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1646 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1647 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1650 "PRIMARY" => array("id"),
1653 $database["user"] = array(
1655 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1656 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1657 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1658 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1659 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1660 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1661 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1662 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1663 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1664 "register_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1665 "login_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1666 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1667 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1668 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1669 "pubkey" => array("type" => "text"),
1670 "prvkey" => array("type" => "text"),
1671 "spubkey" => array("type" => "text"),
1672 "sprvkey" => array("type" => "text"),
1673 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1674 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1675 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1676 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1677 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1678 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1679 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1680 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1681 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1682 "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1683 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1684 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1685 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1686 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1687 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1688 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1689 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1690 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1691 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1692 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1693 "allow_cid" => array("type" => "mediumtext"),
1694 "allow_gid" => array("type" => "mediumtext"),
1695 "deny_cid" => array("type" => "mediumtext"),
1696 "deny_gid" => array("type" => "mediumtext"),
1697 "openidserver" => array("type" => "text"),
1700 "PRIMARY" => array("uid"),
1701 "nickname" => array("nickname(32)"),
1704 $database["userd"] = array(
1706 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1707 "username" => array("type" => "varchar(255)", "not null" => "1"),
1710 "PRIMARY" => array("id"),
1711 "username" => array("username(32)"),
1714 $database["workerqueue"] = array(
1716 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1717 "parameter" => array("type" => "text"),
1718 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1719 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1720 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1721 "executed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1724 "PRIMARY" => array("id"),
1733 * run from command line
1735 function dbstructure_run(&$argv, &$argc) {
1739 $a = new App(dirname(__DIR__));
1743 @include(".htconfig.php");
1744 require_once("include/dba.php");
1745 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1746 unset($db_host, $db_user, $db_pass, $db_data);
1752 update_structure(true, false);
1755 update_structure(true, true);
1757 $build = get_config('system','build');
1759 set_config('system','build',DB_UPDATE_VERSION);
1760 $build = DB_UPDATE_VERSION;
1763 $stored = intval($build);
1764 $current = intval(DB_UPDATE_VERSION);
1766 // run any left update_nnnn functions in update.php
1767 for ($x = $stored; $x < $current; $x ++) {
1768 $r = run_update_function($x);
1772 set_config('system','build',DB_UPDATE_VERSION);
1775 print_structure(db_definition());
1778 convert_to_innodb();
1785 echo $argv[0]." <command>\n";
1788 echo "dryrun show database update schema queries without running them\n";
1789 echo "update update database schema\n";
1790 echo "dumpsql dump database schema\n";
1791 echo "toinnodb convert all tables from MyISAM to InnoDB\n";
1796 if (array_search(__file__,get_included_files())===0) {
1797 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);