3 * @file src/Database/DBStructure.php
5 namespace Friendica\Database;
8 use Friendica\Core\Config;
9 use Friendica\Core\L10n;
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.
24 * Converts all tables from MyISAM to InnoDB
26 public static function convertToInnoDB() {
27 $r = q("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `engine` = 'MyISAM' AND `table_schema` = '%s'",
28 dbesc(dba::database_name()));
30 if (!DBM::is_result($r)) {
31 echo L10n::t('There are no tables on MyISAM.')."\n";
35 foreach ($r AS $table) {
36 $sql = sprintf("ALTER TABLE `%s` engine=InnoDB;", dbesc($table['TABLE_NAME']));
39 $result = dba::e($sql);
40 if (!DBM::is_result($result)) {
41 self::printUpdateError($sql);
47 * send the email and do what is needed to do on update fails
49 * @param update_id (int) number of failed update
50 * @param error_message (str) error message
52 public static function updateFail($update_id, $error_message) {
55 //send the administrators an e-mail
56 $admin_mail_list = "'".implode("','", array_map('dbesc', explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
57 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
62 if (!DBM::is_result($adminlist)) {
63 logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_NORMAL);
69 // every admin could had different language
70 foreach ($adminlist as $admin) {
71 $lang = (($admin['language'])?$admin['language']:'en');
72 L10n::pushLang($lang);
74 $preamble = deindent(L10n::t("
75 The friendica developers released update %s recently,
76 but when I tried to install it, something went terribly wrong.
77 This needs to be fixed soon and I can't do it alone. Please contact a
78 friendica developer if you can not help me on your own. My database might be invalid."));
79 $body = L10n::t("The error message is\n[pre]%s[/pre]");
80 $preamble = sprintf($preamble, $update_id);
81 $body = sprintf($body, $error_message);
84 'type' => SYSTEM_EMAIL,
85 'to_email' => $admin['email'],
86 'preamble' => $preamble,
93 logger("CRITICAL: Database structure update failed: ".$error_message);
97 private static function tableStructure($table) {
98 $structures = q("DESCRIBE `%s`", $table);
100 $full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table);
102 $indexes = q("SHOW INDEX FROM `%s`", $table);
104 $table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table);
106 if (DBM::is_result($table_status)) {
107 $table_status = $table_status[0];
115 if (DBM::is_result($indexes)) {
116 foreach ($indexes AS $index) {
117 if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
118 $indexdata[$index["Key_name"]] = ['UNIQUE'];
121 $column = $index["Column_name"];
123 if ($index["Sub_part"] != "") {
124 $column .= "(".$index["Sub_part"].")";
127 $indexdata[$index["Key_name"]][] = $column;
130 if (DBM::is_result($structures)) {
131 foreach ($structures AS $field) {
132 // Replace the default size values so that we don't have to define them
133 $search = ['tinyint(1)', 'tinyint(3) unsigned', 'tinyint(4)', 'smallint(5) unsigned', 'smallint(6)', 'mediumint(8) unsigned', 'mediumint(9)', 'bigint(20)', 'int(10) unsigned', 'int(11)'];
134 $replace = ['boolean', 'tinyint unsigned', 'tinyint', 'smallint unsigned', 'smallint', 'mediumint unsigned', 'mediumint', 'bigint', 'int unsigned', 'int'];
135 $field["Type"] = str_replace($search, $replace, $field["Type"]);
137 $fielddata[$field["Field"]]["type"] = $field["Type"];
138 if ($field["Null"] == "NO") {
139 $fielddata[$field["Field"]]["not null"] = true;
142 if (isset($field["Default"])) {
143 $fielddata[$field["Field"]]["default"] = $field["Default"];
146 if ($field["Extra"] != "") {
147 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
150 if ($field["Key"] == "PRI") {
151 $fielddata[$field["Field"]]["primary"] = true;
155 if (DBM::is_result($full_columns)) {
156 foreach ($full_columns AS $column) {
157 $fielddata[$column["Field"]]["Collation"] = $column["Collation"];
158 $fielddata[$column["Field"]]["comment"] = $column["Comment"];
162 return ["fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status];
165 public static function printStructure() {
166 $database = self::definition();
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 self::createTable($name, $structure, true, false);
183 * @brief Print out database error messages
185 * @param string $message Message to be added to the error message
187 * @return string Error message
189 private static function printUpdateError($message) {
190 echo L10n::t("\nError %d occurred during database update:\n%s\n",
191 dba::errorNo(), dba::errorMessage());
193 return L10n::t('Errors encountered performing database changes: ').$message.EOL;
197 * Updates DB structure and returns eventual errors messages
199 * @param bool $verbose
200 * @param bool $action Whether to actually apply the update
201 * @param bool $install Is this the initial update during the installation?
202 * @param array $tables An array of the database tables
203 * @param array $definition An array of the definition tables
204 * @return string Empty string if the update is successful, error messages otherwise
206 public static function update($verbose, $action, $install = false, array $tables = null, array $definition = null) {
207 if ($action && !$install) {
208 Config::set('system', 'maintenance', 1);
209 Config::set('system', 'maintenance_reason', L10n::t('%s: Database update', DBM::date().' '.date('e')));
214 logger('updating structure', LOGGER_DEBUG);
216 // Get the current structure
219 if (is_null($tables)) {
220 $tables = q("SHOW TABLES");
223 if (DBM::is_result($tables)) {
224 foreach ($tables AS $table) {
225 $table = current($table);
227 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
228 $database[$table] = self::tableStructure($table);
232 // Get the definition
233 if (is_null($definition)) {
234 $definition = self::definition();
237 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
238 if ((version_compare(dba::server_info(), '5.7.4') >= 0) &&
239 !(strpos(dba::server_info(), 'MariaDB') !== false)) {
246 foreach ($definition AS $name => $structure) {
247 $is_new_table = false;
252 if (!isset($database[$name])) {
253 $r = self::createTable($name, $structure, $verbose, $action);
254 if (!DBM::is_result($r)) {
255 $errors .= self::printUpdateError($name);
257 $is_new_table = true;
259 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
260 if (isset($database[$name]["indexes"][$indexname])) {
261 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
263 $current_index_definition = "__NOT_SET__";
265 $new_index_definition = implode(",",$fieldnames);
266 if ($current_index_definition != $new_index_definition) {
267 if ($fieldnames[0] == "UNIQUE") {
270 $temp_name = "temp-".$name;
277 * Drop the index if it isn't present in the definition
278 * or the definition differ from current status
279 * and index name doesn't start with "local_"
281 foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
282 $current_index_definition = implode(",",$fieldnames);
283 if (isset($structure["indexes"][$indexname])) {
284 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
286 $new_index_definition = "__NOT_SET__";
288 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
289 $sql2=self::dropIndex($indexname);
291 $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
297 // Compare the field structure field by field
298 foreach ($structure["fields"] AS $fieldname => $parameters) {
299 if (!isset($database[$name]["fields"][$fieldname])) {
300 $sql2=self::addTableField($fieldname, $parameters);
302 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
307 // Compare the field definition
308 $field_definition = $database[$name]["fields"][$fieldname];
310 // Remove the relation data that is used for the referential integrity
311 unset($parameters['relation']);
313 // We change the collation after the indexes had been changed.
314 // This is done to avoid index length problems.
315 // So here we always ensure that there is no need to change it.
316 unset($parameters['Collation']);
317 unset($field_definition['Collation']);
319 // Only update the comment when it is defined
320 if (!isset($parameters['comment'])) {
321 $parameters['comment'] = "";
324 $current_field_definition = dba::clean_query(implode(",", $field_definition));
325 $new_field_definition = dba::clean_query(implode(",", $parameters));
326 if ($current_field_definition != $new_field_definition) {
327 $sql2 = self::modifyTableField($fieldname, $parameters);
329 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
339 * Create the index if the index don't exists in database
340 * or the definition differ from the current status.
341 * Don't create keys if table is new
343 if (!$is_new_table) {
344 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
345 if (isset($database[$name]["indexes"][$indexname])) {
346 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
348 $current_index_definition = "__NOT_SET__";
350 $new_index_definition = implode(",",$fieldnames);
351 if ($current_index_definition != $new_index_definition) {
352 $sql2 = self::createIndex($indexname, $fieldnames);
354 // Fetch the "group by" fields for unique indexes
355 if ($fieldnames[0] == "UNIQUE") {
356 $group_by = self::groupBy($indexname, $fieldnames);
360 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
368 if (isset($database[$name]["table_status"]["Comment"])) {
369 if ($database[$name]["table_status"]["Comment"] != $structure['comment']) {
370 $sql2 = "COMMENT = '".dbesc($structure['comment'])."'";
373 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
380 if (isset($database[$name]["table_status"]["Engine"]) && isset($structure['engine'])) {
381 if ($database[$name]["table_status"]["Engine"] != $structure['engine']) {
382 $sql2 = "ENGINE = '".dbesc($structure['engine'])."'";
385 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
392 if (isset($database[$name]["table_status"]["Collation"])) {
393 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
394 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
397 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
408 // Now have a look at the field collations
409 // Compare the field structure field by field
410 foreach ($structure["fields"] AS $fieldname => $parameters) {
411 // Compare the field definition
412 $field_definition = defaults($database[$name]["fields"], $fieldname, ['Collation' => '']);
414 // Define the default collation if not given
415 if (!isset($parameters['Collation']) && !empty($field_definition['Collation'])) {
416 $parameters['Collation'] = 'utf8mb4_general_ci';
418 $parameters['Collation'] = null;
421 if ($field_definition['Collation'] != $parameters['Collation']) {
422 $sql2 = self::modifyTableField($fieldname, $parameters);
423 if (($sql3 == "") || (substr($sql3, -2, 2) == "; ")) {
424 $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
433 if (substr($sql3, -2, 2) != "; ") {
438 if ($is_unique && $ignore == '') {
439 foreach ($database[$name]["fields"] AS $fieldname => $parameters) {
440 $field_list .= 'ANY_VALUE(`' . $fieldname . '`),';
442 $field_list = rtrim($field_list, ',');
446 // Ensure index conversion to unique removes duplicates
447 if ($is_unique && ($temp_name != $name)) {
449 echo "SET session old_alter_table=1;\n";
451 echo "DROP TABLE IF EXISTS `".$temp_name."`;\n";
452 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
458 if ($is_unique && ($temp_name != $name)) {
460 echo "SET session old_alter_table=0;\n";
462 echo "INSERT INTO `".$temp_name."` SELECT ".dba::any_value_fallback($field_list)." FROM `".$name."`".$group_by.";\n";
463 echo "DROP TABLE `".$name."`;\n";
464 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
471 Config::set('system', 'maintenance_reason', L10n::t('%s: updating %s table.', DBM::date().' '.date('e'), $name));
474 // Ensure index conversion to unique removes duplicates
475 if ($is_unique && ($temp_name != $name)) {
477 dba::e("SET session old_alter_table=1;");
479 $r = dba::e("DROP TABLE IF EXISTS `".$temp_name."`;");
480 if (!DBM::is_result($r)) {
481 $errors .= self::printUpdateError($sql3);
485 $r = dba::e("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
486 if (!DBM::is_result($r)) {
487 $errors .= self::printUpdateError($sql3);
494 if (!DBM::is_result($r)) {
495 $errors .= self::printUpdateError($sql3);
497 if ($is_unique && ($temp_name != $name)) {
499 dba::e("SET session old_alter_table=0;");
501 $r = dba::e("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
502 if (!DBM::is_result($r)) {
503 $errors .= self::printUpdateError($sql3);
506 $r = dba::e("DROP TABLE `".$name."`;");
507 if (!DBM::is_result($r)) {
508 $errors .= self::printUpdateError($sql3);
511 $r = dba::e("RENAME TABLE `".$temp_name."` TO `".$name."`;");
512 if (!DBM::is_result($r)) {
513 $errors .= self::printUpdateError($sql3);
522 if ($action && !$install) {
523 Config::set('system', 'maintenance', 0);
524 Config::set('system', 'maintenance_reason', '');
527 Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
529 Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
536 private static function FieldCommand($parameters, $create = true) {
537 $fieldstruct = $parameters["type"];
539 if (isset($parameters["Collation"])) {
540 $fieldstruct .= " COLLATE ".$parameters["Collation"];
543 if (isset($parameters["not null"])) {
544 $fieldstruct .= " NOT NULL";
547 if (isset($parameters["default"])) {
548 if (strpos(strtolower($parameters["type"]),"int")!==false) {
549 $fieldstruct .= " DEFAULT ".$parameters["default"];
551 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
554 if (isset($parameters["extra"])) {
555 $fieldstruct .= " ".$parameters["extra"];
558 if (isset($parameters["comment"])) {
559 $fieldstruct .= " COMMENT '".dbesc($parameters["comment"])."'";
562 /*if (($parameters["primary"] != "") && $create)
563 $fieldstruct .= " PRIMARY KEY";*/
565 return($fieldstruct);
568 private static function createTable($name, $structure, $verbose, $action) {
575 foreach ($structure["fields"] AS $fieldname => $field) {
576 $sql_rows[] = "`".dbesc($fieldname)."` ".self::FieldCommand($field);
577 if (x($field,'primary') && $field['primary']!='') {
578 $primary_keys[] = $fieldname;
582 if (!empty($structure["indexes"])) {
583 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
584 $sql_index = self::createIndex($indexname, $fieldnames, "");
585 if (!is_null($sql_index)) {
586 $sql_rows[] = $sql_index;
591 if (isset($structure["engine"])) {
592 $engine = " ENGINE=" . $structure["engine"];
595 if (isset($structure["comment"])) {
596 $comment = " COMMENT='" . dbesc($structure["comment"]) . "'";
599 $sql = implode(",\n\t", $sql_rows);
601 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql.
602 "\n)" . $engine . " DEFAULT COLLATE utf8mb4_general_ci" . $comment;
614 private static function addTableField($fieldname, $parameters) {
615 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), self::FieldCommand($parameters));
619 private static function modifyTableField($fieldname, $parameters) {
620 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), self::FieldCommand($parameters, false));
624 private static function dropIndex($indexname) {
625 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
629 private static function createIndex($indexname, $fieldnames, $method = "ADD") {
630 $method = strtoupper(trim($method));
631 if ($method!="" && $method!="ADD") {
632 throw new \Exception("Invalid parameter 'method' in self::createIndex(): '$method'");
635 if ($fieldnames[0] == "UNIQUE") {
636 array_shift($fieldnames);
637 $method .= ' UNIQUE';
641 foreach ($fieldnames AS $fieldname) {
646 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
647 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
649 $names .= "`".dbesc($fieldname)."`";
653 if ($indexname == "PRIMARY") {
654 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
658 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
662 private static function groupBy($indexname, $fieldnames) {
663 if ($fieldnames[0] != "UNIQUE") {
667 array_shift($fieldnames);
670 foreach ($fieldnames AS $fieldname) {
675 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
676 $names .= "`".dbesc($matches[1])."`";
678 $names .= "`".dbesc($fieldname)."`";
682 $sql = sprintf(" GROUP BY %s", $names);
686 public static function definition() {
689 $database["addon"] = [
690 "comment" => "registered addons",
692 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
693 "name" => ["type" => "varchar(50)", "not null" => "1", "default" => "", "comment" => "addon base (file)name"],
694 "version" => ["type" => "varchar(50)", "not null" => "1", "default" => "", "comment" => "currently unused"],
695 "installed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "currently always 1"],
696 "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "currently unused"],
697 "timestamp" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "file timestamp to check for reloads"],
698 "plugin_admin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 = has admin config, 0 = has no admin config"],
702 "name" => ["UNIQUE", "name"],
705 $database["attach"] = [
706 "comment" => "file attachments",
708 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "generated index"],
709 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
710 "hash" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "hash"],
711 "filename" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "filename of original"],
712 "filetype" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "mimetype"],
713 "filesize" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "size in bytes"],
714 "data" => ["type" => "longblob", "not null" => "1", "comment" => "file data"],
715 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation time"],
716 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "last edit time"],
717 "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>"],
718 "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"],
719 "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"],
720 "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"],
726 $database["auth_codes"] = [
727 "comment" => "OAuth usage",
729 "id" => ["type" => "varchar(40)", "not null" => "1", "primary" => "1", "comment" => ""],
730 "client_id" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => ["clients" => "client_id"], "comment" => ""],
731 "redirect_uri" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
732 "expires" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
733 "scope" => ["type" => "varchar(250)", "not null" => "1", "default" => "", "comment" => ""],
739 $database["cache"] = [
740 "comment" => "Stores temporary data",
742 "k" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "cache key"],
743 "v" => ["type" => "mediumtext", "comment" => "cached serialized value"],
744 "expires" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of cache expiration"],
745 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of cache insertion"],
749 "k_expires" => ["k", "expires"],
752 $database["challenge"] = [
755 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
756 "challenge" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
757 "dfrn-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
758 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
759 "type" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
760 "last_update" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
766 $database["clients"] = [
767 "comment" => "OAuth usage",
769 "client_id" => ["type" => "varchar(20)", "not null" => "1", "primary" => "1", "comment" => ""],
770 "pw" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => ""],
771 "redirect_uri" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
772 "name" => ["type" => "text", "comment" => ""],
773 "icon" => ["type" => "text", "comment" => ""],
774 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
777 "PRIMARY" => ["client_id"],
780 $database["config"] = [
781 "comment" => "main configuration storage",
783 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
784 "cat" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""],
785 "k" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""],
786 "v" => ["type" => "mediumtext", "comment" => ""],
790 "cat_k" => ["UNIQUE", "cat", "k"],
793 $database["contact"] = [
794 "comment" => "contact table",
796 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
797 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
798 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
799 "self" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 if the contact is the user him/her self"],
800 "remote_self" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
801 "rel" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "The kind of the relation between the user and the contact"],
802 "duplex" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
803 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Network protocol of the contact"],
804 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this contact is known by"],
805 "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Nick- and user name of the contact"],
806 "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
807 "about" => ["type" => "text", "comment" => ""],
808 "keywords" => ["type" => "text", "comment" => "public keywords (interests) of the contact"],
809 "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
810 "xmpp" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
811 "attag" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
812 "avatar" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
813 "photo" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo of the contact"],
814 "thumb" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo (thumb size)"],
815 "micro" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo (micro size)"],
816 "site-pubkey" => ["type" => "text", "comment" => ""],
817 "issued-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
818 "dfrn-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
819 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
820 "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
821 "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
822 "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
823 "pubkey" => ["type" => "text", "comment" => "RSA public key 4096 bit"],
824 "prvkey" => ["type" => "text", "comment" => "RSA private key 4096 bit"],
825 "batch" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
826 "request" => ["type" => "varchar(255)", "comment" => ""],
827 "notify" => ["type" => "varchar(255)", "comment" => ""],
828 "poll" => ["type" => "varchar(255)", "comment" => ""],
829 "confirm" => ["type" => "varchar(255)", "comment" => ""],
830 "poco" => ["type" => "varchar(255)", "comment" => ""],
831 "aes_allow" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
832 "ret-aes" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
833 "usehub" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
834 "subhub" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
835 "hub-verify" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
836 "last-update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of the last try to update the contact info"],
837 "success_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of the last successful contact update"],
838 "failure_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of the last failed update"],
839 "name-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
840 "uri-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
841 "avatar-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
842 "term-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
843 "last-item" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "date of the last post"],
844 "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
845 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
846 "readonly" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "posts of the contact are readonly"],
847 "writable" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
848 "forum" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "contact is a forum"],
849 "prv" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "contact is a private group"],
850 "contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
851 "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
852 "archive" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
853 "pending" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
854 "rating" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
855 "reason" => ["type" => "text", "comment" => ""],
856 "closeness" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "99", "comment" => ""],
857 "info" => ["type" => "mediumtext", "comment" => ""],
858 "profile-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
859 "bdyear" => ["type" => "varchar(4)", "not null" => "1", "default" => "", "comment" => ""],
860 "bd" => ["type" => "date", "not null" => "1", "default" => "0001-01-01", "comment" => ""],
861 "notify_new_posts" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
862 "fetch_further_information" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
863 "ffi_keyword_blacklist" => ["type" => "text", "comment" => ""],
867 "uid_name" => ["uid", "name(190)"],
868 "self_uid" => ["self", "uid"],
869 "alias_uid" => ["alias(32)", "uid"],
870 "pending_uid" => ["pending", "uid"],
871 "blocked_uid" => ["blocked", "uid"],
872 "uid_rel_network_poll" => ["uid", "rel", "network", "poll(64)", "archive"],
873 "uid_network_batch" => ["uid", "network", "batch(64)"],
874 "addr_uid" => ["addr(32)", "uid"],
875 "nurl_uid" => ["nurl(32)", "uid"],
876 "nick_uid" => ["nick(32)", "uid"],
877 "dfrn-id" => ["dfrn-id(64)"],
878 "issued-id" => ["issued-id(64)"],
881 $database["conv"] = [
882 "comment" => "private messages",
884 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
885 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this conversation"],
886 "recips" => ["type" => "text", "comment" => "sender_handle;recipient_handle"],
887 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
888 "creator" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "handle of creator"],
889 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation timestamp"],
890 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "edited timestamp"],
891 "subject" => ["type" => "text", "comment" => "subject of initial message"],
898 $database["conversation"] = [
899 "comment" => "Raw data and structure information for messages",
901 "item-uri" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "URI of the item"],
902 "reply-to-uri" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => "URI to which this item is a reply"],
903 "conversation-uri" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => "GNU Social conversation URI"],
904 "conversation-href" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => "GNU Social conversation link"],
905 "protocol" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "The protocol of the item"],
906 "source" => ["type" => "mediumtext", "comment" => "Original source"],
907 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Receiving date"],
910 "PRIMARY" => ["item-uri"],
911 "conversation-uri" => ["conversation-uri"],
912 "received" => ["received"],
915 $database["event"] = [
916 "comment" => "Events",
918 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
919 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
920 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
921 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact_id (ID of the contact in contact table)"],
922 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
923 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation time"],
924 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "last edit time"],
925 "start" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "event start time"],
926 "finish" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "event end time"],
927 "summary" => ["type" => "text", "comment" => "short description or title of the event"],
928 "desc" => ["type" => "text", "comment" => "event description"],
929 "location" => ["type" => "text", "comment" => "event location"],
930 "type" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => "event or birthday"],
931 "nofinish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if event does have no end this is 1"],
932 "adjust" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => "adjust to timezone of the recipient (0 or 1)"],
933 "ignore" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "0 or 1"],
934 "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>'"],
935 "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"],
936 "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"],
937 "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"],
941 "uid_start" => ["uid", "start"],
944 $database["fcontact"] = [
945 "comment" => "Diaspora compatible contacts - used in the Diaspora implementation",
947 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
948 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "unique id"],
949 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
950 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
951 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
952 "request" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
953 "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
954 "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
955 "batch" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
956 "notify" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
957 "poll" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
958 "confirm" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
959 "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
960 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
961 "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
962 "pubkey" => ["type" => "text", "comment" => ""],
963 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
967 "addr" => ["addr(32)"],
968 "url" => ["UNIQUE", "url(190)"],
971 $database["fsuggest"] = [
972 "comment" => "friend suggestion stuff",
974 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
975 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
976 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
977 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
978 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
979 "request" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
980 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
981 "note" => ["type" => "text", "comment" => ""],
982 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
988 $database["gcign"] = [
989 "comment" => "contacts ignored by friend suggestions",
991 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
992 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Local User id"],
993 "gcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => "gcontact.id of ignored contact"],
1001 $database["gcontact"] = [
1002 "comment" => "global contacts",
1004 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1005 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this contact is known by"],
1006 "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Nick- and user name of the contact"],
1007 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Link to the contacts profile page"],
1008 "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1009 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Link to the profile photo"],
1010 "connect" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1011 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1012 "updated" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1013 "last_contact" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1014 "last_failure" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1015 "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1016 "about" => ["type" => "text", "comment" => ""],
1017 "keywords" => ["type" => "text", "comment" => "puplic keywords (interests)"],
1018 "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1019 "birthday" => ["type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01", "comment" => ""],
1020 "community" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 if contact is forum account"],
1021 "contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "-1", "comment" => ""],
1022 "hide" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 = should be hidden from search"],
1023 "nsfw" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 = contact posts nsfw content"],
1024 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "social network protocol"],
1025 "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1026 "notify" => ["type" => "varchar(255)", "comment" => ""],
1027 "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1028 "generation" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1029 "server_url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "baseurl of the contacts server"],
1032 "PRIMARY" => ["id"],
1033 "nurl" => ["UNIQUE", "nurl(190)"],
1034 "name" => ["name(64)"],
1035 "nick" => ["nick(32)"],
1036 "addr" => ["addr(64)"],
1037 "hide_network_updated" => ["hide", "network", "updated"],
1038 "updated" => ["updated"],
1041 $database["glink"] = [
1042 "comment" => "'friends of friends' linkages derived from poco",
1044 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1045 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1046 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1047 "gcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""],
1048 "zcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""],
1049 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1052 "PRIMARY" => ["id"],
1053 "cid_uid_gcid_zcid" => ["UNIQUE", "cid","uid","gcid","zcid"],
1057 $database["group"] = [
1058 "comment" => "privacy groups, group info",
1060 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1061 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1062 "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 indicates the member list is not private"],
1063 "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 indicates the group has been deleted"],
1064 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "human readable name of group"],
1067 "PRIMARY" => ["id"],
1071 $database["group_member"] = [
1072 "comment" => "privacy groups, member info",
1074 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1075 "gid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["group" => "id"], "comment" => "groups.id of the associated group"],
1076 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id of the member assigned to the associated group"],
1079 "PRIMARY" => ["id"],
1080 "contactid" => ["contact-id"],
1081 "gid_contactid" => ["UNIQUE", "gid", "contact-id"],
1084 $database["gserver"] = [
1085 "comment" => "Global servers",
1087 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1088 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1089 "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1090 "version" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1091 "site_name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1092 "info" => ["type" => "text", "comment" => ""],
1093 "register_policy" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
1094 "registered-users" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "Number of registered users"],
1095 "poco" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1096 "noscrape" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1097 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
1098 "platform" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1099 "relay-subscribe" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Has the server subscribed to the relay system"],
1100 "relay-scope" => ["type" => "varchar(10)", "not null" => "1", "default" => "", "comment" => "The scope of messages that the server wants to get"],
1101 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1102 "last_poco_query" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1103 "last_contact" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1104 "last_failure" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1107 "PRIMARY" => ["id"],
1108 "nurl" => ["UNIQUE", "nurl(190)"],
1111 $database["gserver-tag"] = [
1112 "comment" => "Tags that the server has subscribed",
1114 "gserver-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gserver" => "id"], "primary" => "1", "comment" => "The id of the gserver"],
1115 "tag" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "primary" => "1", "comment" => "Tag that the server has subscribed"],
1118 "PRIMARY" => ["gserver-id", "tag"],
1122 $database["hook"] = [
1123 "comment" => "addon hook registry",
1125 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1126 "hook" => ["type" => "varbinary(100)", "not null" => "1", "default" => "", "comment" => "name of hook"],
1127 "file" => ["type" => "varbinary(200)", "not null" => "1", "default" => "", "comment" => "relative filename of hook handler"],
1128 "function" => ["type" => "varbinary(200)", "not null" => "1", "default" => "", "comment" => "function name of hook handler"],
1129 "priority" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => "not yet implemented - can be used to sort conflicts in hook handling by calling handlers in priority order"],
1132 "PRIMARY" => ["id"],
1133 "hook_file_function" => ["UNIQUE", "hook", "file", "function"],
1136 $database["intro"] = [
1139 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1140 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1141 "fid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["fcontact" => "id"], "comment" => ""],
1142 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1143 "knowyou" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1144 "duplex" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1145 "note" => ["type" => "text", "comment" => ""],
1146 "hash" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1147 "datetime" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1148 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
1149 "ignore" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1152 "PRIMARY" => ["id"],
1155 $database["item"] = [
1156 "comment" => "Structure for all posts",
1158 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => ["thread" => "iid"]],
1159 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this item"],
1160 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1161 "uri-hash" => ["type" => "varchar(80)", "not null" => "1", "default" => "", "comment" => "RIPEMD-128 hash from uri"],
1162 "parent" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => "item.id of the parent to this item if it is a reply of some form; otherwise this must be set to the id of this item"],
1163 "parent-uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "uri of the parent to this item"],
1164 "thr-parent" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "If the parent of this item is not the top-level item in the conversation, the uri of the immediate parent; otherwise set to parent-uri"],
1165 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Creation timestamp."],
1166 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last edit (default is created)"],
1167 "commented" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last comment/reply to this item"],
1168 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime"],
1169 "changed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date that something in the conversation changed, indicating clients should fetch the conversation again"],
1170 "gravity" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1171 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Network from where the item comes from"],
1172 "owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Link to the contact table with uid=0 of the owner of this item"],
1173 "author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Link to the contact table with uid=0 of the author of this item"],
1174 "icid" => ["type" => "int unsigned", "relation" => ["item-content" => "id"], "comment" => "Id of the item-content table entry that contains the whole item content"],
1175 "iaid" => ["type" => "int unsigned", "relation" => ["item-activity" => "id"], "comment" => "Id of the item-activity table entry that contains the activity data"],
1176 "extid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1177 "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1178 "private" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "distribution is restricted"],
1179 "bookmark" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been bookmarked"],
1180 "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1181 "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1182 "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been deleted"],
1183 // User specific fields. Eventually they will move to user-item
1184 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner id which owns this copy of the item"],
1185 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id"],
1186 "wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "This item was posted to the wall of uid"],
1187 "origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item originated at this site"],
1188 "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1189 "starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been favourited"],
1190 "unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => "item has not been seen"],
1191 "mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "The owner of this item was mentioned in it"],
1192 "forum_mode" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1193 // User specific fields. Should possible be replaced with something different
1194 "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>'"],
1195 "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"],
1196 "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"],
1197 "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"],
1198 "postopts" => ["type" => "text", "comment" => "External post connectors add their network name to this comma-separated string to identify that they should be delivered to these networks during delivery"],
1199 "inform" => ["type" => "mediumtext", "comment" => "Additional receivers of this post"],
1200 // It is to be decided whether these fields belong to the user or the structure
1201 "resource-id" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => "Used to link other tables to items, it identifies the linked resource (e.g. photo) and if set must also set resource_type"],
1202 "event-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["event" => "id"], "comment" => "Used to link to the event.id"],
1203 // Will be replaced by the "attach" table
1204 "attach" => ["type" => "mediumtext", "comment" => "JSON structure representing attachments to this item"],
1205 // Seems to be only used for notes, but is filled at many places.
1206 // Will be replaced with some general field that contain the values of "origin" and "wall" as well.
1207 "type" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => ""],
1208 // Deprecated fields. Will be removed in upcoming versions
1209 "file" => ["type" => "mediumtext", "comment" => "Deprecated"],
1210 "location" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1211 "coord" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1212 "tag" => ["type" => "mediumtext", "comment" => "Deprecated"],
1213 "plink" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1214 "title" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1215 "content-warning" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1216 "body" => ["type" => "mediumtext", "comment" => "Deprecated"],
1217 "app" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1218 "verb" => ["type" => "varchar(100)", "comment" => "Deprecated"],
1219 "object-type" => ["type" => "varchar(100)", "comment" => "Deprecated"],
1220 "object" => ["type" => "text", "comment" => "Deprecated"],
1221 "target-type" => ["type" => "varchar(100)", "comment" => "Deprecated"],
1222 "target" => ["type" => "text", "comment" => "Deprecated"],
1223 "author-name" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1224 "author-link" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1225 "author-avatar" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1226 "owner-name" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1227 "owner-link" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1228 "owner-avatar" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1229 "rendered-hash" => ["type" => "varchar(32)", "comment" => "Deprecated"],
1230 "rendered-html" => ["type" => "mediumtext", "comment" => "Deprecated"],
1233 "PRIMARY" => ["id"],
1234 "guid" => ["guid(191)"],
1235 "uri" => ["uri(191)"],
1236 "parent" => ["parent"],
1237 "parent-uri" => ["parent-uri(191)"],
1238 "extid" => ["extid(191)"],
1239 "uid_id" => ["uid","id"],
1240 "uid_contactid_id" => ["uid","contact-id","id"],
1241 "uid_created" => ["uid","created"],
1242 "uid_commented" => ["uid","commented"],
1243 "uid_unseen_contactid" => ["uid","unseen","contact-id"],
1244 "uid_network_received" => ["uid","network","received"],
1245 "uid_network_commented" => ["uid","network","commented"],
1246 "uid_thrparent" => ["uid","thr-parent(190)"],
1247 "uid_parenturi" => ["uid","parent-uri(190)"],
1248 "uid_contactid_created" => ["uid","contact-id","created"],
1249 "authorid_created" => ["author-id","created"],
1250 "ownerid" => ["owner-id"],
1251 "uid_uri" => ["uid", "uri(190)"],
1252 "resource-id" => ["resource-id"],
1253 "deleted_changed" => ["deleted","changed"],
1254 "uid_wall_changed" => ["uid","wall","changed"],
1255 "uid_eventid" => ["uid","event-id"],
1260 $database["item-activity"] = [
1261 "comment" => "Activities for items",
1263 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => ["thread" => "iid"]],
1264 "uri" => ["type" => "varchar(255)", "comment" => ""],
1265 "uri-hash" => ["type" => "varchar(80)", "not null" => "1", "default" => "", "comment" => "RIPEMD-128 hash from uri"],
1266 "activity" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1269 "PRIMARY" => ["id"],
1270 "uri-hash" => ["UNIQUE", "uri-hash"],
1271 "uri" => ["uri(191)"],
1274 $database["item-content"] = [
1275 "comment" => "Content for all posts",
1277 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => ["thread" => "iid"]],
1278 "uri" => ["type" => "varchar(255)", "comment" => ""],
1279 "uri-plink-hash" => ["type" => "varchar(80)", "not null" => "1", "default" => "", "comment" => "RIPEMD-128 hash from uri"],
1280 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "item title"],
1281 "content-warning" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1282 "body" => ["type" => "mediumtext", "comment" => "item body content"],
1283 "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "text location where this item originated"],
1284 "coord" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "longitude/latitude pair representing location where this item originated"],
1285 "language" => ["type" => "text", "comment" => "Language information about this post"],
1286 "app" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "application which generated this item"],
1287 "rendered-hash" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1288 "rendered-html" => ["type" => "mediumtext", "comment" => "item.body converted to html"],
1289 "object-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams object type"],
1290 "object" => ["type" => "text", "comment" => "JSON encoded object structure unless it is an implied object (normal post)"],
1291 "target-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams target type if applicable (URI)"],
1292 "target" => ["type" => "text", "comment" => "JSON encoded target structure if used"],
1293 "plink" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "permalink or URL to a displayable copy of the message at its source"],
1294 "verb" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams verb"],
1297 "PRIMARY" => ["id"],
1298 "uri-plink-hash" => ["UNIQUE", "uri-plink-hash"],
1299 "uri" => ["uri(191)"],
1302 $database["locks"] = [
1305 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1306 "name" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => ""],
1307 "locked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1308 "pid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "Process ID"],
1309 "expires" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of cache expiration"],
1312 "PRIMARY" => ["id"],
1313 "name_expires" => ["name", "expires"]
1316 $database["mail"] = [
1317 "comment" => "private messages",
1319 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1320 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1321 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this private message"],
1322 "from-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "name of the sender"],
1323 "from-photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "contact photo link of the sender"],
1324 "from-url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "profile linke of the sender"],
1325 "contact-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => ["contact" => "id"], "comment" => "contact.id"],
1326 "convid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["conv" => "id"], "comment" => "conv.id"],
1327 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1328 "body" => ["type" => "mediumtext", "comment" => ""],
1329 "seen" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if message visited it is 1"],
1330 "reply" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1331 "replied" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1332 "unknown" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if sender not in the contact table this is 1"],
1333 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1334 "parent-uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1335 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation time of the private message"],
1338 "PRIMARY" => ["id"],
1339 "uid_seen" => ["uid", "seen"],
1340 "convid" => ["convid"],
1341 "uri" => ["uri(64)"],
1342 "parent-uri" => ["parent-uri(64)"],
1343 "contactid" => ["contact-id(32)"],
1346 $database["mailacct"] = [
1347 "comment" => "Mail account data for fetching mails",
1349 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1350 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1351 "server" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1352 "port" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1353 "ssltype" => ["type" => "varchar(16)", "not null" => "1", "default" => "", "comment" => ""],
1354 "mailbox" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1355 "user" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1356 "pass" => ["type" => "text", "comment" => ""],
1357 "reply_to" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1358 "action" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1359 "movetofolder" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1360 "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1361 "last_check" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1364 "PRIMARY" => ["id"],
1367 $database["manage"] = [
1368 "comment" => "table of accounts that can manage each other",
1370 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1371 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1372 "mid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1375 "PRIMARY" => ["id"],
1376 "uid_mid" => ["UNIQUE", "uid","mid"],
1379 $database["notify"] = [
1380 "comment" => "notifications",
1382 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1383 "hash" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
1384 "type" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1385 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1386 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1387 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1388 "date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1389 "msg" => ["type" => "mediumtext", "comment" => ""],
1390 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1391 "link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1392 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => "item.id"],
1393 "parent" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1394 "seen" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1395 "verb" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => ""],
1396 "otype" => ["type" => "varchar(10)", "not null" => "1", "default" => "", "comment" => ""],
1397 "name_cache" => ["type" => "tinytext", "comment" => "Cached bbcode parsing of name"],
1398 "msg_cache" => ["type" => "mediumtext", "comment" => "Cached bbcode parsing of msg"]
1401 "PRIMARY" => ["id"],
1402 "hash_uid" => ["hash", "uid"],
1403 "seen_uid_date" => ["seen", "uid", "date"],
1404 "uid_date" => ["uid", "date"],
1405 "uid_type_link" => ["uid", "type", "link(190)"],
1408 $database["notify-threads"] = [
1411 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1412 "notify-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["notify" => "id"], "comment" => ""],
1413 "master-parent-item" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1414 "parent-item" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1415 "receiver-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1418 "PRIMARY" => ["id"],
1421 $database["oembed"] = [
1422 "comment" => "cache for OEmbed queries",
1424 "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "page url"],
1425 "maxwidth" => ["type" => "mediumint unsigned", "not null" => "1", "primary" => "1", "comment" => "Maximum width passed to Oembed"],
1426 "content" => ["type" => "mediumtext", "comment" => "OEmbed data of the page"],
1427 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of creation"],
1430 "PRIMARY" => ["url", "maxwidth"],
1431 "created" => ["created"],
1434 $database["openwebauth-token"] = [
1435 "comment" => "Store OpenWebAuth token to verify contacts",
1437 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1438 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1439 "type" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => "Verify type"],
1440 "token" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A generated token"],
1441 "meta" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1442 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of creation"],
1445 "PRIMARY" => ["id"],
1448 $database["parsed_url"] = [
1449 "comment" => "cache for 'parse_url' queries",
1451 "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "page url"],
1452 "guessing" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => "is the 'guessing' mode active?"],
1453 "oembed" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => "is the data the result of oembed?"],
1454 "content" => ["type" => "mediumtext", "comment" => "page data"],
1455 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of creation"],
1458 "PRIMARY" => ["url", "guessing", "oembed"],
1459 "created" => ["created"],
1462 $database["participation"] = [
1463 "comment" => "Storage for participation messages from Diaspora",
1465 "iid" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "relation" => ["item" => "id"], "comment" => ""],
1466 "server" => ["type" => "varchar(60)", "not null" => "1", "primary" => "1", "comment" => ""],
1467 "cid" => ["type" => "int unsigned", "not null" => "1", "relation" => ["contact" => "id"], "comment" => ""],
1468 "fid" => ["type" => "int unsigned", "not null" => "1", "relation" => ["fcontact" => "id"], "comment" => ""],
1471 "PRIMARY" => ["iid", "server"]
1474 $database["pconfig"] = [
1475 "comment" => "personal (per user) configuration storage",
1477 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1478 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1479 "cat" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""],
1480 "k" => ["type" => "varbinary(100)", "not null" => "1", "default" => "", "comment" => ""],
1481 "v" => ["type" => "mediumtext", "comment" => ""],
1484 "PRIMARY" => ["id"],
1485 "uid_cat_k" => ["UNIQUE", "uid", "cat", "k"],
1488 $database["photo"] = [
1489 "comment" => "photo storage",
1491 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1492 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1493 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id"],
1494 "guid" => ["type" => "char(16)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this photo"],
1495 "resource-id" => ["type" => "char(32)", "not null" => "1", "default" => "", "comment" => ""],
1496 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation date"],
1497 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "last edited date"],
1498 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1499 "desc" => ["type" => "text", "comment" => ""],
1500 "album" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "The name of the album to which the photo belongs"],
1501 "filename" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1502 "type" => ["type" => "varchar(30)", "not null" => "1", "default" => "image/jpeg"],
1503 "height" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1504 "width" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1505 "datasize" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1506 "data" => ["type" => "mediumblob", "not null" => "1", "comment" => ""],
1507 "scale" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1508 "profile" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1509 "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>'"],
1510 "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"],
1511 "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"],
1512 "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"],
1515 "PRIMARY" => ["id"],
1516 "contactid" => ["contact-id"],
1517 "uid_contactid" => ["uid", "contact-id"],
1518 "uid_profile" => ["uid", "profile"],
1519 "uid_album_scale_created" => ["uid", "album(32)", "scale", "created"],
1520 "uid_album_resource-id_created" => ["uid", "album(32)", "resource-id", "created"],
1521 "resource-id" => ["resource-id"],
1524 $database["poll"] = [
1525 "comment" => "Currently unused table for storing poll results",
1527 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1528 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1529 "q0" => ["type" => "text", "comment" => ""],
1530 "q1" => ["type" => "text", "comment" => ""],
1531 "q2" => ["type" => "text", "comment" => ""],
1532 "q3" => ["type" => "text", "comment" => ""],
1533 "q4" => ["type" => "text", "comment" => ""],
1534 "q5" => ["type" => "text", "comment" => ""],
1535 "q6" => ["type" => "text", "comment" => ""],
1536 "q7" => ["type" => "text", "comment" => ""],
1537 "q8" => ["type" => "text", "comment" => ""],
1538 "q9" => ["type" => "text", "comment" => ""],
1541 "PRIMARY" => ["id"],
1545 $database["poll_result"] = [
1546 "comment" => "data for polls - currently unused",
1548 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1549 "poll_id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["poll" => "id"]],
1550 "choice" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1553 "PRIMARY" => ["id"],
1554 "poll_id" => ["poll_id"],
1557 $database["process"] = [
1558 "comment" => "Currently running system processes",
1560 "pid" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "comment" => ""],
1561 "command" => ["type" => "varbinary(32)", "not null" => "1", "default" => "", "comment" => ""],
1562 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1565 "PRIMARY" => ["pid"],
1566 "command" => ["command"],
1569 $database["profile"] = [
1570 "comment" => "user profiles data",
1572 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1573 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1574 "profile-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name of the profile"],
1575 "is-default" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Mark this profile as default profile"],
1576 "hide-friends" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Hide friend list from viewers of this profile"],
1577 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1578 "pdesc" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Title or description"],
1579 "dob" => ["type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00", "comment" => "Day of birth"],
1580 "address" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1581 "locality" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1582 "region" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1583 "postal-code" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1584 "country-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1585 "hometown" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1586 "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1587 "marital" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1588 "with" => ["type" => "text", "comment" => ""],
1589 "howlong" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1590 "sexual" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1591 "politic" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1592 "religion" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1593 "pub_keywords" => ["type" => "text", "comment" => ""],
1594 "prv_keywords" => ["type" => "text", "comment" => ""],
1595 "likes" => ["type" => "text", "comment" => ""],
1596 "dislikes" => ["type" => "text", "comment" => ""],
1597 "about" => ["type" => "text", "comment" => ""],
1598 "summary" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1599 "music" => ["type" => "text", "comment" => ""],
1600 "book" => ["type" => "text", "comment" => ""],
1601 "tv" => ["type" => "text", "comment" => ""],
1602 "film" => ["type" => "text", "comment" => ""],
1603 "interest" => ["type" => "text", "comment" => ""],
1604 "romance" => ["type" => "text", "comment" => ""],
1605 "work" => ["type" => "text", "comment" => ""],
1606 "education" => ["type" => "text", "comment" => ""],
1607 "contact" => ["type" => "text", "comment" => ""],
1608 "homepage" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1609 "xmpp" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1610 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1611 "thumb" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1612 "publish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "publish default profile in local directory"],
1613 "net-publish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "publish profile in global directory"],
1616 "PRIMARY" => ["id"],
1617 "uid_is-default" => ["uid", "is-default"],
1620 $database["profile_check"] = [
1621 "comment" => "DFRN remote auth use",
1623 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1624 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1625 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id"],
1626 "dfrn_id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1627 "sec" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1628 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1631 "PRIMARY" => ["id"],
1634 $database["push_subscriber"] = [
1635 "comment" => "Used for OStatus: Contains feed subscribers",
1637 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1638 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1639 "callback_url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1640 "topic" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1641 "nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1642 "push" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Retrial counter"],
1643 "last_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last successful trial"],
1644 "next_try" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Next retrial date"],
1645 "renewed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last subscription renewal"],
1646 "secret" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1649 "PRIMARY" => ["id"],
1650 "next_try" => ["next_try"],
1653 $database["queue"] = [
1654 "comment" => "Queue for messages that couldn't be delivered",
1656 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1657 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Message receiver"],
1658 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Receiver's network"],
1659 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Unique GUID of the message"],
1660 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date, when the message was created"],
1661 "last" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last trial"],
1662 "next" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Next retrial date"],
1663 "retrial" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Retrial counter"],
1664 "content" => ["type" => "mediumtext", "comment" => ""],
1665 "batch" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1668 "PRIMARY" => ["id"],
1673 $database["register"] = [
1674 "comment" => "registrations requiring admin approval",
1676 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1677 "hash" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1678 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1679 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1680 "password" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1681 "language" => ["type" => "varchar(16)", "not null" => "1", "default" => "", "comment" => ""],
1682 "note" => ["type" => "text", "comment" => ""],
1685 "PRIMARY" => ["id"],
1688 $database["search"] = [
1691 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1692 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1693 "term" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1696 "PRIMARY" => ["id"],
1700 $database["session"] = [
1701 "comment" => "web session storage",
1703 "id" => ["type" => "bigint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1704 "sid" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""],
1705 "data" => ["type" => "text", "comment" => ""],
1706 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1709 "PRIMARY" => ["id"],
1710 "sid" => ["sid(64)"],
1711 "expire" => ["expire"],
1714 $database["sign"] = [
1715 "comment" => "Diaspora signatures",
1717 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1718 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => "item.id"],
1719 "signed_text" => ["type" => "mediumtext", "comment" => ""],
1720 "signature" => ["type" => "text", "comment" => ""],
1721 "signer" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1724 "PRIMARY" => ["id"],
1725 "iid" => ["UNIQUE", "iid"],
1728 $database["term"] = [
1729 "comment" => "item taxonomy (categories, tags, etc.) table",
1731 "tid" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1732 "oid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1733 "otype" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1734 "type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1735 "term" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1736 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1737 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1738 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1739 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1740 "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1741 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1744 "PRIMARY" => ["tid"],
1745 "oid_otype_type_term" => ["oid","otype","type","term(32)"],
1746 "uid_otype_type_term_global_created" => ["uid","otype","type","term(32)","global","created"],
1747 "uid_otype_type_url" => ["uid","otype","type","url(64)"],
1748 "guid" => ["guid(64)"],
1751 $database["thread"] = [
1752 "comment" => "Thread related data",
1754 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["item" => "id"], "comment" => "sequential ID"],
1755 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1756 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1757 "owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Item owner"],
1758 "author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Item author"],
1759 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1760 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1761 "commented" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1762 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1763 "changed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1764 "wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1765 "private" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1766 "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1767 "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1768 "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1769 "starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1770 "ignored" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1771 "bookmark" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1772 "unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
1773 "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1774 "origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1775 "forum_mode" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1776 "mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1777 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
1780 "PRIMARY" => ["iid"],
1781 "uid_network_commented" => ["uid","network","commented"],
1782 "uid_network_created" => ["uid","network","created"],
1783 "uid_contactid_commented" => ["uid","contact-id","commented"],
1784 "uid_contactid_created" => ["uid","contact-id","created"],
1785 "contactid" => ["contact-id"],
1786 "ownerid" => ["owner-id"],
1787 "authorid" => ["author-id"],
1788 "uid_created" => ["uid","created"],
1789 "uid_commented" => ["uid","commented"],
1790 "uid_wall_created" => ["uid","wall","created"],
1791 "private_wall_origin_commented" => ["private","wall","origin","commented"],
1794 $database["tokens"] = [
1795 "comment" => "OAuth usage",
1797 "id" => ["type" => "varchar(40)", "not null" => "1", "primary" => "1", "comment" => ""],
1798 "secret" => ["type" => "text", "comment" => ""],
1799 "client_id" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => ["clients" => "client_id"]],
1800 "expires" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
1801 "scope" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
1802 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1805 "PRIMARY" => ["id"],
1808 $database["user"] = [
1809 "comment" => "The local users",
1811 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1812 "parent-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "The parent user that has full control about this user"],
1813 "guid" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this user"],
1814 "username" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this user is known by"],
1815 "password" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "encrypted password"],
1816 "legacy_password" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Is the password hash double-hashed?"],
1817 "nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "nick- and user name"],
1818 "email" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "the users email address"],
1819 "openid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1820 "timezone" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => "PHP-legal timezone"],
1821 "language" => ["type" => "varchar(32)", "not null" => "1", "default" => "en", "comment" => "default language"],
1822 "register_date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "timestamp of registration"],
1823 "login_date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "timestamp of last login"],
1824 "default-location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Default for item.location"],
1825 "allow_location" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 allows to display the location"],
1826 "theme" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "user theme preference"],
1827 "pubkey" => ["type" => "text", "comment" => "RSA public key 4096 bit"],
1828 "prvkey" => ["type" => "text", "comment" => "RSA private key 4096 bit"],
1829 "spubkey" => ["type" => "text", "comment" => ""],
1830 "sprvkey" => ["type" => "text", "comment" => ""],
1831 "verified" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "user is verified through email"],
1832 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 for user is blocked"],
1833 "blockwall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Prohibit contacts to post to the profile page of the user"],
1834 "hidewall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Hide profile details from unkown viewers"],
1835 "blocktags" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Prohibit contacts to tag the post of this user"],
1836 "unkmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Permit unknown people to send private mails to this user"],
1837 "cntunkmail" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""],
1838 "notify-flags" => ["type" => "smallint unsigned", "not null" => "1", "default" => "65535", "comment" => "email notification options"],
1839 "page-flags" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "page/profile type"],
1840 "account-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1841 "prvnets" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1842 "pwdreset" => ["type" => "varchar(255)", "comment" => "Password reset request token"],
1843 "pwdreset_time" => ["type" => "datetime", "comment" => "Timestamp of the last password reset request"],
1844 "maxreq" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""],
1845 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1846 "account_removed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if 1 the account is removed"],
1847 "account_expired" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1848 "account_expires_on" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "timestamp when account expires and will be deleted"],
1849 "expire_notification_sent" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "timestamp of last warning of account expiration"],
1850 "def_gid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1851 "allow_cid" => ["type" => "mediumtext", "comment" => "default permission for this user"],
1852 "allow_gid" => ["type" => "mediumtext", "comment" => "default permission for this user"],
1853 "deny_cid" => ["type" => "mediumtext", "comment" => "default permission for this user"],
1854 "deny_gid" => ["type" => "mediumtext", "comment" => "default permission for this user"],
1855 "openidserver" => ["type" => "text", "comment" => ""],
1858 "PRIMARY" => ["uid"],
1859 "nickname" => ["nickname(32)"],
1862 $database["userd"] = [
1863 "comment" => "Deleted usernames",
1865 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1866 "username" => ["type" => "varchar(255)", "not null" => "1", "comment" => ""],
1869 "PRIMARY" => ["id"],
1870 "username" => ["username(32)"],
1873 $database["user-item"] = [
1874 "comment" => "User specific item data",
1876 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["item" => "id"], "comment" => "Item id"],
1877 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["user" => "uid"], "comment" => "User id"],
1878 "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Marker to hide an item from the user"],
1881 "PRIMARY" => ["uid", "iid"],
1884 $database["worker-ipc"] = [
1885 "comment" => "Inter process communication between the frontend and the worker",
1887 "key" => ["type" => "int", "not null" => "1", "primary" => "1", "comment" => ""],
1888 "jobs" => ["type" => "boolean", "comment" => "Flag for outstanding jobs"],
1891 "PRIMARY" => ["key"],
1893 "engine" => "MEMORY",
1896 $database["workerqueue"] = [
1897 "comment" => "Background tasks queue entries",
1899 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "Auto incremented worker task id"],
1900 "parameter" => ["type" => "mediumblob", "comment" => "Task command"],
1901 "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Task priority"],
1902 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Creation date"],
1903 "pid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "Process id of the worker"],
1904 "executed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Execution date"],
1905 "done" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Marked 1 when the task was done - will be deleted later"],
1908 "PRIMARY" => ["id"],
1910 "parameter" => ["parameter(64)"],
1911 "priority_created" => ["priority", "created"],
1912 "done_executed" => ["done", "executed"],
1916 \Friendica\Core\Addon::callHooks('dbstructure_definition', $database);