3 * @file src/Database/DBStructure.php
5 namespace Friendica\Database;
7 use Friendica\Core\Config;
8 use Friendica\Core\L10n;
9 use Friendica\Database\DBM;
12 require_once 'boot.php';
13 require_once 'include/dba.php';
14 require_once 'include/enotify.php';
15 require_once 'include/text.php';
18 * @brief This class contain functions for the database management
20 * This class contains functions that doesn't need to know if pdo, mysqli or whatever is used.
25 * Converts all tables from MyISAM to InnoDB
27 public static function convertToInnoDB() {
28 $r = q("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `engine` = 'MyISAM' AND `table_schema` = '%s'",
29 dbesc(dba::database_name()));
31 if (!DBM::is_result($r)) {
32 echo L10n::t('There are no tables on MyISAM.')."\n";
36 foreach ($r AS $table) {
37 $sql = sprintf("ALTER TABLE `%s` engine=InnoDB;", dbesc($table['TABLE_NAME']));
40 $result = dba::e($sql);
41 if (!DBM::is_result($result)) {
42 self::printUpdateError($sql);
48 * send the email and do what is needed to do on update fails
50 * @param update_id (int) number of failed update
51 * @param error_message (str) error message
53 public static function updateFail($update_id, $error_message) {
56 //send the administrators an e-mail
57 $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
58 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
63 if (!DBM::is_result($adminlist)) {
64 logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_NORMAL);
70 // every admin could had different language
71 foreach ($adminlist as $admin) {
72 $lang = (($admin['language'])?$admin['language']:'en');
73 L10n::pushLang($lang);
75 $preamble = deindent(L10n::t("
76 The friendica developers released update %s recently,
77 but when I tried to install it, something went terribly wrong.
78 This needs to be fixed soon and I can't do it alone. Please contact a
79 friendica developer if you can not help me on your own. My database might be invalid."));
80 $body = L10n::t("The error message is\n[pre]%s[/pre]");
81 $preamble = sprintf($preamble, $update_id);
82 $body = sprintf($body, $error_message);
85 'type' => SYSTEM_EMAIL,
86 'to_email' => $admin['email'],
87 'preamble' => $preamble,
94 logger("CRITICAL: Database structure update failed: ".$error_message);
98 private static function tableStructure($table) {
99 $structures = q("DESCRIBE `%s`", $table);
101 $full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table);
103 $indexes = q("SHOW INDEX FROM `%s`", $table);
105 $table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table);
107 if (DBM::is_result($table_status)) {
108 $table_status = $table_status[0];
116 if (DBM::is_result($indexes)) {
117 foreach ($indexes AS $index) {
118 if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
119 $indexdata[$index["Key_name"]] = ['UNIQUE'];
122 $column = $index["Column_name"];
124 if ($index["Sub_part"] != "") {
125 $column .= "(".$index["Sub_part"].")";
128 $indexdata[$index["Key_name"]][] = $column;
131 if (DBM::is_result($structures)) {
132 foreach ($structures AS $field) {
133 // Replace the default size values so that we don't have to define them
134 $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)'];
135 $replace = ['boolean', 'tinyint unsigned', 'tinyint', 'smallint unsigned', 'smallint', 'mediumint unsigned', 'mediumint', 'bigint', 'int unsigned', 'int'];
136 $field["Type"] = str_replace($search, $replace, $field["Type"]);
138 $fielddata[$field["Field"]]["type"] = $field["Type"];
139 if ($field["Null"] == "NO") {
140 $fielddata[$field["Field"]]["not null"] = true;
143 if (isset($field["Default"])) {
144 $fielddata[$field["Field"]]["default"] = $field["Default"];
147 if ($field["Extra"] != "") {
148 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
151 if ($field["Key"] == "PRI") {
152 $fielddata[$field["Field"]]["primary"] = true;
156 if (DBM::is_result($full_columns)) {
157 foreach ($full_columns AS $column) {
158 $fielddata[$column["Field"]]["Collation"] = $column["Collation"];
159 $fielddata[$column["Field"]]["comment"] = $column["Comment"];
163 return ["fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status];
166 public static function printStructure() {
167 $database = self::definition();
169 echo "-- ------------------------------------------\n";
170 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
171 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
172 echo "-- ------------------------------------------\n\n\n";
173 foreach ($database AS $name => $structure) {
175 echo "-- TABLE $name\n";
177 self::createTable($name, $structure, true, false);
184 * @brief Print out database error messages
186 * @param string $message Message to be added to the error message
188 * @return string Error message
190 private static function printUpdateError($message) {
191 echo L10n::t("\nError %d occurred during database update:\n%s\n",
192 dba::errorNo(), dba::errorMessage());
194 return L10n::t('Errors encountered performing database changes: ').$message.EOL;
198 * Updates DB structure and returns eventual errors messages
200 * @param bool $verbose
201 * @param bool $action Whether to actually apply the update
202 * @param bool $install Is this the initial update during the installation?
203 * @param array $tables An array of the database tables
204 * @param array $definition An array of the definition tables
205 * @return string Empty string if the update is successful, error messages otherwise
207 public static function update($verbose, $action, $install = false, array $tables = null, array $definition = null) {
208 if ($action && !$install) {
209 Config::set('system', 'maintenance', 1);
210 Config::set('system', 'maintenance_reason', L10n::t('%s: Database update', DBM::date().' '.date('e')));
215 logger('updating structure', LOGGER_DEBUG);
217 // Get the current structure
220 if (is_null($tables)) {
221 $tables = q("SHOW TABLES");
224 if (DBM::is_result($tables)) {
225 foreach ($tables AS $table) {
226 $table = current($table);
228 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
229 $database[$table] = self::tableStructure($table);
233 // Get the definition
234 if (is_null($definition)) {
235 $definition = self::definition();
238 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
239 if ((version_compare(dba::server_info(), '5.7.4') >= 0) &&
240 !(strpos(dba::server_info(), 'MariaDB') !== false)) {
247 foreach ($definition AS $name => $structure) {
248 $is_new_table = false;
253 if (!isset($database[$name])) {
254 $r = self::createTable($name, $structure, $verbose, $action);
255 if (!DBM::is_result($r)) {
256 $errors .= self::printUpdateError($name);
258 $is_new_table = true;
260 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
261 if (isset($database[$name]["indexes"][$indexname])) {
262 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
264 $current_index_definition = "__NOT_SET__";
266 $new_index_definition = implode(",",$fieldnames);
267 if ($current_index_definition != $new_index_definition) {
268 if ($fieldnames[0] == "UNIQUE") {
271 $temp_name = "temp-".$name;
278 * Drop the index if it isn't present in the definition
279 * or the definition differ from current status
280 * and index name doesn't start with "local_"
282 foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
283 $current_index_definition = implode(",",$fieldnames);
284 if (isset($structure["indexes"][$indexname])) {
285 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
287 $new_index_definition = "__NOT_SET__";
289 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
290 $sql2=self::dropIndex($indexname);
292 $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
298 // Compare the field structure field by field
299 foreach ($structure["fields"] AS $fieldname => $parameters) {
300 if (!isset($database[$name]["fields"][$fieldname])) {
301 $sql2=self::addTableField($fieldname, $parameters);
303 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
308 // Compare the field definition
309 $field_definition = $database[$name]["fields"][$fieldname];
311 // Remove the relation data that is used for the referential integrity
312 unset($parameters['relation']);
314 // We change the collation after the indexes had been changed.
315 // This is done to avoid index length problems.
316 // So here we always ensure that there is no need to change it.
317 unset($parameters['Collation']);
318 unset($field_definition['Collation']);
320 // Only update the comment when it is defined
321 if (!isset($parameters['comment'])) {
322 $parameters['comment'] = "";
325 $current_field_definition = dba::clean_query(implode(",", $field_definition));
326 $new_field_definition = dba::clean_query(implode(",", $parameters));
327 if ($current_field_definition != $new_field_definition) {
328 $sql2 = self::modifyTableField($fieldname, $parameters);
330 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
340 * Create the index if the index don't exists in database
341 * or the definition differ from the current status.
342 * Don't create keys if table is new
344 if (!$is_new_table) {
345 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
346 if (isset($database[$name]["indexes"][$indexname])) {
347 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
349 $current_index_definition = "__NOT_SET__";
351 $new_index_definition = implode(",",$fieldnames);
352 if ($current_index_definition != $new_index_definition) {
353 $sql2 = self::createIndex($indexname, $fieldnames);
355 // Fetch the "group by" fields for unique indexes
356 if ($fieldnames[0] == "UNIQUE") {
357 $group_by = self::groupBy($indexname, $fieldnames);
361 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
369 if (isset($database[$name]["table_status"]["Comment"])) {
370 if ($database[$name]["table_status"]["Comment"] != $structure['comment']) {
371 $sql2 = "COMMENT = '".dbesc($structure['comment'])."'";
374 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
381 if (isset($database[$name]["table_status"]["Engine"]) && isset($structure['engine'])) {
382 if ($database[$name]["table_status"]["Engine"] != $structure['engine']) {
383 $sql2 = "ENGINE = '".dbesc($structure['engine'])."'";
386 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
393 if (isset($database[$name]["table_status"]["Collation"])) {
394 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
395 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
398 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
409 // Now have a look at the field collations
410 // Compare the field structure field by field
411 foreach ($structure["fields"] AS $fieldname => $parameters) {
412 // Compare the field definition
413 $field_definition = $database[$name]["fields"][$fieldname];
415 // Define the default collation if not given
416 if (!isset($parameters['Collation']) && !is_null($field_definition['Collation'])) {
417 $parameters['Collation'] = 'utf8mb4_general_ci';
419 $parameters['Collation'] = null;
422 if ($field_definition['Collation'] != $parameters['Collation']) {
423 $sql2 = self::modifyTableField($fieldname, $parameters);
424 if (($sql3 == "") || (substr($sql3, -2, 2) == "; ")) {
425 $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
434 if (substr($sql3, -2, 2) != "; ") {
439 if ($is_unique && $ignore == '') {
440 foreach ($database[$name]["fields"] AS $fieldname => $parameters) {
441 $field_list .= 'ANY_VALUE(`' . $fieldname . '`),';
443 $field_list = rtrim($field_list, ',');
447 // Ensure index conversion to unique removes duplicates
448 if ($is_unique && ($temp_name != $name)) {
450 echo "SET session old_alter_table=1;\n";
452 echo "DROP TABLE IF EXISTS `".$temp_name."`;\n";
453 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
459 if ($is_unique && ($temp_name != $name)) {
461 echo "SET session old_alter_table=0;\n";
463 echo "INSERT INTO `".$temp_name."` SELECT ".dba::any_value_fallback($field_list)." FROM `".$name."`".$group_by.";\n";
464 echo "DROP TABLE `".$name."`;\n";
465 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
472 Config::set('system', 'maintenance_reason', L10n::t('%s: updating %s table.', DBM::date().' '.date('e'), $name));
475 // Ensure index conversion to unique removes duplicates
476 if ($is_unique && ($temp_name != $name)) {
478 dba::e("SET session old_alter_table=1;");
480 $r = dba::e("DROP TABLE IF EXISTS `".$temp_name."`;");
481 if (!DBM::is_result($r)) {
482 $errors .= self::printUpdateError($sql3);
486 $r = dba::e("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
487 if (!DBM::is_result($r)) {
488 $errors .= self::printUpdateError($sql3);
495 if (!DBM::is_result($r)) {
496 $errors .= self::printUpdateError($sql3);
498 if ($is_unique && ($temp_name != $name)) {
500 dba::e("SET session old_alter_table=0;");
502 $r = dba::e("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
503 if (!DBM::is_result($r)) {
504 $errors .= self::printUpdateError($sql3);
507 $r = dba::e("DROP TABLE `".$name."`;");
508 if (!DBM::is_result($r)) {
509 $errors .= self::printUpdateError($sql3);
512 $r = dba::e("RENAME TABLE `".$temp_name."` TO `".$name."`;");
513 if (!DBM::is_result($r)) {
514 $errors .= self::printUpdateError($sql3);
523 if ($action && !$install) {
524 Config::set('system', 'maintenance', 0);
525 Config::set('system', 'maintenance_reason', '');
528 Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
530 Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
537 private static function FieldCommand($parameters, $create = true) {
538 $fieldstruct = $parameters["type"];
540 if (!is_null($parameters["Collation"])) {
541 $fieldstruct .= " COLLATE ".$parameters["Collation"];
544 if ($parameters["not null"]) {
545 $fieldstruct .= " NOT NULL";
548 if (isset($parameters["default"])) {
549 if (strpos(strtolower($parameters["type"]),"int")!==false) {
550 $fieldstruct .= " DEFAULT ".$parameters["default"];
552 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
555 if ($parameters["extra"] != "") {
556 $fieldstruct .= " ".$parameters["extra"];
559 if (!is_null($parameters["comment"])) {
560 $fieldstruct .= " COMMENT '".dbesc($parameters["comment"])."'";
563 /*if (($parameters["primary"] != "") && $create)
564 $fieldstruct .= " PRIMARY KEY";*/
566 return($fieldstruct);
569 private static function createTable($name, $structure, $verbose, $action) {
576 foreach ($structure["fields"] AS $fieldname => $field) {
577 $sql_rows[] = "`".dbesc($fieldname)."` ".self::FieldCommand($field);
578 if (x($field,'primary') && $field['primary']!='') {
579 $primary_keys[] = $fieldname;
583 if (!is_null($structure["indexes"])) {
584 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
585 $sql_index = self::createIndex($indexname, $fieldnames, "");
586 if (!is_null($sql_index)) {
587 $sql_rows[] = $sql_index;
592 if (!is_null($structure["engine"])) {
593 $engine = " ENGINE=" . $structure["engine"];
596 if (!is_null($structure["comment"])) {
597 $comment = " COMMENT='" . dbesc($structure["comment"]) . "'";
600 $sql = implode(",\n\t", $sql_rows);
602 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql.
603 "\n)" . $engine . " DEFAULT COLLATE utf8mb4_general_ci" . $comment;
615 private static function addTableField($fieldname, $parameters) {
616 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), self::FieldCommand($parameters));
620 private static function modifyTableField($fieldname, $parameters) {
621 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), self::FieldCommand($parameters, false));
625 private static function dropIndex($indexname) {
626 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
630 private static function createIndex($indexname, $fieldnames, $method = "ADD") {
631 $method = strtoupper(trim($method));
632 if ($method!="" && $method!="ADD") {
633 throw new \Exception("Invalid parameter 'method' in self::createIndex(): '$method'");
636 if ($fieldnames[0] == "UNIQUE") {
637 array_shift($fieldnames);
638 $method .= ' UNIQUE';
642 foreach ($fieldnames AS $fieldname) {
647 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
648 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
650 $names .= "`".dbesc($fieldname)."`";
654 if ($indexname == "PRIMARY") {
655 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
659 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
663 private static function groupBy($indexname, $fieldnames) {
664 if ($fieldnames[0] != "UNIQUE") {
668 array_shift($fieldnames);
671 foreach ($fieldnames AS $fieldname) {
676 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
677 $names .= "`".dbesc($matches[1])."`";
679 $names .= "`".dbesc($fieldname)."`";
683 $sql = sprintf(" GROUP BY %s", $names);
687 public static function definition() {
690 $database["addon"] = [
691 "comment" => "registered addons",
693 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
694 "name" => ["type" => "varchar(50)", "not null" => "1", "default" => "", "comment" => "addon base (file)name"],
695 "version" => ["type" => "varchar(50)", "not null" => "1", "default" => "", "comment" => "currently unused"],
696 "installed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "currently always 1"],
697 "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "currently unused"],
698 "timestamp" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "file timestamp to check for reloads"],
699 "plugin_admin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 = has admin config, 0 = has no admin config"],
703 "name" => ["UNIQUE", "name"],
706 $database["attach"] = [
707 "comment" => "file attachments",
709 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "generated index"],
710 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
711 "hash" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "hash"],
712 "filename" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "filename of original"],
713 "filetype" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "mimetype"],
714 "filesize" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "size in bytes"],
715 "data" => ["type" => "longblob", "not null" => "1", "comment" => "file data"],
716 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation time"],
717 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "last edit time"],
718 "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>"],
719 "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"],
720 "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"],
721 "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"],
727 $database["auth_codes"] = [
728 "comment" => "OAuth usage",
730 "id" => ["type" => "varchar(40)", "not null" => "1", "primary" => "1", "comment" => ""],
731 "client_id" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => ["clients" => "client_id"], "comment" => ""],
732 "redirect_uri" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
733 "expires" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
734 "scope" => ["type" => "varchar(250)", "not null" => "1", "default" => "", "comment" => ""],
740 $database["cache"] = [
741 "comment" => "Stores temporary data",
743 "k" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "cache key"],
744 "v" => ["type" => "mediumtext", "comment" => "cached serialized value"],
745 "expires" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of cache expiration"],
746 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of cache insertion"],
750 "k_expires" => ["k", "expires"],
753 $database["challenge"] = [
756 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
757 "challenge" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
758 "dfrn-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
759 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
760 "type" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
761 "last_update" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
767 $database["clients"] = [
768 "comment" => "OAuth usage",
770 "client_id" => ["type" => "varchar(20)", "not null" => "1", "primary" => "1", "comment" => ""],
771 "pw" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => ""],
772 "redirect_uri" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
773 "name" => ["type" => "text", "comment" => ""],
774 "icon" => ["type" => "text", "comment" => ""],
775 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
778 "PRIMARY" => ["client_id"],
781 $database["config"] = [
782 "comment" => "main configuration storage",
784 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
785 "cat" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""],
786 "k" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""],
787 "v" => ["type" => "mediumtext", "comment" => ""],
791 "cat_k" => ["UNIQUE", "cat", "k"],
794 $database["contact"] = [
795 "comment" => "contact table",
797 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
798 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
799 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
800 "self" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 if the contact is the user him/her self"],
801 "remote_self" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
802 "rel" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "The kind of the relation between the user and the contact"],
803 "duplex" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
804 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Network protocol of the contact"],
805 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this contact is known by"],
806 "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Nick- and user name of the contact"],
807 "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
808 "about" => ["type" => "text", "comment" => ""],
809 "keywords" => ["type" => "text", "comment" => "public keywords (interests) of the contact"],
810 "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
811 "xmpp" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
812 "attag" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
813 "avatar" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
814 "photo" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo of the contact"],
815 "thumb" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo (thumb size)"],
816 "micro" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo (micro size)"],
817 "site-pubkey" => ["type" => "text", "comment" => ""],
818 "issued-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
819 "dfrn-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
820 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
821 "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
822 "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
823 "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
824 "pubkey" => ["type" => "text", "comment" => "RSA public key 4096 bit"],
825 "prvkey" => ["type" => "text", "comment" => "RSA private key 4096 bit"],
826 "batch" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
827 "request" => ["type" => "varchar(255)", "comment" => ""],
828 "notify" => ["type" => "varchar(255)", "comment" => ""],
829 "poll" => ["type" => "varchar(255)", "comment" => ""],
830 "confirm" => ["type" => "varchar(255)", "comment" => ""],
831 "poco" => ["type" => "varchar(255)", "comment" => ""],
832 "aes_allow" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
833 "ret-aes" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
834 "usehub" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
835 "subhub" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
836 "hub-verify" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
837 "last-update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of the last try to update the contact info"],
838 "success_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of the last successful contact update"],
839 "failure_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of the last failed update"],
840 "name-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
841 "uri-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
842 "avatar-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
843 "term-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
844 "last-item" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "date of the last post"],
845 "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
846 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
847 "readonly" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "posts of the contact are readonly"],
848 "writable" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
849 "forum" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "contact is a forum"],
850 "prv" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "contact is a private group"],
851 "contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
852 "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
853 "archive" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
854 "pending" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
855 "rating" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
856 "reason" => ["type" => "text", "comment" => ""],
857 "closeness" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "99", "comment" => ""],
858 "info" => ["type" => "mediumtext", "comment" => ""],
859 "profile-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
860 "bdyear" => ["type" => "varchar(4)", "not null" => "1", "default" => "", "comment" => ""],
861 "bd" => ["type" => "date", "not null" => "1", "default" => "0001-01-01", "comment" => ""],
862 "notify_new_posts" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
863 "fetch_further_information" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
864 "ffi_keyword_blacklist" => ["type" => "text", "comment" => ""],
868 "uid_name" => ["uid", "name(190)"],
869 "self_uid" => ["self", "uid"],
870 "alias_uid" => ["alias(32)", "uid"],
871 "pending_uid" => ["pending", "uid"],
872 "blocked_uid" => ["blocked", "uid"],
873 "uid_rel_network_poll" => ["uid", "rel", "network", "poll(64)", "archive"],
874 "uid_network_batch" => ["uid", "network", "batch(64)"],
875 "addr_uid" => ["addr(32)", "uid"],
876 "nurl_uid" => ["nurl(32)", "uid"],
877 "nick_uid" => ["nick(32)", "uid"],
878 "dfrn-id" => ["dfrn-id(64)"],
879 "issued-id" => ["issued-id(64)"],
882 $database["conv"] = [
883 "comment" => "private messages",
885 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
886 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this conversation"],
887 "recips" => ["type" => "text", "comment" => "sender_handle;recipient_handle"],
888 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
889 "creator" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "handle of creator"],
890 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation timestamp"],
891 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "edited timestamp"],
892 "subject" => ["type" => "text", "comment" => "subject of initial message"],
899 $database["conversation"] = [
900 "comment" => "Raw data and structure information for messages",
902 "item-uri" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "URI of the item"],
903 "reply-to-uri" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => "URI to which this item is a reply"],
904 "conversation-uri" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => "GNU Social conversation URI"],
905 "conversation-href" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => "GNU Social conversation link"],
906 "protocol" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "The protocol of the item"],
907 "source" => ["type" => "mediumtext", "comment" => "Original source"],
908 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Receiving date"],
911 "PRIMARY" => ["item-uri"],
912 "conversation-uri" => ["conversation-uri"],
913 "received" => ["received"],
916 $database["event"] = [
917 "comment" => "Events",
919 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
920 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
921 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
922 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact_id (ID of the contact in contact table)"],
923 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
924 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation time"],
925 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "last edit time"],
926 "start" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "event start time"],
927 "finish" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "event end time"],
928 "summary" => ["type" => "text", "comment" => "short description or title of the event"],
929 "desc" => ["type" => "text", "comment" => "event description"],
930 "location" => ["type" => "text", "comment" => "event location"],
931 "type" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => "event or birthday"],
932 "nofinish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if event does have no end this is 1"],
933 "adjust" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => "adjust to timezone of the recipient (0 or 1)"],
934 "ignore" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "0 or 1"],
935 "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>'"],
936 "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"],
937 "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"],
938 "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"],
942 "uid_start" => ["uid", "start"],
945 $database["fcontact"] = [
946 "comment" => "Diaspora compatible contacts - used in the Diaspora implementation",
948 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
949 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "unique id"],
950 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
951 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
952 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
953 "request" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
954 "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
955 "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
956 "batch" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
957 "notify" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
958 "poll" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
959 "confirm" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
960 "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
961 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
962 "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
963 "pubkey" => ["type" => "text", "comment" => ""],
964 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
968 "addr" => ["addr(32)"],
969 "url" => ["UNIQUE", "url(190)"],
972 $database["fsuggest"] = [
973 "comment" => "friend suggestion stuff",
975 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
976 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
977 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
978 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
979 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
980 "request" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
981 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
982 "note" => ["type" => "text", "comment" => ""],
983 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
989 $database["gcign"] = [
990 "comment" => "contacts ignored by friend suggestions",
992 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
993 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Local User id"],
994 "gcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => "gcontact.id of ignored contact"],
1002 $database["gcontact"] = [
1003 "comment" => "global contacts",
1005 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1006 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this contact is known by"],
1007 "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Nick- and user name of the contact"],
1008 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Link to the contacts profile page"],
1009 "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1010 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Link to the profile photo"],
1011 "connect" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1012 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1013 "updated" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1014 "last_contact" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1015 "last_failure" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1016 "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1017 "about" => ["type" => "text", "comment" => ""],
1018 "keywords" => ["type" => "text", "comment" => "puplic keywords (interests)"],
1019 "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1020 "birthday" => ["type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01", "comment" => ""],
1021 "community" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 if contact is forum account"],
1022 "contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "-1", "comment" => ""],
1023 "hide" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 = should be hidden from search"],
1024 "nsfw" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 = contact posts nsfw content"],
1025 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "social network protocol"],
1026 "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1027 "notify" => ["type" => "varchar(255)", "comment" => ""],
1028 "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1029 "generation" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1030 "server_url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "baseurl of the contacts server"],
1033 "PRIMARY" => ["id"],
1034 "nurl" => ["UNIQUE", "nurl(190)"],
1035 "name" => ["name(64)"],
1036 "nick" => ["nick(32)"],
1037 "addr" => ["addr(64)"],
1038 "hide_network_updated" => ["hide", "network", "updated"],
1039 "updated" => ["updated"],
1042 $database["glink"] = [
1043 "comment" => "'friends of friends' linkages derived from poco",
1045 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1046 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1047 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1048 "gcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""],
1049 "zcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""],
1050 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1053 "PRIMARY" => ["id"],
1054 "cid_uid_gcid_zcid" => ["UNIQUE", "cid","uid","gcid","zcid"],
1058 $database["group"] = [
1059 "comment" => "privacy groups, group info",
1061 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1062 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1063 "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 indicates the member list is not private"],
1064 "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 indicates the group has been deleted"],
1065 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "human readable name of group"],
1068 "PRIMARY" => ["id"],
1072 $database["group_member"] = [
1073 "comment" => "privacy groups, member info",
1075 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1076 "gid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["group" => "id"], "comment" => "groups.id of the associated group"],
1077 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id of the member assigned to the associated group"],
1080 "PRIMARY" => ["id"],
1081 "contactid" => ["contact-id"],
1082 "gid_contactid" => ["UNIQUE", "gid", "contact-id"],
1085 $database["gserver"] = [
1086 "comment" => "Global servers",
1088 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1089 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1090 "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1091 "version" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1092 "site_name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1093 "info" => ["type" => "text", "comment" => ""],
1094 "register_policy" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
1095 "registered-users" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "Number of registered users"],
1096 "poco" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1097 "noscrape" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1098 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
1099 "platform" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1100 "relay-subscribe" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Has the server subscribed to the relay system"],
1101 "relay-scope" => ["type" => "varchar(10)", "not null" => "1", "default" => "", "comment" => "The scope of messages that the server wants to get"],
1102 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1103 "last_poco_query" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1104 "last_contact" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1105 "last_failure" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1108 "PRIMARY" => ["id"],
1109 "nurl" => ["UNIQUE", "nurl(190)"],
1112 $database["gserver-tag"] = [
1113 "comment" => "Tags that the server has subscribed",
1115 "gserver-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gserver" => "id"], "primary" => "1", "comment" => "The id of the gserver"],
1116 "tag" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "primary" => "1", "comment" => "Tag that the server has subscribed"],
1119 "PRIMARY" => ["gserver-id", "tag"],
1123 $database["hook"] = [
1124 "comment" => "addon hook registry",
1126 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1127 "hook" => ["type" => "varbinary(100)", "not null" => "1", "default" => "", "comment" => "name of hook"],
1128 "file" => ["type" => "varbinary(200)", "not null" => "1", "default" => "", "comment" => "relative filename of hook handler"],
1129 "function" => ["type" => "varbinary(200)", "not null" => "1", "default" => "", "comment" => "function name of hook handler"],
1130 "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"],
1133 "PRIMARY" => ["id"],
1134 "hook_file_function" => ["UNIQUE", "hook", "file", "function"],
1137 $database["intro"] = [
1140 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1141 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1142 "fid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["fcontact" => "id"], "comment" => ""],
1143 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1144 "knowyou" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1145 "duplex" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1146 "note" => ["type" => "text", "comment" => ""],
1147 "hash" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1148 "datetime" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1149 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
1150 "ignore" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1153 "PRIMARY" => ["id"],
1156 $database["item"] = [
1157 "comment" => "Structure for all posts",
1159 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => ["thread" => "iid"]],
1160 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this item"],
1161 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1162 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner id which owns this copy of the item"],
1163 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id"],
1164 "type" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => ""],
1165 "wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "This item was posted to the wall of uid"],
1166 "gravity" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1167 "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"],
1168 "parent-uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "uri of the parent to this item"],
1169 "extid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1170 "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"],
1171 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Creation timestamp."],
1172 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last edit (default is created)"],
1173 "commented" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last comment/reply to this item"],
1174 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime"],
1175 "changed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date that something in the conversation changed, indicating clients should fetch the conversation again"],
1176 "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"],
1177 "owner-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name of the owner of this item"],
1178 "owner-link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Link to the profile page of the owner of this item"],
1179 "owner-avatar" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Link to the avatar picture of the owner of this item"],
1180 "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"],
1181 "author-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name of the author of this item"],
1182 "author-link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Link to the profile page of the author of this item"],
1183 "author-avatar" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Link to the avatar picture of the author of this item"],
1184 "icid" => ["type" => "int unsigned", "relation" => ["item-content" => "id"], "comment" => "Id of the item-content table entry that contains the whole item content"],
1185 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "item title"],
1186 "content-warning" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1187 "body" => ["type" => "mediumtext", "comment" => "item body content"],
1188 "app" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "application which generated this item"],
1189 "verb" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams verb"],
1190 "object-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams object type"],
1191 "object" => ["type" => "text", "comment" => "JSON encoded object structure unless it is an implied object (normal post)"],
1192 "target-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams target type if applicable (URI)"],
1193 "target" => ["type" => "text", "comment" => "JSON encoded target structure if used"],
1194 "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"],
1195 "plink" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "permalink or URL to a displayable copy of the message at its source"],
1196 "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"],
1197 "event-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["event" => "id"], "comment" => "Used to link to the event.id"],
1198 "tag" => ["type" => "mediumtext", "comment" => ""],
1199 "attach" => ["type" => "mediumtext", "comment" => "JSON structure representing attachments to this item"],
1200 "inform" => ["type" => "mediumtext", "comment" => ""],
1201 "file" => ["type" => "mediumtext", "comment" => ""],
1202 "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "text location where this item originated"],
1203 "coord" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "longitude/latitude pair representing location where this item originated"],
1204 "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>'"],
1205 "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"],
1206 "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"],
1207 "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"],
1208 "private" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "distribution is restricted"],
1209 "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1210 "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1211 "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1212 "starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been favourited"],
1213 "bookmark" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been bookmarked"],
1214 "unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => "item has not been seen"],
1215 "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been deleted"],
1216 "origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item originated at this site"],
1217 "forum_mode" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1218 "mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "The owner of this item was mentioned in it"],
1219 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Network from where the item comes from"],
1220 "rendered-hash" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1221 "rendered-html" => ["type" => "mediumtext", "comment" => "item.body converted to html"],
1222 "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1225 "PRIMARY" => ["id"],
1226 "guid" => ["guid(191)"],
1227 "uri" => ["uri(191)"],
1228 "parent" => ["parent"],
1229 "parent-uri" => ["parent-uri(191)"],
1230 "extid" => ["extid(191)"],
1231 "uid_id" => ["uid","id"],
1232 "uid_contactid_id" => ["uid","contact-id","id"],
1233 "uid_created" => ["uid","created"],
1234 "uid_commented" => ["uid","commented"],
1235 "uid_unseen_contactid" => ["uid","unseen","contact-id"],
1236 "uid_network_received" => ["uid","network","received"],
1237 "uid_network_commented" => ["uid","network","commented"],
1238 "uid_thrparent" => ["uid","thr-parent(190)"],
1239 "uid_parenturi" => ["uid","parent-uri(190)"],
1240 "uid_contactid_created" => ["uid","contact-id","created"],
1241 "authorid_created" => ["author-id","created"],
1242 "ownerid" => ["owner-id"],
1243 "uid_uri" => ["uid", "uri(190)"],
1244 "resource-id" => ["resource-id"],
1245 "contactid_allowcid_allowpid_denycid_denygid" => ["contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"], //
1246 "uid_type_changed" => ["uid","type","changed"],
1247 "contactid_verb" => ["contact-id","verb"],
1248 "deleted_changed" => ["deleted","changed"],
1249 "uid_wall_changed" => ["uid","wall","changed"],
1250 "uid_eventid" => ["uid","event-id"],
1254 $database["item-content"] = [
1255 "comment" => "Content for all posts",
1257 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => ["thread" => "iid"]],
1258 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1259 "uri-plink-hash" => ["type" => "char(80)", "not null" => "1", "default" => "", "comment" => "SHA-1 hash from uri and plink"],
1260 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "item title"],
1261 "content-warning" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1262 "body" => ["type" => "mediumtext", "comment" => "item body content"],
1263 "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "text location where this item originated"],
1264 "coord" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "longitude/latitude pair representing location where this item originated"],
1265 "app" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "application which generated this item"],
1266 "rendered-hash" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1267 "rendered-html" => ["type" => "mediumtext", "comment" => "item.body converted to html"],
1268 "object-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams object type"],
1269 "object" => ["type" => "text", "comment" => "JSON encoded object structure unless it is an implied object (normal post)"],
1270 "target-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams target type if applicable (URI)"],
1271 "target" => ["type" => "text", "comment" => "JSON encoded target structure if used"],
1272 "plink" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "permalink or URL to a displayable copy of the message at its source"],
1275 "PRIMARY" => ["id"],
1276 "uri-plink-hash" => ["UNIQUE", "uri-plink-hash"],
1277 "uri" => ["uri(191)"],
1280 $database["locks"] = [
1283 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1284 "name" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => ""],
1285 "locked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1286 "pid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "Process ID"],
1289 "PRIMARY" => ["id"],
1292 $database["mail"] = [
1293 "comment" => "private messages",
1295 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1296 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1297 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this private message"],
1298 "from-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "name of the sender"],
1299 "from-photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "contact photo link of the sender"],
1300 "from-url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "profile linke of the sender"],
1301 "contact-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => ["contact" => "id"], "comment" => "contact.id"],
1302 "convid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["conv" => "id"], "comment" => "conv.id"],
1303 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1304 "body" => ["type" => "mediumtext", "comment" => ""],
1305 "seen" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if message visited it is 1"],
1306 "reply" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1307 "replied" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1308 "unknown" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if sender not in the contact table this is 1"],
1309 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1310 "parent-uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1311 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation time of the private message"],
1314 "PRIMARY" => ["id"],
1315 "uid_seen" => ["uid", "seen"],
1316 "convid" => ["convid"],
1317 "uri" => ["uri(64)"],
1318 "parent-uri" => ["parent-uri(64)"],
1319 "contactid" => ["contact-id(32)"],
1322 $database["mailacct"] = [
1323 "comment" => "Mail account data for fetching mails",
1325 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1326 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1327 "server" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1328 "port" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1329 "ssltype" => ["type" => "varchar(16)", "not null" => "1", "default" => "", "comment" => ""],
1330 "mailbox" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1331 "user" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1332 "pass" => ["type" => "text", "comment" => ""],
1333 "reply_to" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1334 "action" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1335 "movetofolder" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1336 "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1337 "last_check" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1340 "PRIMARY" => ["id"],
1343 $database["manage"] = [
1344 "comment" => "table of accounts that can manage each other",
1346 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1347 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1348 "mid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1351 "PRIMARY" => ["id"],
1352 "uid_mid" => ["UNIQUE", "uid","mid"],
1355 $database["notify"] = [
1356 "comment" => "notifications",
1358 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1359 "hash" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
1360 "type" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1361 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1362 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1363 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1364 "date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1365 "msg" => ["type" => "mediumtext", "comment" => ""],
1366 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1367 "link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1368 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => "item.id"],
1369 "parent" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1370 "seen" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1371 "verb" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => ""],
1372 "otype" => ["type" => "varchar(10)", "not null" => "1", "default" => "", "comment" => ""],
1373 "name_cache" => ["type" => "tinytext", "comment" => "Cached bbcode parsing of name"],
1374 "msg_cache" => ["type" => "mediumtext", "comment" => "Cached bbcode parsing of msg"]
1377 "PRIMARY" => ["id"],
1378 "hash_uid" => ["hash", "uid"],
1379 "seen_uid_date" => ["seen", "uid", "date"],
1380 "uid_date" => ["uid", "date"],
1381 "uid_type_link" => ["uid", "type", "link(190)"],
1384 $database["notify-threads"] = [
1387 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1388 "notify-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["notify" => "id"], "comment" => ""],
1389 "master-parent-item" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1390 "parent-item" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1391 "receiver-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1394 "PRIMARY" => ["id"],
1397 $database["oembed"] = [
1398 "comment" => "cache for OEmbed queries",
1400 "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "page url"],
1401 "maxwidth" => ["type" => "mediumint unsigned", "not null" => "1", "primary" => "1", "comment" => "Maximum width passed to Oembed"],
1402 "content" => ["type" => "mediumtext", "comment" => "OEmbed data of the page"],
1403 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of creation"],
1406 "PRIMARY" => ["url", "maxwidth"],
1407 "created" => ["created"],
1410 $database["openwebauth-token"] = [
1411 "comment" => "Store OpenWebAuth token to verify contacts",
1413 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1414 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1415 "type" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => "Verify type"],
1416 "token" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A generated token"],
1417 "meta" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1418 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of creation"],
1421 "PRIMARY" => ["id"],
1424 $database["parsed_url"] = [
1425 "comment" => "cache for 'parse_url' queries",
1427 "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "page url"],
1428 "guessing" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => "is the 'guessing' mode active?"],
1429 "oembed" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => "is the data the result of oembed?"],
1430 "content" => ["type" => "mediumtext", "comment" => "page data"],
1431 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of creation"],
1434 "PRIMARY" => ["url", "guessing", "oembed"],
1435 "created" => ["created"],
1438 $database["participation"] = [
1439 "comment" => "Storage for participation messages from Diaspora",
1441 "iid" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "relation" => ["item" => "id"], "comment" => ""],
1442 "server" => ["type" => "varchar(60)", "not null" => "1", "primary" => "1", "comment" => ""],
1443 "cid" => ["type" => "int unsigned", "not null" => "1", "relation" => ["contact" => "id"], "comment" => ""],
1444 "fid" => ["type" => "int unsigned", "not null" => "1", "relation" => ["fcontact" => "id"], "comment" => ""],
1447 "PRIMARY" => ["iid", "server"]
1450 $database["pconfig"] = [
1451 "comment" => "personal (per user) configuration storage",
1453 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1454 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1455 "cat" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""],
1456 "k" => ["type" => "varbinary(100)", "not null" => "1", "default" => "", "comment" => ""],
1457 "v" => ["type" => "mediumtext", "comment" => ""],
1460 "PRIMARY" => ["id"],
1461 "uid_cat_k" => ["UNIQUE", "uid", "cat", "k"],
1464 $database["photo"] = [
1465 "comment" => "photo storage",
1467 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1468 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1469 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id"],
1470 "guid" => ["type" => "char(16)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this photo"],
1471 "resource-id" => ["type" => "char(32)", "not null" => "1", "default" => "", "comment" => ""],
1472 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation date"],
1473 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "last edited date"],
1474 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1475 "desc" => ["type" => "text", "comment" => ""],
1476 "album" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "The name of the album to which the photo belongs"],
1477 "filename" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1478 "type" => ["type" => "varchar(30)", "not null" => "1", "default" => "image/jpeg"],
1479 "height" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1480 "width" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1481 "datasize" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1482 "data" => ["type" => "mediumblob", "not null" => "1", "comment" => ""],
1483 "scale" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1484 "profile" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1485 "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>'"],
1486 "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"],
1487 "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"],
1488 "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"],
1491 "PRIMARY" => ["id"],
1492 "contactid" => ["contact-id"],
1493 "uid_contactid" => ["uid", "contact-id"],
1494 "uid_profile" => ["uid", "profile"],
1495 "uid_album_scale_created" => ["uid", "album(32)", "scale", "created"],
1496 "uid_album_resource-id_created" => ["uid", "album(32)", "resource-id", "created"],
1497 "resource-id" => ["resource-id"],
1500 $database["poll"] = [
1501 "comment" => "Currently unused table for storing poll results",
1503 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1504 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1505 "q0" => ["type" => "text", "comment" => ""],
1506 "q1" => ["type" => "text", "comment" => ""],
1507 "q2" => ["type" => "text", "comment" => ""],
1508 "q3" => ["type" => "text", "comment" => ""],
1509 "q4" => ["type" => "text", "comment" => ""],
1510 "q5" => ["type" => "text", "comment" => ""],
1511 "q6" => ["type" => "text", "comment" => ""],
1512 "q7" => ["type" => "text", "comment" => ""],
1513 "q8" => ["type" => "text", "comment" => ""],
1514 "q9" => ["type" => "text", "comment" => ""],
1517 "PRIMARY" => ["id"],
1521 $database["poll_result"] = [
1522 "comment" => "data for polls - currently unused",
1524 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1525 "poll_id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["poll" => "id"]],
1526 "choice" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1529 "PRIMARY" => ["id"],
1530 "poll_id" => ["poll_id"],
1533 $database["process"] = [
1534 "comment" => "Currently running system processes",
1536 "pid" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "comment" => ""],
1537 "command" => ["type" => "varbinary(32)", "not null" => "1", "default" => "", "comment" => ""],
1538 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1541 "PRIMARY" => ["pid"],
1542 "command" => ["command"],
1545 $database["profile"] = [
1546 "comment" => "user profiles data",
1548 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1549 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1550 "profile-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name of the profile"],
1551 "is-default" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Mark this profile as default profile"],
1552 "hide-friends" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Hide friend list from viewers of this profile"],
1553 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1554 "pdesc" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Title or description"],
1555 "dob" => ["type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00", "comment" => "Day of birth"],
1556 "address" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1557 "locality" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1558 "region" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1559 "postal-code" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1560 "country-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1561 "hometown" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1562 "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1563 "marital" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1564 "with" => ["type" => "text", "comment" => ""],
1565 "howlong" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1566 "sexual" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1567 "politic" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1568 "religion" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1569 "pub_keywords" => ["type" => "text", "comment" => ""],
1570 "prv_keywords" => ["type" => "text", "comment" => ""],
1571 "likes" => ["type" => "text", "comment" => ""],
1572 "dislikes" => ["type" => "text", "comment" => ""],
1573 "about" => ["type" => "text", "comment" => ""],
1574 "summary" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1575 "music" => ["type" => "text", "comment" => ""],
1576 "book" => ["type" => "text", "comment" => ""],
1577 "tv" => ["type" => "text", "comment" => ""],
1578 "film" => ["type" => "text", "comment" => ""],
1579 "interest" => ["type" => "text", "comment" => ""],
1580 "romance" => ["type" => "text", "comment" => ""],
1581 "work" => ["type" => "text", "comment" => ""],
1582 "education" => ["type" => "text", "comment" => ""],
1583 "contact" => ["type" => "text", "comment" => ""],
1584 "homepage" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1585 "xmpp" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1586 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1587 "thumb" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1588 "publish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "publish default profile in local directory"],
1589 "net-publish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "publish profile in global directory"],
1592 "PRIMARY" => ["id"],
1593 "uid_is-default" => ["uid", "is-default"],
1596 $database["profile_check"] = [
1597 "comment" => "DFRN remote auth use",
1599 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1600 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1601 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id"],
1602 "dfrn_id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1603 "sec" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1604 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1607 "PRIMARY" => ["id"],
1610 $database["push_subscriber"] = [
1611 "comment" => "Used for OStatus: Contains feed subscribers",
1613 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1614 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1615 "callback_url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1616 "topic" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1617 "nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1618 "push" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Retrial counter"],
1619 "last_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last successful trial"],
1620 "next_try" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Next retrial date"],
1621 "renewed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last subscription renewal"],
1622 "secret" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1625 "PRIMARY" => ["id"],
1626 "next_try" => ["next_try"],
1629 $database["queue"] = [
1630 "comment" => "Queue for messages that couldn't be delivered",
1632 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1633 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Message receiver"],
1634 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Receiver's network"],
1635 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Unique GUID of the message"],
1636 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date, when the message was created"],
1637 "last" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last trial"],
1638 "next" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Next retrial date"],
1639 "retrial" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Retrial counter"],
1640 "content" => ["type" => "mediumtext", "comment" => ""],
1641 "batch" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1644 "PRIMARY" => ["id"],
1649 $database["register"] = [
1650 "comment" => "registrations requiring admin approval",
1652 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1653 "hash" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1654 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1655 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1656 "password" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1657 "language" => ["type" => "varchar(16)", "not null" => "1", "default" => "", "comment" => ""],
1658 "note" => ["type" => "text", "comment" => ""],
1661 "PRIMARY" => ["id"],
1664 $database["search"] = [
1667 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1668 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1669 "term" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1672 "PRIMARY" => ["id"],
1676 $database["session"] = [
1677 "comment" => "web session storage",
1679 "id" => ["type" => "bigint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1680 "sid" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""],
1681 "data" => ["type" => "text", "comment" => ""],
1682 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1685 "PRIMARY" => ["id"],
1686 "sid" => ["sid(64)"],
1687 "expire" => ["expire"],
1690 $database["sign"] = [
1691 "comment" => "Diaspora signatures",
1693 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1694 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => "item.id"],
1695 "signed_text" => ["type" => "mediumtext", "comment" => ""],
1696 "signature" => ["type" => "text", "comment" => ""],
1697 "signer" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1700 "PRIMARY" => ["id"],
1701 "iid" => ["UNIQUE", "iid"],
1704 $database["term"] = [
1705 "comment" => "item taxonomy (categories, tags, etc.) table",
1707 "tid" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1708 "oid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1709 "otype" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1710 "type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1711 "term" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1712 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1713 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1714 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1715 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1716 "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1717 "aid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1718 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1721 "PRIMARY" => ["tid"],
1722 "oid_otype_type_term" => ["oid","otype","type","term(32)"],
1723 "uid_otype_type_term_global_created" => ["uid","otype","type","term(32)","global","created"],
1724 "uid_otype_type_url" => ["uid","otype","type","url(64)"],
1725 "guid" => ["guid(64)"],
1728 $database["thread"] = [
1729 "comment" => "Thread related data",
1731 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["item" => "id"], "comment" => "sequential ID"],
1732 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1733 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1734 "owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Item owner"],
1735 "author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Item author"],
1736 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1737 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1738 "commented" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1739 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1740 "changed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1741 "wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1742 "private" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1743 "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1744 "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1745 "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1746 "starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1747 "ignored" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1748 "bookmark" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1749 "unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
1750 "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1751 "origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1752 "forum_mode" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1753 "mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1754 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
1757 "PRIMARY" => ["iid"],
1758 "uid_network_commented" => ["uid","network","commented"],
1759 "uid_network_created" => ["uid","network","created"],
1760 "uid_contactid_commented" => ["uid","contact-id","commented"],
1761 "uid_contactid_created" => ["uid","contact-id","created"],
1762 "contactid" => ["contact-id"],
1763 "ownerid" => ["owner-id"],
1764 "authorid" => ["author-id"],
1765 "uid_created" => ["uid","created"],
1766 "uid_commented" => ["uid","commented"],
1767 "uid_wall_created" => ["uid","wall","created"],
1768 "private_wall_origin_commented" => ["private","wall","origin","commented"],
1771 $database["tokens"] = [
1772 "comment" => "OAuth usage",
1774 "id" => ["type" => "varchar(40)", "not null" => "1", "primary" => "1", "comment" => ""],
1775 "secret" => ["type" => "text", "comment" => ""],
1776 "client_id" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => ["clients" => "client_id"]],
1777 "expires" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
1778 "scope" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
1779 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1782 "PRIMARY" => ["id"],
1785 $database["user"] = [
1786 "comment" => "The local users",
1788 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1789 "parent-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "The parent user that has full control about this user"],
1790 "guid" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this user"],
1791 "username" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this user is known by"],
1792 "password" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "encrypted password"],
1793 "legacy_password" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Is the password hash double-hashed?"],
1794 "nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "nick- and user name"],
1795 "email" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "the users email address"],
1796 "openid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1797 "timezone" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => "PHP-legal timezone"],
1798 "language" => ["type" => "varchar(32)", "not null" => "1", "default" => "en", "comment" => "default language"],
1799 "register_date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "timestamp of registration"],
1800 "login_date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "timestamp of last login"],
1801 "default-location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Default for item.location"],
1802 "allow_location" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 allows to display the location"],
1803 "theme" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "user theme preference"],
1804 "pubkey" => ["type" => "text", "comment" => "RSA public key 4096 bit"],
1805 "prvkey" => ["type" => "text", "comment" => "RSA private key 4096 bit"],
1806 "spubkey" => ["type" => "text", "comment" => ""],
1807 "sprvkey" => ["type" => "text", "comment" => ""],
1808 "verified" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "user is verified through email"],
1809 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 for user is blocked"],
1810 "blockwall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Prohibit contacts to post to the profile page of the user"],
1811 "hidewall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Hide profile details from unkown viewers"],
1812 "blocktags" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Prohibit contacts to tag the post of this user"],
1813 "unkmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Permit unknown people to send private mails to this user"],
1814 "cntunkmail" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""],
1815 "notify-flags" => ["type" => "smallint unsigned", "not null" => "1", "default" => "65535", "comment" => "email notification options"],
1816 "page-flags" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "page/profile type"],
1817 "account-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1818 "prvnets" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1819 "pwdreset" => ["type" => "varchar(255)", "comment" => "Password reset request token"],
1820 "pwdreset_time" => ["type" => "datetime", "comment" => "Timestamp of the last password reset request"],
1821 "maxreq" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""],
1822 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1823 "account_removed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if 1 the account is removed"],
1824 "account_expired" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1825 "account_expires_on" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "timestamp when account expires and will be deleted"],
1826 "expire_notification_sent" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "timestamp of last warning of account expiration"],
1827 "def_gid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1828 "allow_cid" => ["type" => "mediumtext", "comment" => "default permission for this user"],
1829 "allow_gid" => ["type" => "mediumtext", "comment" => "default permission for this user"],
1830 "deny_cid" => ["type" => "mediumtext", "comment" => "default permission for this user"],
1831 "deny_gid" => ["type" => "mediumtext", "comment" => "default permission for this user"],
1832 "openidserver" => ["type" => "text", "comment" => ""],
1835 "PRIMARY" => ["uid"],
1836 "nickname" => ["nickname(32)"],
1839 $database["userd"] = [
1840 "comment" => "Deleted usernames",
1842 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1843 "username" => ["type" => "varchar(255)", "not null" => "1", "comment" => ""],
1846 "PRIMARY" => ["id"],
1847 "username" => ["username(32)"],
1850 $database["user-item"] = [
1851 "comment" => "User specific item data",
1853 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["item" => "id"], "comment" => "Item id"],
1854 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["user" => "uid"], "comment" => "User id"],
1855 "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Marker to hide an item from the user"],
1858 "PRIMARY" => ["uid", "iid"],
1861 $database["worker-ipc"] = [
1862 "comment" => "Inter process communication between the frontend and the worker",
1864 "key" => ["type" => "int", "not null" => "1", "primary" => "1", "comment" => ""],
1865 "jobs" => ["type" => "boolean", "comment" => "Flag for outstanding jobs"],
1868 "PRIMARY" => ["key"],
1870 "engine" => "MEMORY",
1873 $database["workerqueue"] = [
1874 "comment" => "Background tasks queue entries",
1876 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "Auto incremented worker task id"],
1877 "parameter" => ["type" => "mediumblob", "comment" => "Task command"],
1878 "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Task priority"],
1879 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Creation date"],
1880 "pid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "Process id of the worker"],
1881 "executed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Execution date"],
1882 "done" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Marked 1 when the task was done - will be deleted later"],
1885 "PRIMARY" => ["id"],
1887 "parameter" => ["parameter(64)"],
1888 "priority_created" => ["priority", "created"],
1889 "done_executed" => ["done", "executed"],
1893 \Friendica\Core\Addon::callHooks('dbstructure_definition', $database);