3 * @file src/Database/DBStructure.php
5 namespace Friendica\Database;
7 use Friendica\Core\Config;
8 use Friendica\Database\DBM;
11 require_once "boot.php";
12 require_once 'include/dba.php';
13 require_once 'include/enotify.php';
14 require_once "include/text.php";
17 * @brief This class contain functions for the database management
19 * This class contains functions that doesn't need to know if pdo, mysqli or whatever is used.
23 * Converts all tables from MyISAM to InnoDB
25 public static function convertToInnoDB() {
26 $r = q("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `engine` = 'MyISAM' AND `table_schema` = '%s'",
27 dbesc(dba::database_name()));
29 if (!DBM::is_result($r)) {
30 echo t('There are no tables on MyISAM.')."\n";
34 foreach ($r AS $table) {
35 $sql = sprintf("ALTER TABLE `%s` engine=InnoDB;", dbesc($table['TABLE_NAME']));
38 $result = dba::e($sql);
39 if (!DBM::is_result($result)) {
40 self::printUpdateError($sql);
46 * send the email and do what is needed to do on update fails
48 * @param update_id (int) number of failed update
49 * @param error_message (str) error message
51 public static function updateFail($update_id, $error_message) {
54 //send the administrators an e-mail
55 $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
56 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
61 if (!DBM::is_result($adminlist)) {
62 logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_NORMAL);
68 // every admin could had different language
69 foreach ($adminlist as $admin) {
70 $lang = (($admin['language'])?$admin['language']:'en');
73 $preamble = deindent(t("
74 The friendica developers released update %s recently,
75 but when I tried to install it, something went terribly wrong.
76 This needs to be fixed soon and I can't do it alone. Please contact a
77 friendica developer if you can not help me on your own. My database might be invalid."));
78 $body = t("The error message is\n[pre]%s[/pre]");
79 $preamble = sprintf($preamble, $update_id);
80 $body = sprintf($body, $error_message);
83 'type' => SYSTEM_EMAIL,
84 'to_email' => $admin['email'],
85 'preamble' => $preamble,
92 logger("CRITICAL: Database structure update failed: ".$error_message);
96 private static function tableStructure($table) {
97 $structures = q("DESCRIBE `%s`", $table);
99 $full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table);
101 $indexes = q("SHOW INDEX FROM `%s`", $table);
103 $table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table);
105 if (DBM::is_result($table_status)) {
106 $table_status = $table_status[0];
108 $table_status = array();
111 $fielddata = array();
112 $indexdata = array();
114 if (DBM::is_result($indexes)) {
115 foreach ($indexes AS $index) {
116 if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
117 $indexdata[$index["Key_name"]] = array('UNIQUE');
120 $column = $index["Column_name"];
122 if ($index["Sub_part"] != "") {
123 $column .= "(".$index["Sub_part"].")";
126 $indexdata[$index["Key_name"]][] = $column;
129 if (DBM::is_result($structures)) {
130 foreach ($structures AS $field) {
131 // Replace the default size values so that we don't have to define them
132 $search = ['tinyint(1)', 'tinyint(4)', 'smallint(6)', 'mediumint(9)', 'bigint(20)', 'int(11)'];
133 $replace = ['boolean', 'tinyint', 'smallint', 'mediumint', 'bigint', 'int'];
134 $field["Type"] = str_replace($search, $replace, $field["Type"]);
136 $fielddata[$field["Field"]]["type"] = $field["Type"];
137 if ($field["Null"] == "NO") {
138 $fielddata[$field["Field"]]["not null"] = true;
141 if (isset($field["Default"])) {
142 $fielddata[$field["Field"]]["default"] = $field["Default"];
145 if ($field["Extra"] != "") {
146 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
149 if ($field["Key"] == "PRI") {
150 $fielddata[$field["Field"]]["primary"] = true;
154 if (DBM::is_result($full_columns)) {
155 foreach ($full_columns AS $column) {
156 $fielddata[$column["Field"]]["Collation"] = $column["Collation"];
157 $fielddata[$column["Field"]]["comment"] = $column["Comment"];
161 return array("fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status);
164 public static function printStructure() {
165 $database = self::definition();
167 echo "-- ------------------------------------------\n";
168 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
169 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
170 echo "-- ------------------------------------------\n\n\n";
171 foreach ($database AS $name => $structure) {
173 echo "-- TABLE $name\n";
175 self::createTable($name, $structure['fields'], true, false, $structure["indexes"]);
182 * @brief Print out database error messages
184 * @param string $message Message to be added to the error message
186 * @return string Error message
188 private static function printUpdateError($message) {
189 echo sprintf(t("\nError %d occurred during database update:\n%s\n"),
190 dba::errorNo(), dba::errorMessage());
192 return t('Errors encountered performing database changes: ').$message.EOL;
196 * Updates DB structure and returns eventual errors messages
198 * @param bool $verbose
199 * @param bool $action Whether to actually apply the update
200 * @param array $tables An array of the database tables
201 * @param array $definition An array of the definition tables
202 * @return string Empty string if the update is successful, error messages otherwise
204 public static function update($verbose, $action, array $tables = null, array $definition = null) {
206 Config::set('system', 'maintenance', 1);
207 Config::set('system', 'maintenance_reason', sprintf(t(': Database update'), DBM::date().' '.date('e')));
212 logger('updating structure', LOGGER_DEBUG);
214 // Get the current structure
217 if (is_null($tables)) {
218 $tables = q("SHOW TABLES");
221 if (DBM::is_result($tables)) {
222 foreach ($tables AS $table) {
223 $table = current($table);
225 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
226 $database[$table] = self::tableStructure($table);
230 // Get the definition
231 if (is_null($definition)) {
232 $definition = self::definition();
235 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
236 if ((version_compare(dba::server_info(), '5.7.4') >= 0) &&
237 !(strpos(dba::server_info(), 'MariaDB') !== false)) {
244 foreach ($definition AS $name => $structure) {
245 $is_new_table = False;
248 if (!isset($database[$name])) {
249 $r = self::createTable($name, $structure["fields"], $verbose, $action, $structure['indexes']);
250 if (!DBM::is_result($r)) {
251 $errors .= self::printUpdateError($name);
253 $is_new_table = True;
258 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
259 if (isset($database[$name]["indexes"][$indexname])) {
260 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
262 $current_index_definition = "__NOT_SET__";
264 $new_index_definition = implode(",",$fieldnames);
265 if ($current_index_definition != $new_index_definition) {
266 if ($fieldnames[0] == "UNIQUE") {
269 $temp_name = "temp-".$name;
276 * Drop the index if it isn't present in the definition
277 * or the definition differ from current status
278 * and index name doesn't start with "local_"
280 foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
281 $current_index_definition = implode(",",$fieldnames);
282 if (isset($structure["indexes"][$indexname])) {
283 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
285 $new_index_definition = "__NOT_SET__";
287 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
288 $sql2=self::dropIndex($indexname);
290 $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
296 // Compare the field structure field by field
297 foreach ($structure["fields"] AS $fieldname => $parameters) {
298 if (!isset($database[$name]["fields"][$fieldname])) {
299 $sql2=self::addTableField($fieldname, $parameters);
301 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
306 // Compare the field definition
307 $field_definition = $database[$name]["fields"][$fieldname];
309 // Remove the relation data that is used for the referential integrity
310 unset($parameters['relation']);
312 // We change the collation after the indexes had been changed.
313 // This is done to avoid index length problems.
314 // So here we always ensure that there is no need to change it.
315 unset($parameters['Collation']);
316 unset($field_definition['Collation']);
318 // Only update the comment when it is defined
319 if (!isset($parameters['comment'])) {
320 $parameters['comment'] = "";
323 $current_field_definition = implode(",", $field_definition);
324 $new_field_definition = implode(",", $parameters);
325 if ($current_field_definition != $new_field_definition) {
326 $sql2 = self::modifyTableField($fieldname, $parameters);
328 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
338 * Create the index if the index don't exists in database
339 * or the definition differ from the current status.
340 * Don't create keys if table is new
342 if (!$is_new_table) {
343 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
344 if (isset($database[$name]["indexes"][$indexname])) {
345 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
347 $current_index_definition = "__NOT_SET__";
349 $new_index_definition = implode(",",$fieldnames);
350 if ($current_index_definition != $new_index_definition) {
351 $sql2 = self::createIndex($indexname, $fieldnames);
353 // Fetch the "group by" fields for unique indexes
354 if ($fieldnames[0] == "UNIQUE") {
355 $group_by = self::groupBy($indexname, $fieldnames);
359 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
367 if (isset($database[$name]["table_status"]["Comment"])) {
368 if ($database[$name]["table_status"]["Comment"] != $structure['comment']) {
369 $sql2 = "COMMENT = '".dbesc($structure['comment'])."'";
372 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
379 if (isset($database[$name]["table_status"]["Collation"])) {
380 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
381 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
384 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
395 // Now have a look at the field collations
396 // Compare the field structure field by field
397 foreach ($structure["fields"] AS $fieldname => $parameters) {
398 // Compare the field definition
399 $field_definition = $database[$name]["fields"][$fieldname];
401 // Define the default collation if not given
402 if (!isset($parameters['Collation']) && !is_null($field_definition['Collation'])) {
403 $parameters['Collation'] = 'utf8mb4_general_ci';
405 $parameters['Collation'] = null;
408 if ($field_definition['Collation'] != $parameters['Collation']) {
409 $sql2 = self::modifyTableField($fieldname, $parameters);
410 if (($sql3 == "") || (substr($sql3, -2, 2) == "; ")) {
411 $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
420 if (substr($sql3, -2, 2) != "; ") {
425 if ($is_unique && $ignore == '') {
426 foreach ($database[$name]["fields"] AS $fieldname => $parameters) {
427 $field_list .= 'ANY_VALUE(`' . $fieldname . '`),';
429 $field_list = rtrim($field_list, ',');
433 // Ensure index conversion to unique removes duplicates
434 if ($is_unique && ($temp_name != $name)) {
436 echo "SET session old_alter_table=1;\n";
438 echo "DROP TABLE IF EXISTS `".$temp_name."`;\n";
439 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
445 if ($is_unique && ($temp_name != $name)) {
447 echo "SET session old_alter_table=0;\n";
449 echo "INSERT INTO `".$temp_name."` SELECT ".dba::any_value_fallback($field_list)." FROM `".$name."`".$group_by.";\n";
450 echo "DROP TABLE `".$name."`;\n";
451 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
457 Config::set('system', 'maintenance_reason', sprintf(t('%s: updating %s table.'), DBM::date().' '.date('e'), $name));
459 // Ensure index conversion to unique removes duplicates
460 if ($is_unique && ($temp_name != $name)) {
462 dba::e("SET session old_alter_table=1;");
464 dba::e("DROP TABLE IF EXISTS `".$temp_name."`;");
465 if (!DBM::is_result($r)) {
466 $errors .= self::printUpdateError($sql3);
470 $r = dba::e("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
471 if (!DBM::is_result($r)) {
472 $errors .= self::printUpdateError($sql3);
479 if (!DBM::is_result($r)) {
480 $errors .= self::printUpdateError($sql3);
482 if ($is_unique && ($temp_name != $name)) {
484 dba::e("SET session old_alter_table=0;");
486 $r = dba::e("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
487 if (!DBM::is_result($r)) {
488 $errors .= self::printUpdateError($sql3);
491 $r = dba::e("DROP TABLE `".$name."`;");
492 if (!DBM::is_result($r)) {
493 $errors .= self::printUpdateError($sql3);
496 $r = dba::e("RENAME TABLE `".$temp_name."` TO `".$name."`;");
497 if (!DBM::is_result($r)) {
498 $errors .= self::printUpdateError($sql3);
508 Config::set('system', 'maintenance', 0);
509 Config::set('system', 'maintenance_reason', '');
513 Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
515 Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
521 private static function FieldCommand($parameters, $create = true) {
522 $fieldstruct = $parameters["type"];
524 if (!is_null($parameters["Collation"])) {
525 $fieldstruct .= " COLLATE ".$parameters["Collation"];
528 if ($parameters["not null"]) {
529 $fieldstruct .= " NOT NULL";
532 if (isset($parameters["default"])) {
533 if (strpos(strtolower($parameters["type"]),"int")!==false) {
534 $fieldstruct .= " DEFAULT ".$parameters["default"];
536 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
539 if ($parameters["extra"] != "") {
540 $fieldstruct .= " ".$parameters["extra"];
543 if (!is_null($parameters["comment"])) {
544 $fieldstruct .= " COMMENT '".dbesc($parameters["comment"])."'";
547 /*if (($parameters["primary"] != "") && $create)
548 $fieldstruct .= " PRIMARY KEY";*/
550 return($fieldstruct);
553 private static function createTable($name, $fields, $verbose, $action, $indexes=null) {
557 $primary_keys = array();
558 foreach ($fields AS $fieldname => $field) {
559 $sql_rows[] = "`".dbesc($fieldname)."` ".self::FieldCommand($field);
560 if (x($field,'primary') && $field['primary']!='') {
561 $primary_keys[] = $fieldname;
565 if (!is_null($indexes)) {
566 foreach ($indexes AS $indexname => $fieldnames) {
567 $sql_index = self::createIndex($indexname, $fieldnames, "");
568 if (!is_null($sql_index)) {
569 $sql_rows[] = $sql_index;
574 $sql = implode(",\n\t", $sql_rows);
576 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
588 private static function addTableField($fieldname, $parameters) {
589 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), self::FieldCommand($parameters));
593 private static function modifyTableField($fieldname, $parameters) {
594 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), self::FieldCommand($parameters, false));
598 private static function dropIndex($indexname) {
599 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
603 private static function createIndex($indexname, $fieldnames, $method = "ADD") {
604 $method = strtoupper(trim($method));
605 if ($method!="" && $method!="ADD") {
606 throw new \Exception("Invalid parameter 'method' in self::createIndex(): '$method'");
609 if ($fieldnames[0] == "UNIQUE") {
610 array_shift($fieldnames);
611 $method .= ' UNIQUE';
615 foreach ($fieldnames AS $fieldname) {
620 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
621 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
623 $names .= "`".dbesc($fieldname)."`";
627 if ($indexname == "PRIMARY") {
628 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
632 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
636 private static function groupBy($indexname, $fieldnames) {
637 if ($fieldnames[0] != "UNIQUE") {
641 array_shift($fieldnames);
644 foreach ($fieldnames AS $fieldname) {
649 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
650 $names .= "`".dbesc($matches[1])."`";
652 $names .= "`".dbesc($fieldname)."`";
656 $sql = sprintf(" GROUP BY %s", $names);
660 public static function definition() {
663 $database["addon"] = array(
664 "comment" => "registered plugins",
666 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
667 "name" => array("type" => "varchar(190)", "not null" => "1", "default" => "", "comment" => ""),
668 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
669 "installed" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
670 "hidden" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
671 "timestamp" => array("type" => "bigint", "not null" => "1", "default" => "0", "comment" => ""),
672 "plugin_admin" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
675 "PRIMARY" => array("id"),
676 "name" => array("UNIQUE", "name"),
679 $database["attach"] = array(
680 "comment" => "file attachments",
682 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
683 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
684 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""),
685 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
686 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""),
687 "filesize" => array("type" => "int", "not null" => "1", "default" => "0", "comment" => ""),
688 "data" => array("type" => "longblob", "not null" => "1", "comment" => ""),
689 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
690 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
691 "allow_cid" => array("type" => "mediumtext", "comment" => ""),
692 "allow_gid" => array("type" => "mediumtext", "comment" => ""),
693 "deny_cid" => array("type" => "mediumtext", "comment" => ""),
694 "deny_gid" => array("type" => "mediumtext", "comment" => ""),
697 "PRIMARY" => array("id"),
700 $database["auth_codes"] = array(
701 "comment" => "OAuth usage",
703 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1", "comment" => ""),
704 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id"), "comment" => ""),
705 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""),
706 "expires" => array("type" => "int", "not null" => "1", "default" => "0", "comment" => ""),
707 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => "", "comment" => ""),
710 "PRIMARY" => array("id"),
713 $database["cache"] = array(
714 "comment" => "Used to store different data that doesn't to be stored for a long time",
716 "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => ""),
717 "v" => array("type" => "mediumtext", "comment" => ""),
718 "expire_mode" => array("type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""),
719 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
722 "PRIMARY" => array("k"),
723 "expire_mode_updated" => array("expire_mode", "updated"),
726 $database["challenge"] = array(
729 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
730 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
731 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
732 "expire" => array("type" => "int", "not null" => "1", "default" => "0", "comment" => ""),
733 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
734 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
737 "PRIMARY" => array("id"),
740 $database["clients"] = array(
741 "comment" => "OAuth usage",
743 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1", "comment" => ""),
744 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => ""),
745 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""),
746 "name" => array("type" => "text", "comment" => ""),
747 "icon" => array("type" => "text", "comment" => ""),
748 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
751 "PRIMARY" => array("client_id"),
754 $database["config"] = array(
755 "comment" => "main configuration storage",
757 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
758 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""),
759 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""),
760 "v" => array("type" => "mediumtext", "comment" => ""),
763 "PRIMARY" => array("id"),
764 "cat_k" => array("UNIQUE", "cat", "k"),
767 $database["contact"] = array(
768 "comment" => "contact table",
770 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
771 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
772 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
773 "self" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
774 "remote_self" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
775 "rel" => array("type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""),
776 "duplex" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
777 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
778 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
779 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
780 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
781 "about" => array("type" => "text", "comment" => ""),
782 "keywords" => array("type" => "text", "comment" => ""),
783 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""),
784 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
785 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
786 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
787 "photo" => array("type" => "text", "comment" => ""),
788 "thumb" => array("type" => "text", "comment" => ""),
789 "micro" => array("type" => "text", "comment" => ""),
790 "site-pubkey" => array("type" => "text", "comment" => ""),
791 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
792 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
793 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
794 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
795 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
796 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
797 "pubkey" => array("type" => "text", "comment" => ""),
798 "prvkey" => array("type" => "text", "comment" => ""),
799 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
800 "request" => array("type" => "text", "comment" => ""),
801 "notify" => array("type" => "text", "comment" => ""),
802 "poll" => array("type" => "text", "comment" => ""),
803 "confirm" => array("type" => "text", "comment" => ""),
804 "poco" => array("type" => "text", "comment" => ""),
805 "aes_allow" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
806 "ret-aes" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
807 "usehub" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
808 "subhub" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
809 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
810 "last-update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
811 "success_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
812 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
813 "name-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
814 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
815 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
816 "term-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
817 "last-item" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
818 "priority" => array("type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""),
819 "blocked" => array("type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""),
820 "readonly" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
821 "writable" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
822 "forum" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
823 "prv" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
824 "contact-type" => array("type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""),
825 "hidden" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
826 "archive" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
827 "pending" => array("type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""),
828 "rating" => array("type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""),
829 "reason" => array("type" => "text", "comment" => ""),
830 "closeness" => array("type" => "tinyint", "not null" => "1", "default" => "99", "comment" => ""),
831 "info" => array("type" => "mediumtext", "comment" => ""),
832 "profile-id" => array("type" => "int", "not null" => "1", "default" => "0", "comment" => ""),
833 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => "", "comment" => ""),
834 "bd" => array("type" => "date", "not null" => "1", "default" => "0001-01-01", "comment" => ""),
835 "notify_new_posts" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
836 "fetch_further_information" => array("type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""),
837 "ffi_keyword_blacklist" => array("type" => "text", "comment" => ""),
840 "PRIMARY" => array("id"),
841 "uid_name" => array("uid", "name(190)"),
842 "self_uid" => array("self", "uid"),
843 "alias_uid" => array("alias(32)", "uid"),
844 "pending_uid" => array("pending", "uid"),
845 "blocked_uid" => array("blocked", "uid"),
846 "uid_rel_network_poll" => array("uid", "rel", "network(4)", "poll(64)", "archive"),
847 "uid_network_batch" => array("uid", "network(4)", "batch(64)"),
848 "addr_uid" => array("addr(32)", "uid"),
849 "nurl_uid" => array("nurl(32)", "uid"),
850 "nick_uid" => array("nick(32)", "uid"),
851 "dfrn-id" => array("dfrn-id(64)"),
852 "issued-id" => array("issued-id(64)"),
855 $database["conv"] = array(
856 "comment" => "private messages",
858 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
859 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
860 "recips" => array("type" => "text", "comment" => ""),
861 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
862 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
863 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
864 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
865 "subject" => array("type" => "text", "comment" => ""),
868 "PRIMARY" => array("id"),
869 "uid" => array("uid"),
872 $database["conversation"] = array(
873 "comment" => "Raw data and structure information for messages",
875 "item-uri" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => ""),
876 "reply-to-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""),
877 "conversation-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""),
878 "conversation-href" => array("type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""),
879 "protocol" => array("type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""),
880 "source" => array("type" => "mediumtext", "comment" => ""),
881 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
884 "PRIMARY" => array("item-uri"),
885 "conversation-uri" => array("conversation-uri"),
886 "received" => array("received"),
889 $database["event"] = array(
890 "comment" => "Events",
892 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
893 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
894 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
895 "cid" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("contact" => "id"), "comment" => ""),
896 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
897 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
898 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
899 "start" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
900 "finish" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
901 "summary" => array("type" => "text", "comment" => ""),
902 "desc" => array("type" => "text", "comment" => ""),
903 "location" => array("type" => "text", "comment" => ""),
904 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
905 "nofinish" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
906 "adjust" => array("type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""),
907 "ignore" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
908 "allow_cid" => array("type" => "mediumtext", "comment" => ""),
909 "allow_gid" => array("type" => "mediumtext", "comment" => ""),
910 "deny_cid" => array("type" => "mediumtext", "comment" => ""),
911 "deny_gid" => array("type" => "mediumtext", "comment" => ""),
914 "PRIMARY" => array("id"),
915 "uid_start" => array("uid", "start"),
918 $database["fcontact"] = array(
919 "comment" => "Diaspora compatible contacts - used in the Diaspora implementation",
921 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
922 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
923 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
924 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
925 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
926 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
927 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
928 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
929 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
930 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
931 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
932 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
933 "priority" => array("type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""),
934 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""),
935 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
936 "pubkey" => array("type" => "text", "comment" => ""),
937 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
940 "PRIMARY" => array("id"),
941 "addr" => array("addr(32)"),
942 "url" => array("UNIQUE", "url(190)"),
945 $database["fsuggest"] = array(
946 "comment" => "friend suggestion stuff",
948 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
949 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
950 "cid" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("contact" => "id"), "comment" => ""),
951 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
952 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
953 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
954 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
955 "note" => array("type" => "text", "comment" => ""),
956 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
959 "PRIMARY" => array("id"),
962 $database["gcign"] = array(
963 "comment" => "contacts ignored by friend suggestions",
965 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
966 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
967 "gcid" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id"), "comment" => ""),
970 "PRIMARY" => array("id"),
971 "uid" => array("uid"),
972 "gcid" => array("gcid"),
975 $database["gcontact"] = array(
976 "comment" => "global contacts",
978 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
979 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
980 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
981 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
982 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
983 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
984 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
985 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
986 "updated" => array("type" => "datetime", "default" => NULL_DATE, "comment" => ""),
987 "last_contact" => array("type" => "datetime", "default" => NULL_DATE, "comment" => ""),
988 "last_failure" => array("type" => "datetime", "default" => NULL_DATE, "comment" => ""),
989 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
990 "about" => array("type" => "text", "comment" => ""),
991 "keywords" => array("type" => "text", "comment" => ""),
992 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""),
993 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01", "comment" => ""),
994 "community" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
995 "contact-type" => array("type" => "tinyint", "not null" => "1", "default" => "-1", "comment" => ""),
996 "hide" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
997 "nsfw" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
998 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
999 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1000 "notify" => array("type" => "text", "comment" => ""),
1001 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1002 "generation" => array("type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""),
1003 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1006 "PRIMARY" => array("id"),
1007 "nurl" => array("UNIQUE", "nurl(190)"),
1008 "name" => array("name(64)"),
1009 "nick" => array("nick(32)"),
1010 "addr" => array("addr(64)"),
1011 "hide_network_updated" => array("hide", "network(4)", "updated"),
1012 "updated" => array("updated"),
1015 $database["glink"] = array(
1016 "comment" => "'friends of friends' linkages derived from poco",
1018 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1019 "cid" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("contact" => "id"), "comment" => ""),
1020 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
1021 "gcid" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id"), "comment" => ""),
1022 "zcid" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id"), "comment" => ""),
1023 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1026 "PRIMARY" => array("id"),
1027 "cid_uid_gcid_zcid" => array("UNIQUE", "cid","uid","gcid","zcid"),
1028 "gcid" => array("gcid"),
1031 $database["group"] = array(
1032 "comment" => "privacy groups, group info",
1034 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1035 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
1036 "visible" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1037 "deleted" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1038 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1041 "PRIMARY" => array("id"),
1042 "uid" => array("uid"),
1045 $database["group_member"] = array(
1046 "comment" => "privacy groups, member info",
1048 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1049 "gid" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("group" => "id"), "comment" => ""),
1050 "contact-id" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("contact" => "id"), "comment" => ""),
1053 "PRIMARY" => array("id"),
1054 "contactid" => array("contact-id"),
1055 "gid_contactid" => array("UNIQUE", "gid", "contact-id"),
1058 $database["gserver"] = array(
1059 "comment" => "Global servers",
1061 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1062 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1063 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1064 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1065 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1066 "info" => array("type" => "text", "comment" => ""),
1067 "register_policy" => array("type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""),
1068 "registered-users" => array("type" => "int", "not null" => "1", "default" => "0", "comment" => ""),
1069 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1070 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1071 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""),
1072 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1073 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1074 "last_poco_query" => array("type" => "datetime", "default" => NULL_DATE, "comment" => ""),
1075 "last_contact" => array("type" => "datetime", "default" => NULL_DATE, "comment" => ""),
1076 "last_failure" => array("type" => "datetime", "default" => NULL_DATE, "comment" => ""),
1079 "PRIMARY" => array("id"),
1080 "nurl" => array("UNIQUE", "nurl(190)"),
1083 $database["hook"] = array(
1084 "comment" => "plugin hook registry",
1086 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1087 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1088 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1089 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1090 "priority" => array("type" => "smallint", "not null" => "1", "default" => "0", "comment" => ""),
1093 "PRIMARY" => array("id"),
1094 "hook_file_function" => array("UNIQUE", "hook(50)","file(80)","function(60)"),
1097 $database["intro"] = array(
1100 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1101 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
1102 "fid" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id"), "comment" => ""),
1103 "contact-id" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("contact" => "id"), "comment" => ""),
1104 "knowyou" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1105 "duplex" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1106 "note" => array("type" => "text", "comment" => ""),
1107 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1108 "datetime" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1109 "blocked" => array("type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""),
1110 "ignore" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1113 "PRIMARY" => array("id"),
1116 $database["item"] = array(
1117 "comment" => "All posts",
1119 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => array("thread" => "iid")),
1120 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1121 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1122 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
1123 "contact-id" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("contact" => "id"), "comment" => ""),
1124 "gcontact-id" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id"), "comment" => ""),
1125 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1126 "wall" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1127 "gravity" => array("type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""),
1128 "parent" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("item" => "id"), "comment" => ""),
1129 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1130 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1131 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1132 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1133 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1134 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1135 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1136 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1137 "owner-id" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("contact" => "id"), "comment" => ""),
1138 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1139 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1140 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1141 "author-id" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("contact" => "id"), "comment" => ""),
1142 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1143 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1144 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1145 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1146 "body" => array("type" => "mediumtext", "comment" => ""),
1147 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1148 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1149 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1150 "object" => array("type" => "text", "comment" => ""),
1151 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1152 "target" => array("type" => "text", "comment" => ""),
1153 "postopts" => array("type" => "text", "comment" => ""),
1154 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1155 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1156 "event-id" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("event" => "id"), "comment" => ""),
1157 "tag" => array("type" => "mediumtext", "comment" => ""),
1158 "attach" => array("type" => "mediumtext", "comment" => ""),
1159 "inform" => array("type" => "mediumtext", "comment" => ""),
1160 "file" => array("type" => "mediumtext", "comment" => ""),
1161 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1162 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1163 "allow_cid" => array("type" => "mediumtext", "comment" => ""),
1164 "allow_gid" => array("type" => "mediumtext", "comment" => ""),
1165 "deny_cid" => array("type" => "mediumtext", "comment" => ""),
1166 "deny_gid" => array("type" => "mediumtext", "comment" => ""),
1167 "private" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1168 "pubmail" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1169 "moderated" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1170 "visible" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1171 "spam" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1172 "starred" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1173 "bookmark" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1174 "unseen" => array("type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""),
1175 "deleted" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1176 "origin" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1177 "forum_mode" => array("type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""),
1178 "last-child" => array("type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""),
1179 "mention" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1180 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""),
1181 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""),
1182 "rendered-html" => array("type" => "mediumtext", "comment" => ""),
1183 "global" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1186 "PRIMARY" => array("id"),
1187 "guid" => array("guid(191)"),
1188 "uri" => array("uri(191)"),
1189 "parent" => array("parent"),
1190 "parent-uri" => array("parent-uri(191)"),
1191 "extid" => array("extid(191)"),
1192 "uid_id" => array("uid","id"),
1193 "uid_contactid_id" => array("uid","contact-id","id"),
1194 "uid_created" => array("uid","created"),
1195 "uid_unseen_contactid" => array("uid","unseen","contact-id"),
1196 "uid_network_received" => array("uid","network(4)","received"),
1197 "uid_network_commented" => array("uid","network(4)","commented"),
1198 "uid_thrparent" => array("uid","thr-parent(190)"),
1199 "uid_parenturi" => array("uid","parent-uri(190)"),
1200 "uid_contactid_created" => array("uid","contact-id","created"),
1201 "authorid_created" => array("author-id","created"),
1202 "ownerid" => array("owner-id"),
1203 "uid_uri" => array("uid", "uri(190)"),
1204 "resource-id" => array("resource-id(191)"),
1205 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
1206 "uid_type_changed" => array("uid","type(190)","changed"),
1207 "contactid_verb" => array("contact-id","verb(190)"),
1208 "deleted_changed" => array("deleted","changed"),
1209 "uid_wall_changed" => array("uid","wall","changed"),
1210 "uid_eventid" => array("uid","event-id"),
1211 "uid_authorlink" => array("uid","author-link(190)"),
1212 "uid_ownerlink" => array("uid","owner-link(190)"),
1215 $database["locks"] = array(
1218 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1219 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => ""),
1220 "locked" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1221 "pid" => array("type" => "int", "not null" => "1", "default" => "0", "comment" => ""),
1224 "PRIMARY" => array("id"),
1227 $database["mail"] = array(
1228 "comment" => "private messages",
1230 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1231 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
1232 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1233 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1234 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1235 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1236 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => array("contact" => "id"), "comment" => ""),
1237 "convid" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("conv" => "id"), "comment" => ""),
1238 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1239 "body" => array("type" => "mediumtext", "comment" => ""),
1240 "seen" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1241 "reply" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1242 "replied" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1243 "unknown" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1244 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1245 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1246 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1249 "PRIMARY" => array("id"),
1250 "uid_seen" => array("uid", "seen"),
1251 "convid" => array("convid"),
1252 "uri" => array("uri(64)"),
1253 "parent-uri" => array("parent-uri(64)"),
1254 "contactid" => array("contact-id(32)"),
1257 $database["mailacct"] = array(
1258 "comment" => "Mail account data for fetching mails",
1260 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1261 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
1262 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1263 "port" => array("type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""),
1264 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => "", "comment" => ""),
1265 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1266 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1267 "pass" => array("type" => "text", "comment" => ""),
1268 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1269 "action" => array("type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""),
1270 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1271 "pubmail" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1272 "last_check" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1275 "PRIMARY" => array("id"),
1278 $database["manage"] = array(
1279 "comment" => "table of accounts that can manage each other",
1281 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1282 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
1283 "mid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
1286 "PRIMARY" => array("id"),
1287 "uid_mid" => array("UNIQUE", "uid","mid"),
1290 $database["notify"] = array(
1291 "comment" => "notifications",
1293 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1294 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""),
1295 "type" => array("type" => "smallint", "not null" => "1", "default" => "0", "comment" => ""),
1296 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1297 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1298 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1299 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1300 "msg" => array("type" => "mediumtext", "comment" => ""),
1301 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
1302 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1303 "iid" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("item" => "id"), "comment" => ""),
1304 "parent" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("item" => "id"), "comment" => ""),
1305 "seen" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1306 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1307 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => "", "comment" => ""),
1308 "name_cache" => array("type" => "tinytext", "comment" => ""),
1309 "msg_cache" => array("type" => "mediumtext", "comment" => "")
1312 "PRIMARY" => array("id"),
1313 "hash_uid" => array("hash", "uid"),
1314 "seen_uid_date" => array("seen", "uid", "date"),
1315 "uid_date" => array("uid", "date"),
1316 "uid_type_link" => array("uid", "type", "link(190)"),
1319 $database["notify-threads"] = array(
1322 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1323 "notify-id" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("notify" => "id"), "comment" => ""),
1324 "master-parent-item" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("item" => "id"), "comment" => ""),
1325 "parent-item" => array("type" => "int", "not null" => "1", "default" => "0", "comment" => ""),
1326 "receiver-uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
1329 "PRIMARY" => array("id"),
1332 $database["oembed"] = array(
1333 "comment" => "cache for OEmbed queries",
1335 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => ""),
1336 "maxwidth" => array("type" => "mediumint", "not null" => "1", "primary" => "1", "comment" => ""),
1337 "content" => array("type" => "mediumtext", "comment" => ""),
1338 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1341 "PRIMARY" => array("url", "maxwidth"),
1342 "created" => array("created"),
1345 $database["parsed_url"] = array(
1346 "comment" => "cache for 'parse_url' queries",
1348 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => ""),
1349 "guessing" => array("type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => ""),
1350 "oembed" => array("type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => ""),
1351 "content" => array("type" => "mediumtext", "comment" => ""),
1352 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1355 "PRIMARY" => array("url", "guessing", "oembed"),
1356 "created" => array("created"),
1359 $database["participation"] = array(
1360 "comment" => "Storage for participation messages from Diaspora",
1362 "iid" => array("type" => "int", "not null" => "1", "primary" => "1", "relation" => array("item" => "id"), "comment" => ""),
1363 "server" => array("type" => "varchar(60)", "not null" => "1", "primary" => "1", "comment" => ""),
1364 "cid" => array("type" => "int", "not null" => "1", "relation" => array("contact" => "id"), "comment" => ""),
1365 "fid" => array("type" => "int", "not null" => "1", "relation" => array("fcontact" => "id"), "comment" => ""),
1368 "PRIMARY" => array("iid", "server")
1371 $database["pconfig"] = array(
1372 "comment" => "personal (per user) configuration storage",
1374 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1375 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
1376 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""),
1377 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""),
1378 "v" => array("type" => "mediumtext", "comment" => ""),
1381 "PRIMARY" => array("id"),
1382 "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
1385 $database["photo"] = array(
1386 "comment" => "photo storage",
1388 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1389 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
1390 "contact-id" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("contact" => "id"), "comment" => ""),
1391 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""),
1392 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1393 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1394 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1395 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1396 "desc" => array("type" => "text", "comment" => ""),
1397 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1398 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1399 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1400 "height" => array("type" => "smallint", "not null" => "1", "default" => "0", "comment" => ""),
1401 "width" => array("type" => "smallint", "not null" => "1", "default" => "0", "comment" => ""),
1402 "datasize" => array("type" => "int", "not null" => "1", "default" => "0", "comment" => ""),
1403 "data" => array("type" => "mediumblob", "not null" => "1", "comment" => ""),
1404 "scale" => array("type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""),
1405 "profile" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1406 "allow_cid" => array("type" => "mediumtext", "comment" => ""),
1407 "allow_gid" => array("type" => "mediumtext", "comment" => ""),
1408 "deny_cid" => array("type" => "mediumtext", "comment" => ""),
1409 "deny_gid" => array("type" => "mediumtext", "comment" => ""),
1412 "PRIMARY" => array("id"),
1413 "contactid" => array("contact-id"),
1414 "uid_contactid" => array("uid", "contact-id"),
1415 "uid_profile" => array("uid", "profile"),
1416 "uid_album_scale_created" => array("uid", "album(32)", "scale", "created"),
1417 "uid_album_resource-id_created" => array("uid", "album(32)", "resource-id(64)", "created"),
1418 "resource-id" => array("resource-id(64)"),
1421 $database["poll"] = array(
1422 "comment" => "Currently unused table for storing poll results",
1424 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1425 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
1426 "q0" => array("type" => "text", "comment" => ""),
1427 "q1" => array("type" => "text", "comment" => ""),
1428 "q2" => array("type" => "text", "comment" => ""),
1429 "q3" => array("type" => "text", "comment" => ""),
1430 "q4" => array("type" => "text", "comment" => ""),
1431 "q5" => array("type" => "text", "comment" => ""),
1432 "q6" => array("type" => "text", "comment" => ""),
1433 "q7" => array("type" => "text", "comment" => ""),
1434 "q8" => array("type" => "text", "comment" => ""),
1435 "q9" => array("type" => "text", "comment" => ""),
1438 "PRIMARY" => array("id"),
1439 "uid" => array("uid"),
1442 $database["poll_result"] = array(
1443 "comment" => "data for polls - currently unused",
1445 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1446 "poll_id" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("poll" => "id")),
1447 "choice" => array("type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""),
1450 "PRIMARY" => array("id"),
1451 "poll_id" => array("poll_id"),
1454 $database["process"] = array(
1455 "comment" => "Currently running system processes",
1457 "pid" => array("type" => "int", "not null" => "1", "primary" => "1", "comment" => ""),
1458 "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => "", "comment" => ""),
1459 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1462 "PRIMARY" => array("pid"),
1463 "command" => array("command"),
1466 $database["profile"] = array(
1467 "comment" => "user profiles data",
1469 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1470 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
1471 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1472 "is-default" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1473 "hide-friends" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1474 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1475 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1476 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01", "comment" => ""),
1477 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1478 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1479 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1480 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""),
1481 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1482 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1483 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""),
1484 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1485 "with" => array("type" => "text", "comment" => ""),
1486 "howlong" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1487 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1488 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1489 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1490 "pub_keywords" => array("type" => "text", "comment" => ""),
1491 "prv_keywords" => array("type" => "text", "comment" => ""),
1492 "likes" => array("type" => "text", "comment" => ""),
1493 "dislikes" => array("type" => "text", "comment" => ""),
1494 "about" => array("type" => "text", "comment" => ""),
1495 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1496 "music" => array("type" => "text", "comment" => ""),
1497 "book" => array("type" => "text", "comment" => ""),
1498 "tv" => array("type" => "text", "comment" => ""),
1499 "film" => array("type" => "text", "comment" => ""),
1500 "interest" => array("type" => "text", "comment" => ""),
1501 "romance" => array("type" => "text", "comment" => ""),
1502 "work" => array("type" => "text", "comment" => ""),
1503 "education" => array("type" => "text", "comment" => ""),
1504 "contact" => array("type" => "text", "comment" => ""),
1505 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1506 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1507 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1508 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1509 "publish" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1510 "net-publish" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1513 "PRIMARY" => array("id"),
1514 "uid_is-default" => array("uid", "is-default"),
1517 $database["profile_check"] = array(
1518 "comment" => "DFRN remote auth use",
1520 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1521 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
1522 "cid" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("contact" => "id"), "comment" => ""),
1523 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1524 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1525 "expire" => array("type" => "int", "not null" => "1", "default" => "0", "comment" => ""),
1528 "PRIMARY" => array("id"),
1531 $database["push_subscriber"] = array(
1532 "comment" => "Used for OStatus: Contains feed subscribers",
1534 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1535 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
1536 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1537 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1538 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1539 "push" => array("type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""),
1540 "last_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1541 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1544 "PRIMARY" => array("id"),
1547 $database["queue"] = array(
1548 "comment" => "Queue for messages that couldn't be delivered",
1550 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1551 "cid" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("contact" => "id"), "comment" => ""),
1552 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""),
1553 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1554 "last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1555 "content" => array("type" => "mediumtext", "comment" => ""),
1556 "batch" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1559 "PRIMARY" => array("id"),
1560 "cid" => array("cid"),
1561 "created" => array("created"),
1562 "last" => array("last"),
1563 "network" => array("network"),
1564 "batch" => array("batch"),
1567 $database["register"] = array(
1568 "comment" => "registrations requiring admin approval",
1570 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1571 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1572 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1573 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
1574 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1575 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => "", "comment" => ""),
1576 "note" => array("type" => "text", "comment" => ""),
1579 "PRIMARY" => array("id"),
1582 $database["search"] = array(
1585 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1586 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
1587 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1590 "PRIMARY" => array("id"),
1591 "uid" => array("uid"),
1594 $database["session"] = array(
1595 "comment" => "web session storage",
1597 "id" => array("type" => "bigint", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1598 "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""),
1599 "data" => array("type" => "text", "comment" => ""),
1600 "expire" => array("type" => "int", "not null" => "1", "default" => "0", "comment" => ""),
1603 "PRIMARY" => array("id"),
1604 "sid" => array("sid(64)"),
1605 "expire" => array("expire"),
1608 $database["sign"] = array(
1609 "comment" => "Diaspora signatures",
1611 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1612 "iid" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("item" => "id"), "comment" => ""),
1613 "signed_text" => array("type" => "mediumtext", "comment" => ""),
1614 "signature" => array("type" => "text", "comment" => ""),
1615 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1618 "PRIMARY" => array("id"),
1619 "iid" => array("UNIQUE", "iid"),
1622 $database["term"] = array(
1623 "comment" => "item taxonomy (categories, tags, etc.) table",
1625 "tid" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1626 "oid" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("item" => "id"), "comment" => ""),
1627 "otype" => array("type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""),
1628 "type" => array("type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""),
1629 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1630 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1631 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1632 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1633 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1634 "global" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1635 "aid" => array("type" => "int", "not null" => "1", "default" => "0", "comment" => ""),
1636 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
1639 "PRIMARY" => array("tid"),
1640 "oid_otype_type_term" => array("oid","otype","type","term(32)"),
1641 "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"),
1642 "uid_otype_type_url" => array("uid","otype","type","url(64)"),
1643 "guid" => array("guid(64)"),
1646 $database["thread"] = array(
1647 "comment" => "Thread related data",
1649 "iid" => array("type" => "int", "not null" => "1", "default" => "0", "primary" => "1", "relation" => array("item" => "id"), "comment" => ""),
1650 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
1651 "contact-id" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("contact" => "id"), "comment" => ""),
1652 "gcontact-id" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id"), "comment" => ""),
1653 "owner-id" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("contact" => "id"), "comment" => ""),
1654 "author-id" => array("type" => "int", "not null" => "1", "default" => "0", "relation" => array("contact" => "id"), "comment" => ""),
1655 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1656 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1657 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1658 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1659 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1660 "wall" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1661 "private" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1662 "pubmail" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1663 "moderated" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1664 "visible" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1665 "spam" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1666 "starred" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1667 "ignored" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1668 "bookmark" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1669 "unseen" => array("type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""),
1670 "deleted" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1671 "origin" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1672 "forum_mode" => array("type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""),
1673 "mention" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1674 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""),
1677 "PRIMARY" => array("iid"),
1678 "uid_network_commented" => array("uid","network","commented"),
1679 "uid_network_created" => array("uid","network","created"),
1680 "uid_contactid_commented" => array("uid","contact-id","commented"),
1681 "uid_contactid_created" => array("uid","contact-id","created"),
1682 "contactid" => array("contact-id"),
1683 "ownerid" => array("owner-id"),
1684 "authorid" => array("author-id"),
1685 "uid_created" => array("uid","created"),
1686 "uid_commented" => array("uid","commented"),
1687 "uid_wall_created" => array("uid","wall","created"),
1688 "private_wall_commented" => array("private","wall","commented"),
1691 $database["tokens"] = array(
1692 "comment" => "OAuth usage",
1694 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1", "comment" => ""),
1695 "secret" => array("type" => "text", "comment" => ""),
1696 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
1697 "expires" => array("type" => "int", "not null" => "1", "default" => "0", "comment" => ""),
1698 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""),
1699 "uid" => array("type" => "mediumint", "not null" => "1", "default" => "0", "relation" => array("user" => "uid"), "comment" => "User id"),
1702 "PRIMARY" => array("id"),
1705 $database["user"] = array(
1706 "comment" => "The local users",
1708 "uid" => array("type" => "mediumint", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1709 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""),
1710 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1711 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1712 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1713 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1714 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1715 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => ""),
1716 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en", "comment" => ""),
1717 "register_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1718 "login_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1719 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1720 "allow_location" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1721 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1722 "pubkey" => array("type" => "text", "comment" => ""),
1723 "prvkey" => array("type" => "text", "comment" => ""),
1724 "spubkey" => array("type" => "text", "comment" => ""),
1725 "sprvkey" => array("type" => "text", "comment" => ""),
1726 "verified" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1727 "blocked" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1728 "blockwall" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1729 "hidewall" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1730 "blocktags" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1731 "unkmail" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1732 "cntunkmail" => array("type" => "int", "not null" => "1", "default" => "10", "comment" => ""),
1733 "notify-flags" => array("type" => "smallint unsigned", "not null" => "1", "default" => "65535", "comment" => ""),
1734 "page-flags" => array("type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""),
1735 "account-type" => array("type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""),
1736 "prvnets" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1737 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""),
1738 "maxreq" => array("type" => "int", "not null" => "1", "default" => "10", "comment" => ""),
1739 "expire" => array("type" => "int", "not null" => "1", "default" => "0", "comment" => ""),
1740 "account_removed" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1741 "account_expired" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""),
1742 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1743 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""),
1744 "def_gid" => array("type" => "int", "not null" => "1", "default" => "0", "comment" => ""),
1745 "allow_cid" => array("type" => "mediumtext", "comment" => ""),
1746 "allow_gid" => array("type" => "mediumtext", "comment" => ""),
1747 "deny_cid" => array("type" => "mediumtext", "comment" => ""),
1748 "deny_gid" => array("type" => "mediumtext", "comment" => ""),
1749 "openidserver" => array("type" => "text", "comment" => ""),
1752 "PRIMARY" => array("uid"),
1753 "nickname" => array("nickname(32)"),
1756 $database["userd"] = array(
1757 "comment" => "Deleted usernames",
1759 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""),
1760 "username" => array("type" => "varchar(255)", "not null" => "1", "comment" => ""),
1763 "PRIMARY" => array("id"),
1764 "username" => array("username(32)"),
1767 $database["workerqueue"] = array(
1768 "comment" => "Background tasks queue entries",
1770 "id" => array("type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "Auto incremented worker task id"),
1771 "parameter" => array("type" => "text", "comment" => "Task command"),
1772 "priority" => array("type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Task priority"),
1773 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Creation date"),
1774 "pid" => array("type" => "int", "not null" => "1", "default" => "0", "comment" => "Process id of the worker"),
1775 "executed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Execution date"),
1776 "done" => array("type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Marked when the task was done, will be deleted later"),
1779 "PRIMARY" => array("id"),
1780 "pid" => array("pid"),
1781 "parameter" => array("parameter(64)"),
1782 "priority_created" => array("priority", "created"),
1783 "executed" => array("executed"),