3 * @file src/Database/DBStructure.php
5 namespace Friendica\Database;
8 use Friendica\Core\Addon;
9 use Friendica\Core\Config;
10 use Friendica\Core\L10n;
11 use Friendica\Util\DateTimeFormat;
13 require_once 'boot.php';
14 require_once 'include/dba.php';
15 require_once 'include/enotify.php';
16 require_once 'include/text.php';
19 * @brief This class contain functions for the database management
21 * This class contains functions that doesn't need to know if pdo, mysqli or whatever is used.
26 * Converts all tables from MyISAM to InnoDB
28 public static function convertToInnoDB() {
29 $r = q("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `engine` = 'MyISAM' AND `table_schema` = '%s'",
30 dbesc(DBA::databaseName()));
32 if (!DBA::isResult($r)) {
33 echo L10n::t('There are no tables on MyISAM.')."\n";
37 foreach ($r AS $table) {
38 $sql = sprintf("ALTER TABLE `%s` engine=InnoDB;", dbesc($table['TABLE_NAME']));
41 $result = DBA::e($sql);
42 if (!DBA::isResult($result)) {
43 self::printUpdateError($sql);
49 * send the email and do what is needed to do on update fails
51 * @param update_id (int) number of failed update
52 * @param error_message (str) error message
54 public static function updateFail($update_id, $error_message) {
57 //send the administrators an e-mail
58 $admin_mail_list = "'".implode("','", array_map('dbesc', explode(",", str_replace(" ", "", Config::get('config', 'admin_email')))))."'";
59 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
64 if (!DBA::isResult($adminlist)) {
65 logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_INFO);
71 // every admin could had different language
72 foreach ($adminlist as $admin) {
73 $lang = (($admin['language'])?$admin['language']:'en');
74 L10n::pushLang($lang);
76 $preamble = deindent(L10n::t("
77 The friendica developers released update %s recently,
78 but when I tried to install it, something went terribly wrong.
79 This needs to be fixed soon and I can't do it alone. Please contact a
80 friendica developer if you can not help me on your own. My database might be invalid."));
81 $body = L10n::t("The error message is\n[pre]%s[/pre]");
82 $preamble = sprintf($preamble, $update_id);
83 $body = sprintf($body, $error_message);
86 'type' => SYSTEM_EMAIL,
87 'to_email' => $admin['email'],
88 'preamble' => $preamble,
95 logger("CRITICAL: Database structure update failed: ".$error_message);
99 private static function tableStructure($table) {
100 $structures = q("DESCRIBE `%s`", $table);
102 $full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table);
104 $indexes = q("SHOW INDEX FROM `%s`", $table);
106 $table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table);
108 if (DBA::isResult($table_status)) {
109 $table_status = $table_status[0];
117 if (DBA::isResult($indexes)) {
118 foreach ($indexes AS $index) {
119 if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
120 $indexdata[$index["Key_name"]] = ['UNIQUE'];
123 $column = $index["Column_name"];
125 if ($index["Sub_part"] != "") {
126 $column .= "(".$index["Sub_part"].")";
129 $indexdata[$index["Key_name"]][] = $column;
132 if (DBA::isResult($structures)) {
133 foreach ($structures AS $field) {
134 // Replace the default size values so that we don't have to define them
135 $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)'];
136 $replace = ['boolean', 'tinyint unsigned', 'tinyint', 'smallint unsigned', 'smallint', 'mediumint unsigned', 'mediumint', 'bigint', 'int unsigned', 'int'];
137 $field["Type"] = str_replace($search, $replace, $field["Type"]);
139 $fielddata[$field["Field"]]["type"] = $field["Type"];
140 if ($field["Null"] == "NO") {
141 $fielddata[$field["Field"]]["not null"] = true;
144 if (isset($field["Default"])) {
145 $fielddata[$field["Field"]]["default"] = $field["Default"];
148 if ($field["Extra"] != "") {
149 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
152 if ($field["Key"] == "PRI") {
153 $fielddata[$field["Field"]]["primary"] = true;
157 if (DBA::isResult($full_columns)) {
158 foreach ($full_columns AS $column) {
159 $fielddata[$column["Field"]]["Collation"] = $column["Collation"];
160 $fielddata[$column["Field"]]["comment"] = $column["Comment"];
164 return ["fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status];
167 public static function printStructure() {
168 $database = self::definition();
170 echo "-- ------------------------------------------\n";
171 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
172 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
173 echo "-- ------------------------------------------\n\n\n";
174 foreach ($database AS $name => $structure) {
176 echo "-- TABLE $name\n";
178 self::createTable($name, $structure, true, false);
185 * @brief Print out database error messages
187 * @param string $message Message to be added to the error message
189 * @return string Error message
191 private static function printUpdateError($message) {
192 echo L10n::t("\nError %d occurred during database update:\n%s\n",
193 DBA::errorNo(), DBA::errorMessage());
195 return L10n::t('Errors encountered performing database changes: ').$message.EOL;
199 * Updates DB structure and returns eventual errors messages
201 * @param bool $verbose
202 * @param bool $action Whether to actually apply the update
203 * @param bool $install Is this the initial update during the installation?
204 * @param array $tables An array of the database tables
205 * @param array $definition An array of the definition tables
206 * @return string Empty string if the update is successful, error messages otherwise
208 public static function update($verbose, $action, $install = false, array $tables = null, array $definition = null) {
209 if ($action && !$install) {
210 Config::set('system', 'maintenance', 1);
211 Config::set('system', 'maintenance_reason', L10n::t('%s: Database update', DateTimeFormat::utcNow().' '.date('e')));
216 logger('updating structure', LOGGER_DEBUG);
218 // Get the current structure
221 if (is_null($tables)) {
222 $tables = q("SHOW TABLES");
225 if (DBA::isResult($tables)) {
226 foreach ($tables AS $table) {
227 $table = current($table);
229 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
230 $database[$table] = self::tableStructure($table);
234 // Get the definition
235 if (is_null($definition)) {
236 $definition = self::definition();
239 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
240 if ((version_compare(DBA::serverInfo(), '5.7.4') >= 0) &&
241 !(strpos(DBA::serverInfo(), 'MariaDB') !== false)) {
248 foreach ($definition AS $name => $structure) {
249 $is_new_table = false;
254 if (!isset($database[$name])) {
255 $r = self::createTable($name, $structure, $verbose, $action);
256 if (!DBA::isResult($r)) {
257 $errors .= self::printUpdateError($name);
259 $is_new_table = true;
261 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
262 if (isset($database[$name]["indexes"][$indexname])) {
263 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
265 $current_index_definition = "__NOT_SET__";
267 $new_index_definition = implode(",",$fieldnames);
268 if ($current_index_definition != $new_index_definition) {
269 if ($fieldnames[0] == "UNIQUE") {
272 $temp_name = "temp-".$name;
279 * Drop the index if it isn't present in the definition
280 * or the definition differ from current status
281 * and index name doesn't start with "local_"
283 foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
284 $current_index_definition = implode(",",$fieldnames);
285 if (isset($structure["indexes"][$indexname])) {
286 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
288 $new_index_definition = "__NOT_SET__";
290 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
291 $sql2=self::dropIndex($indexname);
293 $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
299 // Compare the field structure field by field
300 foreach ($structure["fields"] AS $fieldname => $parameters) {
301 if (!isset($database[$name]["fields"][$fieldname])) {
302 $sql2=self::addTableField($fieldname, $parameters);
304 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
309 // Compare the field definition
310 $field_definition = $database[$name]["fields"][$fieldname];
312 // Remove the relation data that is used for the referential integrity
313 unset($parameters['relation']);
315 // We change the collation after the indexes had been changed.
316 // This is done to avoid index length problems.
317 // So here we always ensure that there is no need to change it.
318 unset($parameters['Collation']);
319 unset($field_definition['Collation']);
321 // Only update the comment when it is defined
322 if (!isset($parameters['comment'])) {
323 $parameters['comment'] = "";
326 $current_field_definition = DBA::cleanQuery(implode(",", $field_definition));
327 $new_field_definition = DBA::cleanQuery(implode(",", $parameters));
328 if ($current_field_definition != $new_field_definition) {
329 $sql2 = self::modifyTableField($fieldname, $parameters);
331 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
341 * Create the index if the index don't exists in database
342 * or the definition differ from the current status.
343 * Don't create keys if table is new
345 if (!$is_new_table) {
346 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
347 if (isset($database[$name]["indexes"][$indexname])) {
348 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
350 $current_index_definition = "__NOT_SET__";
352 $new_index_definition = implode(",",$fieldnames);
353 if ($current_index_definition != $new_index_definition) {
354 $sql2 = self::createIndex($indexname, $fieldnames);
356 // Fetch the "group by" fields for unique indexes
357 if ($fieldnames[0] == "UNIQUE") {
358 $group_by = self::groupBy($indexname, $fieldnames);
362 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
370 if (isset($database[$name]["table_status"]["Comment"])) {
371 if ($database[$name]["table_status"]["Comment"] != $structure['comment']) {
372 $sql2 = "COMMENT = '".dbesc($structure['comment'])."'";
375 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
382 if (isset($database[$name]["table_status"]["Engine"]) && isset($structure['engine'])) {
383 if ($database[$name]["table_status"]["Engine"] != $structure['engine']) {
384 $sql2 = "ENGINE = '".dbesc($structure['engine'])."'";
387 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
394 if (isset($database[$name]["table_status"]["Collation"])) {
395 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
396 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
399 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
410 // Now have a look at the field collations
411 // Compare the field structure field by field
412 foreach ($structure["fields"] AS $fieldname => $parameters) {
413 // Compare the field definition
414 $field_definition = defaults($database[$name]["fields"], $fieldname, ['Collation' => '']);
416 // Define the default collation if not given
417 if (!isset($parameters['Collation']) && !empty($field_definition['Collation'])) {
418 $parameters['Collation'] = 'utf8mb4_general_ci';
420 $parameters['Collation'] = null;
423 if ($field_definition['Collation'] != $parameters['Collation']) {
424 $sql2 = self::modifyTableField($fieldname, $parameters);
425 if (($sql3 == "") || (substr($sql3, -2, 2) == "; ")) {
426 $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
435 if (substr($sql3, -2, 2) != "; ") {
440 if ($is_unique && $ignore == '') {
441 foreach ($database[$name]["fields"] AS $fieldname => $parameters) {
442 $field_list .= 'ANY_VALUE(`' . $fieldname . '`),';
444 $field_list = rtrim($field_list, ',');
448 // Ensure index conversion to unique removes duplicates
449 if ($is_unique && ($temp_name != $name)) {
451 echo "SET session old_alter_table=1;\n";
453 echo "DROP TABLE IF EXISTS `".$temp_name."`;\n";
454 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
460 if ($is_unique && ($temp_name != $name)) {
462 echo "SET session old_alter_table=0;\n";
464 echo "INSERT INTO `".$temp_name."` SELECT ".DBA::anyValueFallback($field_list)." FROM `".$name."`".$group_by.";\n";
465 echo "DROP TABLE `".$name."`;\n";
466 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
473 Config::set('system', 'maintenance_reason', L10n::t('%s: updating %s table.', DateTimeFormat::utcNow().' '.date('e'), $name));
476 // Ensure index conversion to unique removes duplicates
477 if ($is_unique && ($temp_name != $name)) {
479 DBA::e("SET session old_alter_table=1;");
481 $r = DBA::e("DROP TABLE IF EXISTS `".$temp_name."`;");
482 if (!DBA::isResult($r)) {
483 $errors .= self::printUpdateError($sql3);
487 $r = DBA::e("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
488 if (!DBA::isResult($r)) {
489 $errors .= self::printUpdateError($sql3);
496 if (!DBA::isResult($r)) {
497 $errors .= self::printUpdateError($sql3);
499 if ($is_unique && ($temp_name != $name)) {
501 DBA::e("SET session old_alter_table=0;");
503 $r = DBA::e("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
504 if (!DBA::isResult($r)) {
505 $errors .= self::printUpdateError($sql3);
508 $r = DBA::e("DROP TABLE `".$name."`;");
509 if (!DBA::isResult($r)) {
510 $errors .= self::printUpdateError($sql3);
513 $r = DBA::e("RENAME TABLE `".$temp_name."` TO `".$name."`;");
514 if (!DBA::isResult($r)) {
515 $errors .= self::printUpdateError($sql3);
524 if ($action && !$install) {
525 Config::set('system', 'maintenance', 0);
526 Config::set('system', 'maintenance_reason', '');
529 Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
531 Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
538 private static function FieldCommand($parameters, $create = true) {
539 $fieldstruct = $parameters["type"];
541 if (isset($parameters["Collation"])) {
542 $fieldstruct .= " COLLATE ".$parameters["Collation"];
545 if (isset($parameters["not null"])) {
546 $fieldstruct .= " NOT NULL";
549 if (isset($parameters["default"])) {
550 if (strpos(strtolower($parameters["type"]),"int")!==false) {
551 $fieldstruct .= " DEFAULT ".$parameters["default"];
553 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
556 if (isset($parameters["extra"])) {
557 $fieldstruct .= " ".$parameters["extra"];
560 if (isset($parameters["comment"])) {
561 $fieldstruct .= " COMMENT '".dbesc($parameters["comment"])."'";
564 /*if (($parameters["primary"] != "") && $create)
565 $fieldstruct .= " PRIMARY KEY";*/
567 return($fieldstruct);
570 private static function createTable($name, $structure, $verbose, $action) {
577 foreach ($structure["fields"] AS $fieldname => $field) {
578 $sql_rows[] = "`".dbesc($fieldname)."` ".self::FieldCommand($field);
579 if (x($field,'primary') && $field['primary']!='') {
580 $primary_keys[] = $fieldname;
584 if (!empty($structure["indexes"])) {
585 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
586 $sql_index = self::createIndex($indexname, $fieldnames, "");
587 if (!is_null($sql_index)) {
588 $sql_rows[] = $sql_index;
593 if (isset($structure["engine"])) {
594 $engine = " ENGINE=" . $structure["engine"];
597 if (isset($structure["comment"])) {
598 $comment = " COMMENT='" . dbesc($structure["comment"]) . "'";
601 $sql = implode(",\n\t", $sql_rows);
603 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql.
604 "\n)" . $engine . " DEFAULT COLLATE utf8mb4_general_ci" . $comment;
616 private static function addTableField($fieldname, $parameters) {
617 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), self::FieldCommand($parameters));
621 private static function modifyTableField($fieldname, $parameters) {
622 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), self::FieldCommand($parameters, false));
626 private static function dropIndex($indexname) {
627 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
631 private static function createIndex($indexname, $fieldnames, $method = "ADD") {
632 $method = strtoupper(trim($method));
633 if ($method!="" && $method!="ADD") {
634 throw new Exception("Invalid parameter 'method' in self::createIndex(): '$method'");
637 if ($fieldnames[0] == "UNIQUE") {
638 array_shift($fieldnames);
639 $method .= ' UNIQUE';
643 foreach ($fieldnames AS $fieldname) {
648 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
649 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
651 $names .= "`".dbesc($fieldname)."`";
655 if ($indexname == "PRIMARY") {
656 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
660 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
664 private static function groupBy($indexname, $fieldnames) {
665 if ($fieldnames[0] != "UNIQUE") {
669 array_shift($fieldnames);
672 foreach ($fieldnames AS $fieldname) {
677 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
678 $names .= "`".dbesc($matches[1])."`";
680 $names .= "`".dbesc($fieldname)."`";
684 $sql = sprintf(" GROUP BY %s", $names);
689 * Check if a table exists
691 * @param string $table Table name
693 * @return boolean Does the table exist?
695 public static function existsTable($table)
701 $table = DBA::escape($table);
703 $sql = "SHOW TABLES LIKE '" . $table . "';";
705 $stmt = DBA::p($sql);
707 if (is_bool($stmt)) {
710 $retval = (DBA::numRows($stmt) > 0);
719 * Check if the columns of the table exists
721 * @param string $table Table name
722 * @param array $columns Columns to check ( Syntax: [ $col1, $col2, .. ] )
724 * @return boolean Does the table exist?
726 public static function existsColumn($table, $columns = []) {
731 if (is_null($columns) || empty($columns)) {
732 return self::existsTable($table);
735 $table = DBA::escape($table);
737 foreach ($columns AS $column) {
738 $sql = "SHOW COLUMNS FROM `" . $table . "` LIKE '" . $column . "';";
740 $stmt = DBA::p($sql);
742 if (is_bool($stmt)) {
745 $retval = (DBA::numRows($stmt) > 0);
758 const RENAME_COLUMN = 0;
759 const RENAME_PRIMARY_KEY = 1;
762 * Renames columns or the primary key of a table
763 * @todo You cannot rename a primary key if "auto increment" is set
765 * @param string $table Table name
766 * @param array $columns Columns Syntax for Rename: [ $old1 => [ $new1, $type1 ], $old2 => [ $new2, $type2 ], ... ] )
767 * Syntax for Primary Key: [ $col1, $col2, ...] )
768 * @param int $type The type of renaming (Default is Column)
770 * @return boolean Was the renaming successful?
773 public static function rename($table, $columns, $type = self::RENAME_COLUMN) {
774 if (empty($table) || empty($columns)) {
778 if (!is_array($columns)) {
782 $table = DBA::escape($table);
784 $sql = "ALTER TABLE `" . $table . "`";
786 case self::RENAME_COLUMN:
787 if (!self::existsColumn($table, array_keys($columns))) {
790 $sql .= implode(',', array_map(
791 function ($to, $from) {
792 return " CHANGE `" . $from . "` `" . $to[0] . "` " . $to[1];
798 case self::RENAME_PRIMARY_KEY:
799 if (!self::existsColumn($table, $columns)) {
802 $sql .= " DROP PRIMARY KEY, ADD PRIMARY KEY(`" . implode('`, `', $columns) . "`)";
810 $stmt = DBA::p($sql);
812 if (is_bool($stmt)) {
823 public static function definition() {
826 $database["addon"] = [
827 "comment" => "registered addons",
829 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
830 "name" => ["type" => "varchar(50)", "not null" => "1", "default" => "", "comment" => "addon base (file)name"],
831 "version" => ["type" => "varchar(50)", "not null" => "1", "default" => "", "comment" => "currently unused"],
832 "installed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "currently always 1"],
833 "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "currently unused"],
834 "timestamp" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "file timestamp to check for reloads"],
835 "plugin_admin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 = has admin config, 0 = has no admin config"],
839 "name" => ["UNIQUE", "name"],
842 $database["attach"] = [
843 "comment" => "file attachments",
845 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "generated index"],
846 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
847 "hash" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "hash"],
848 "filename" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "filename of original"],
849 "filetype" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "mimetype"],
850 "filesize" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "size in bytes"],
851 "data" => ["type" => "longblob", "not null" => "1", "comment" => "file data"],
852 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation time"],
853 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "last edit time"],
854 "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>"],
855 "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"],
856 "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"],
857 "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"],
863 $database["auth_codes"] = [
864 "comment" => "OAuth usage",
866 "id" => ["type" => "varchar(40)", "not null" => "1", "primary" => "1", "comment" => ""],
867 "client_id" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => ["clients" => "client_id"], "comment" => ""],
868 "redirect_uri" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
869 "expires" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
870 "scope" => ["type" => "varchar(250)", "not null" => "1", "default" => "", "comment" => ""],
876 $database["cache"] = [
877 "comment" => "Stores temporary data",
879 "k" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "cache key"],
880 "v" => ["type" => "mediumtext", "comment" => "cached serialized value"],
881 "expires" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of cache expiration"],
882 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of cache insertion"],
886 "k_expires" => ["k", "expires"],
889 $database["challenge"] = [
892 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
893 "challenge" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
894 "dfrn-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
895 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
896 "type" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
897 "last_update" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
903 $database["clients"] = [
904 "comment" => "OAuth usage",
906 "client_id" => ["type" => "varchar(20)", "not null" => "1", "primary" => "1", "comment" => ""],
907 "pw" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => ""],
908 "redirect_uri" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
909 "name" => ["type" => "text", "comment" => ""],
910 "icon" => ["type" => "text", "comment" => ""],
911 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
914 "PRIMARY" => ["client_id"],
917 $database["config"] = [
918 "comment" => "main configuration storage",
920 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
921 "cat" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""],
922 "k" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""],
923 "v" => ["type" => "mediumtext", "comment" => ""],
927 "cat_k" => ["UNIQUE", "cat", "k"],
930 $database["contact"] = [
931 "comment" => "contact table",
933 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
934 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
935 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
936 "self" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 if the contact is the user him/her self"],
937 "remote_self" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
938 "rel" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "The kind of the relation between the user and the contact"],
939 "duplex" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
940 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Network protocol of the contact"],
941 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this contact is known by"],
942 "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Nick- and user name of the contact"],
943 "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
944 "about" => ["type" => "text", "comment" => ""],
945 "keywords" => ["type" => "text", "comment" => "public keywords (interests) of the contact"],
946 "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
947 "xmpp" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
948 "attag" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
949 "avatar" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
950 "photo" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo of the contact"],
951 "thumb" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo (thumb size)"],
952 "micro" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo (micro size)"],
953 "site-pubkey" => ["type" => "text", "comment" => ""],
954 "issued-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
955 "dfrn-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
956 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
957 "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
958 "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
959 "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
960 "pubkey" => ["type" => "text", "comment" => "RSA public key 4096 bit"],
961 "prvkey" => ["type" => "text", "comment" => "RSA private key 4096 bit"],
962 "batch" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
963 "request" => ["type" => "varchar(255)", "comment" => ""],
964 "notify" => ["type" => "varchar(255)", "comment" => ""],
965 "poll" => ["type" => "varchar(255)", "comment" => ""],
966 "confirm" => ["type" => "varchar(255)", "comment" => ""],
967 "poco" => ["type" => "varchar(255)", "comment" => ""],
968 "aes_allow" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
969 "ret-aes" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
970 "usehub" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
971 "subhub" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
972 "hub-verify" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
973 "last-update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of the last try to update the contact info"],
974 "success_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of the last successful contact update"],
975 "failure_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of the last failed update"],
976 "name-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
977 "uri-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
978 "avatar-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
979 "term-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
980 "last-item" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "date of the last post"],
981 "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
982 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
983 "readonly" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "posts of the contact are readonly"],
984 "writable" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
985 "forum" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "contact is a forum"],
986 "prv" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "contact is a private group"],
987 "contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
988 "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
989 "archive" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
990 "pending" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
991 "rating" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
992 "reason" => ["type" => "text", "comment" => ""],
993 "closeness" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "99", "comment" => ""],
994 "info" => ["type" => "mediumtext", "comment" => ""],
995 "profile-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
996 "bdyear" => ["type" => "varchar(4)", "not null" => "1", "default" => "", "comment" => ""],
997 "bd" => ["type" => "date", "not null" => "1", "default" => "0001-01-01", "comment" => ""],
998 "notify_new_posts" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
999 "fetch_further_information" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1000 "ffi_keyword_blacklist" => ["type" => "text", "comment" => ""],
1003 "PRIMARY" => ["id"],
1004 "uid_name" => ["uid", "name(190)"],
1005 "self_uid" => ["self", "uid"],
1006 "alias_uid" => ["alias(32)", "uid"],
1007 "pending_uid" => ["pending", "uid"],
1008 "blocked_uid" => ["blocked", "uid"],
1009 "uid_rel_network_poll" => ["uid", "rel", "network", "poll(64)", "archive"],
1010 "uid_network_batch" => ["uid", "network", "batch(64)"],
1011 "addr_uid" => ["addr(32)", "uid"],
1012 "nurl_uid" => ["nurl(32)", "uid"],
1013 "nick_uid" => ["nick(32)", "uid"],
1014 "dfrn-id" => ["dfrn-id(64)"],
1015 "issued-id" => ["issued-id(64)"],
1018 $database["conv"] = [
1019 "comment" => "private messages",
1021 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1022 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this conversation"],
1023 "recips" => ["type" => "text", "comment" => "sender_handle;recipient_handle"],
1024 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1025 "creator" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "handle of creator"],
1026 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation timestamp"],
1027 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "edited timestamp"],
1028 "subject" => ["type" => "text", "comment" => "subject of initial message"],
1031 "PRIMARY" => ["id"],
1035 $database["conversation"] = [
1036 "comment" => "Raw data and structure information for messages",
1038 "item-uri" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "URI of the item"],
1039 "reply-to-uri" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => "URI to which this item is a reply"],
1040 "conversation-uri" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => "GNU Social conversation URI"],
1041 "conversation-href" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => "GNU Social conversation link"],
1042 "protocol" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "The protocol of the item"],
1043 "source" => ["type" => "mediumtext", "comment" => "Original source"],
1044 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Receiving date"],
1047 "PRIMARY" => ["item-uri"],
1048 "conversation-uri" => ["conversation-uri"],
1049 "received" => ["received"],
1052 $database["event"] = [
1053 "comment" => "Events",
1055 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1056 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1057 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1058 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact_id (ID of the contact in contact table)"],
1059 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1060 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation time"],
1061 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "last edit time"],
1062 "start" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "event start time"],
1063 "finish" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "event end time"],
1064 "summary" => ["type" => "text", "comment" => "short description or title of the event"],
1065 "desc" => ["type" => "text", "comment" => "event description"],
1066 "location" => ["type" => "text", "comment" => "event location"],
1067 "type" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => "event or birthday"],
1068 "nofinish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if event does have no end this is 1"],
1069 "adjust" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => "adjust to timezone of the recipient (0 or 1)"],
1070 "ignore" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "0 or 1"],
1071 "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>'"],
1072 "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"],
1073 "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"],
1074 "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"],
1077 "PRIMARY" => ["id"],
1078 "uid_start" => ["uid", "start"],
1081 $database["fcontact"] = [
1082 "comment" => "Diaspora compatible contacts - used in the Diaspora implementation",
1084 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1085 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "unique id"],
1086 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1087 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1088 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1089 "request" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1090 "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1091 "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1092 "batch" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1093 "notify" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1094 "poll" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1095 "confirm" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1096 "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1097 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
1098 "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1099 "pubkey" => ["type" => "text", "comment" => ""],
1100 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1103 "PRIMARY" => ["id"],
1104 "addr" => ["addr(32)"],
1105 "url" => ["UNIQUE", "url(190)"],
1108 $database["fsuggest"] = [
1109 "comment" => "friend suggestion stuff",
1111 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1112 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1113 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1114 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1115 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1116 "request" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1117 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1118 "note" => ["type" => "text", "comment" => ""],
1119 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1122 "PRIMARY" => ["id"],
1125 $database["gcign"] = [
1126 "comment" => "contacts ignored by friend suggestions",
1128 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1129 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Local User id"],
1130 "gcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => "gcontact.id of ignored contact"],
1133 "PRIMARY" => ["id"],
1138 $database["gcontact"] = [
1139 "comment" => "global contacts",
1141 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1142 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this contact is known by"],
1143 "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Nick- and user name of the contact"],
1144 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Link to the contacts profile page"],
1145 "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1146 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Link to the profile photo"],
1147 "connect" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1148 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1149 "updated" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1150 "last_contact" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1151 "last_failure" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1152 "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1153 "about" => ["type" => "text", "comment" => ""],
1154 "keywords" => ["type" => "text", "comment" => "puplic keywords (interests)"],
1155 "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1156 "birthday" => ["type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01", "comment" => ""],
1157 "community" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 if contact is forum account"],
1158 "contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "-1", "comment" => ""],
1159 "hide" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 = should be hidden from search"],
1160 "nsfw" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 = contact posts nsfw content"],
1161 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "social network protocol"],
1162 "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1163 "notify" => ["type" => "varchar(255)", "comment" => ""],
1164 "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1165 "generation" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1166 "server_url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "baseurl of the contacts server"],
1169 "PRIMARY" => ["id"],
1170 "nurl" => ["UNIQUE", "nurl(190)"],
1171 "name" => ["name(64)"],
1172 "nick" => ["nick(32)"],
1173 "addr" => ["addr(64)"],
1174 "hide_network_updated" => ["hide", "network", "updated"],
1175 "updated" => ["updated"],
1178 $database["glink"] = [
1179 "comment" => "'friends of friends' linkages derived from poco",
1181 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1182 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1183 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1184 "gcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""],
1185 "zcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""],
1186 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1189 "PRIMARY" => ["id"],
1190 "cid_uid_gcid_zcid" => ["UNIQUE", "cid","uid","gcid","zcid"],
1194 $database["group"] = [
1195 "comment" => "privacy groups, group info",
1197 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1198 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1199 "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 indicates the member list is not private"],
1200 "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 indicates the group has been deleted"],
1201 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "human readable name of group"],
1204 "PRIMARY" => ["id"],
1208 $database["group_member"] = [
1209 "comment" => "privacy groups, member info",
1211 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1212 "gid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["group" => "id"], "comment" => "groups.id of the associated group"],
1213 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id of the member assigned to the associated group"],
1216 "PRIMARY" => ["id"],
1217 "contactid" => ["contact-id"],
1218 "gid_contactid" => ["UNIQUE", "gid", "contact-id"],
1221 $database["gserver"] = [
1222 "comment" => "Global servers",
1224 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1225 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1226 "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1227 "version" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1228 "site_name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1229 "info" => ["type" => "text", "comment" => ""],
1230 "register_policy" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
1231 "registered-users" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "Number of registered users"],
1232 "poco" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1233 "noscrape" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1234 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
1235 "platform" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1236 "relay-subscribe" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Has the server subscribed to the relay system"],
1237 "relay-scope" => ["type" => "varchar(10)", "not null" => "1", "default" => "", "comment" => "The scope of messages that the server wants to get"],
1238 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1239 "last_poco_query" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1240 "last_contact" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1241 "last_failure" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1244 "PRIMARY" => ["id"],
1245 "nurl" => ["UNIQUE", "nurl(190)"],
1248 $database["gserver-tag"] = [
1249 "comment" => "Tags that the server has subscribed",
1251 "gserver-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gserver" => "id"], "primary" => "1", "comment" => "The id of the gserver"],
1252 "tag" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "primary" => "1", "comment" => "Tag that the server has subscribed"],
1255 "PRIMARY" => ["gserver-id", "tag"],
1259 $database["hook"] = [
1260 "comment" => "addon hook registry",
1262 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1263 "hook" => ["type" => "varbinary(100)", "not null" => "1", "default" => "", "comment" => "name of hook"],
1264 "file" => ["type" => "varbinary(200)", "not null" => "1", "default" => "", "comment" => "relative filename of hook handler"],
1265 "function" => ["type" => "varbinary(200)", "not null" => "1", "default" => "", "comment" => "function name of hook handler"],
1266 "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"],
1269 "PRIMARY" => ["id"],
1270 "hook_file_function" => ["UNIQUE", "hook", "file", "function"],
1273 $database["intro"] = [
1276 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1277 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1278 "fid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["fcontact" => "id"], "comment" => ""],
1279 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1280 "knowyou" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1281 "duplex" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1282 "note" => ["type" => "text", "comment" => ""],
1283 "hash" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1284 "datetime" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1285 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
1286 "ignore" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1289 "PRIMARY" => ["id"],
1292 $database["item"] = [
1293 "comment" => "Structure for all posts",
1295 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => ["thread" => "iid"]],
1296 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this item"],
1297 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1298 "uri-hash" => ["type" => "varchar(80)", "not null" => "1", "default" => "", "comment" => "RIPEMD-128 hash from uri"],
1299 "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"],
1300 "parent-uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "uri of the parent to this item"],
1301 "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"],
1302 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Creation timestamp."],
1303 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last edit (default is created)"],
1304 "commented" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last comment/reply to this item"],
1305 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime"],
1306 "changed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date that something in the conversation changed, indicating clients should fetch the conversation again"],
1307 "gravity" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1308 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Network from where the item comes from"],
1309 "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"],
1310 "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"],
1311 "icid" => ["type" => "int unsigned", "relation" => ["item-content" => "id"], "comment" => "Id of the item-content table entry that contains the whole item content"],
1312 "iaid" => ["type" => "int unsigned", "relation" => ["item-activity" => "id"], "comment" => "Id of the item-activity table entry that contains the activity data"],
1313 "extid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1314 "post-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Post type (personal note, bookmark, ...)"],
1315 "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1316 "private" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "distribution is restricted"],
1317 "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1318 "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1319 "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been deleted"],
1320 // User specific fields. Eventually they will move to user-item
1321 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner id which owns this copy of the item"],
1322 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id"],
1323 "wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "This item was posted to the wall of uid"],
1324 "origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item originated at this site"],
1325 "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1326 "starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been favourited"],
1327 "unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => "item has not been seen"],
1328 "mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "The owner of this item was mentioned in it"],
1329 "forum_mode" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1330 "psid" => ["type" => "int unsigned", "relation" => ["permissionset" => "id"], "comment" => "ID of the permission set of this post"],
1331 // These fields will be replaced by the "psid" from above
1332 "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>'"],
1333 "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"],
1334 "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"],
1335 "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"],
1336 // It is to be decided whether these fields belong to the user or the structure
1337 "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"],
1338 "event-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["event" => "id"], "comment" => "Used to link to the event.id"],
1339 // Could possibly be replaced by the "attach" table?
1340 "attach" => ["type" => "mediumtext", "comment" => "JSON structure representing attachments to this item"],
1341 // Deprecated fields. Will be removed in upcoming versions
1342 "postopts" => ["type" => "text", "comment" => "Deprecated"],
1343 "inform" => ["type" => "mediumtext", "comment" => "Deprecated"],
1344 "type" => ["type" => "varchar(20)", "comment" => "Deprecated"],
1345 "bookmark" => ["type" => "boolean", "comment" => "Deprecated"],
1346 "file" => ["type" => "mediumtext", "comment" => "Deprecated"],
1347 "location" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1348 "coord" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1349 "tag" => ["type" => "mediumtext", "comment" => "Deprecated"],
1350 "plink" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1351 "title" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1352 "content-warning" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1353 "body" => ["type" => "mediumtext", "comment" => "Deprecated"],
1354 "app" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1355 "verb" => ["type" => "varchar(100)", "comment" => "Deprecated"],
1356 "object-type" => ["type" => "varchar(100)", "comment" => "Deprecated"],
1357 "object" => ["type" => "text", "comment" => "Deprecated"],
1358 "target-type" => ["type" => "varchar(100)", "comment" => "Deprecated"],
1359 "target" => ["type" => "text", "comment" => "Deprecated"],
1360 "author-name" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1361 "author-link" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1362 "author-avatar" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1363 "owner-name" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1364 "owner-link" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1365 "owner-avatar" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1366 "rendered-hash" => ["type" => "varchar(32)", "comment" => "Deprecated"],
1367 "rendered-html" => ["type" => "mediumtext", "comment" => "Deprecated"],
1370 "PRIMARY" => ["id"],
1371 "guid" => ["guid(191)"],
1372 "uri" => ["uri(191)"],
1373 "parent" => ["parent"],
1374 "parent-uri" => ["parent-uri(191)"],
1375 "extid" => ["extid(191)"],
1376 "uid_id" => ["uid","id"],
1377 "uid_contactid_id" => ["uid","contact-id","id"],
1378 "uid_created" => ["uid","created"],
1379 "uid_commented" => ["uid","commented"],
1380 "uid_unseen_contactid" => ["uid","unseen","contact-id"],
1381 "uid_network_received" => ["uid","network","received"],
1382 "uid_network_commented" => ["uid","network","commented"],
1383 "uid_thrparent" => ["uid","thr-parent(190)"],
1384 "uid_parenturi" => ["uid","parent-uri(190)"],
1385 "uid_contactid_created" => ["uid","contact-id","created"],
1386 "authorid_created" => ["author-id","created"],
1387 "ownerid" => ["owner-id"],
1388 "uid_uri" => ["uid", "uri(190)"],
1389 "resource-id" => ["resource-id"],
1390 "deleted_changed" => ["deleted","changed"],
1391 "uid_wall_changed" => ["uid","wall","changed"],
1392 "uid_eventid" => ["uid","event-id"],
1398 $database["item-activity"] = [
1399 "comment" => "Activities for items",
1401 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => ["thread" => "iid"]],
1402 "uri" => ["type" => "varchar(255)", "comment" => ""],
1403 "uri-hash" => ["type" => "varchar(80)", "not null" => "1", "default" => "", "comment" => "RIPEMD-128 hash from uri"],
1404 "activity" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1407 "PRIMARY" => ["id"],
1408 "uri-hash" => ["UNIQUE", "uri-hash"],
1409 "uri" => ["uri(191)"],
1412 $database["item-content"] = [
1413 "comment" => "Content for all posts",
1415 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => ["thread" => "iid"]],
1416 "uri" => ["type" => "varchar(255)", "comment" => ""],
1417 "uri-plink-hash" => ["type" => "varchar(80)", "not null" => "1", "default" => "", "comment" => "RIPEMD-128 hash from uri"],
1418 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "item title"],
1419 "content-warning" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1420 "body" => ["type" => "mediumtext", "comment" => "item body content"],
1421 "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "text location where this item originated"],
1422 "coord" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "longitude/latitude pair representing location where this item originated"],
1423 "language" => ["type" => "text", "comment" => "Language information about this post"],
1424 "app" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "application which generated this item"],
1425 "rendered-hash" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1426 "rendered-html" => ["type" => "mediumtext", "comment" => "item.body converted to html"],
1427 "object-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams object type"],
1428 "object" => ["type" => "text", "comment" => "JSON encoded object structure unless it is an implied object (normal post)"],
1429 "target-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams target type if applicable (URI)"],
1430 "target" => ["type" => "text", "comment" => "JSON encoded target structure if used"],
1431 "plink" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "permalink or URL to a displayable copy of the message at its source"],
1432 "verb" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams verb"],
1435 "PRIMARY" => ["id"],
1436 "uri-plink-hash" => ["UNIQUE", "uri-plink-hash"],
1437 "uri" => ["uri(191)"],
1440 $database["item-delivery-data"] = [
1441 "comment" => "Delivery data for items",
1443 "iid" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "relation" => ["item" => "id"], "comment" => "Item id"],
1444 "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"],
1445 "inform" => ["type" => "mediumtext", "comment" => "Additional receivers of the linked item"],
1448 "PRIMARY" => ["iid"],
1451 $database["locks"] = [
1454 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1455 "name" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => ""],
1456 "locked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1457 "pid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "Process ID"],
1458 "expires" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of cache expiration"],
1461 "PRIMARY" => ["id"],
1462 "name_expires" => ["name", "expires"]
1465 $database["mail"] = [
1466 "comment" => "private messages",
1468 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1469 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1470 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this private message"],
1471 "from-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "name of the sender"],
1472 "from-photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "contact photo link of the sender"],
1473 "from-url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "profile linke of the sender"],
1474 "contact-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => ["contact" => "id"], "comment" => "contact.id"],
1475 "convid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["conv" => "id"], "comment" => "conv.id"],
1476 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1477 "body" => ["type" => "mediumtext", "comment" => ""],
1478 "seen" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if message visited it is 1"],
1479 "reply" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1480 "replied" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1481 "unknown" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if sender not in the contact table this is 1"],
1482 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1483 "parent-uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1484 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation time of the private message"],
1487 "PRIMARY" => ["id"],
1488 "uid_seen" => ["uid", "seen"],
1489 "convid" => ["convid"],
1490 "uri" => ["uri(64)"],
1491 "parent-uri" => ["parent-uri(64)"],
1492 "contactid" => ["contact-id(32)"],
1495 $database["mailacct"] = [
1496 "comment" => "Mail account data for fetching mails",
1498 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1499 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1500 "server" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1501 "port" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1502 "ssltype" => ["type" => "varchar(16)", "not null" => "1", "default" => "", "comment" => ""],
1503 "mailbox" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1504 "user" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1505 "pass" => ["type" => "text", "comment" => ""],
1506 "reply_to" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1507 "action" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1508 "movetofolder" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1509 "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1510 "last_check" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1513 "PRIMARY" => ["id"],
1516 $database["manage"] = [
1517 "comment" => "table of accounts that can manage each other",
1519 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1520 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1521 "mid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1524 "PRIMARY" => ["id"],
1525 "uid_mid" => ["UNIQUE", "uid","mid"],
1528 $database["notify"] = [
1529 "comment" => "notifications",
1531 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1532 "hash" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
1533 "type" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1534 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1535 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1536 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1537 "date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1538 "msg" => ["type" => "mediumtext", "comment" => ""],
1539 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1540 "link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1541 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => "item.id"],
1542 "parent" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1543 "seen" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1544 "verb" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => ""],
1545 "otype" => ["type" => "varchar(10)", "not null" => "1", "default" => "", "comment" => ""],
1546 "name_cache" => ["type" => "tinytext", "comment" => "Cached bbcode parsing of name"],
1547 "msg_cache" => ["type" => "mediumtext", "comment" => "Cached bbcode parsing of msg"]
1550 "PRIMARY" => ["id"],
1551 "hash_uid" => ["hash", "uid"],
1552 "seen_uid_date" => ["seen", "uid", "date"],
1553 "uid_date" => ["uid", "date"],
1554 "uid_type_link" => ["uid", "type", "link(190)"],
1557 $database["notify-threads"] = [
1560 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1561 "notify-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["notify" => "id"], "comment" => ""],
1562 "master-parent-item" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1563 "parent-item" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1564 "receiver-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1567 "PRIMARY" => ["id"],
1570 $database["oembed"] = [
1571 "comment" => "cache for OEmbed queries",
1573 "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "page url"],
1574 "maxwidth" => ["type" => "mediumint unsigned", "not null" => "1", "primary" => "1", "comment" => "Maximum width passed to Oembed"],
1575 "content" => ["type" => "mediumtext", "comment" => "OEmbed data of the page"],
1576 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of creation"],
1579 "PRIMARY" => ["url", "maxwidth"],
1580 "created" => ["created"],
1583 $database["openwebauth-token"] = [
1584 "comment" => "Store OpenWebAuth token to verify contacts",
1586 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1587 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1588 "type" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => "Verify type"],
1589 "token" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A generated token"],
1590 "meta" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1591 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of creation"],
1594 "PRIMARY" => ["id"],
1597 $database["parsed_url"] = [
1598 "comment" => "cache for 'parse_url' queries",
1600 "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "page url"],
1601 "guessing" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => "is the 'guessing' mode active?"],
1602 "oembed" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => "is the data the result of oembed?"],
1603 "content" => ["type" => "mediumtext", "comment" => "page data"],
1604 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of creation"],
1607 "PRIMARY" => ["url", "guessing", "oembed"],
1608 "created" => ["created"],
1611 $database["participation"] = [
1612 "comment" => "Storage for participation messages from Diaspora",
1614 "iid" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "relation" => ["item" => "id"], "comment" => ""],
1615 "server" => ["type" => "varchar(60)", "not null" => "1", "primary" => "1", "comment" => ""],
1616 "cid" => ["type" => "int unsigned", "not null" => "1", "relation" => ["contact" => "id"], "comment" => ""],
1617 "fid" => ["type" => "int unsigned", "not null" => "1", "relation" => ["fcontact" => "id"], "comment" => ""],
1620 "PRIMARY" => ["iid", "server"]
1623 $database["pconfig"] = [
1624 "comment" => "personal (per user) configuration storage",
1626 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1627 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1628 "cat" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""],
1629 "k" => ["type" => "varbinary(100)", "not null" => "1", "default" => "", "comment" => ""],
1630 "v" => ["type" => "mediumtext", "comment" => ""],
1633 "PRIMARY" => ["id"],
1634 "uid_cat_k" => ["UNIQUE", "uid", "cat", "k"],
1637 $database["permissionset"] = [
1640 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1641 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner id of this permission set"],
1642 "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>'"],
1643 "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"],
1644 "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"],
1645 "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"],
1648 "PRIMARY" => ["id"],
1649 "uid_allow_cid_allow_gid_deny_cid_deny_gid" => ["allow_cid(50)", "allow_gid(30)", "deny_cid(50)", "deny_gid(30)"],
1652 $database["photo"] = [
1653 "comment" => "photo storage",
1655 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1656 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1657 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id"],
1658 "guid" => ["type" => "char(16)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this photo"],
1659 "resource-id" => ["type" => "char(32)", "not null" => "1", "default" => "", "comment" => ""],
1660 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation date"],
1661 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "last edited date"],
1662 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1663 "desc" => ["type" => "text", "comment" => ""],
1664 "album" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "The name of the album to which the photo belongs"],
1665 "filename" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1666 "type" => ["type" => "varchar(30)", "not null" => "1", "default" => "image/jpeg"],
1667 "height" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1668 "width" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1669 "datasize" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1670 "data" => ["type" => "mediumblob", "not null" => "1", "comment" => ""],
1671 "scale" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1672 "profile" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1673 "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>'"],
1674 "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"],
1675 "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"],
1676 "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"],
1679 "PRIMARY" => ["id"],
1680 "contactid" => ["contact-id"],
1681 "uid_contactid" => ["uid", "contact-id"],
1682 "uid_profile" => ["uid", "profile"],
1683 "uid_album_scale_created" => ["uid", "album(32)", "scale", "created"],
1684 "uid_album_resource-id_created" => ["uid", "album(32)", "resource-id", "created"],
1685 "resource-id" => ["resource-id"],
1688 $database["poll"] = [
1689 "comment" => "Currently unused table for storing poll results",
1691 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1692 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1693 "q0" => ["type" => "text", "comment" => ""],
1694 "q1" => ["type" => "text", "comment" => ""],
1695 "q2" => ["type" => "text", "comment" => ""],
1696 "q3" => ["type" => "text", "comment" => ""],
1697 "q4" => ["type" => "text", "comment" => ""],
1698 "q5" => ["type" => "text", "comment" => ""],
1699 "q6" => ["type" => "text", "comment" => ""],
1700 "q7" => ["type" => "text", "comment" => ""],
1701 "q8" => ["type" => "text", "comment" => ""],
1702 "q9" => ["type" => "text", "comment" => ""],
1705 "PRIMARY" => ["id"],
1709 $database["poll_result"] = [
1710 "comment" => "data for polls - currently unused",
1712 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1713 "poll_id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["poll" => "id"]],
1714 "choice" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1717 "PRIMARY" => ["id"],
1718 "poll_id" => ["poll_id"],
1721 $database["process"] = [
1722 "comment" => "Currently running system processes",
1724 "pid" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "comment" => ""],
1725 "command" => ["type" => "varbinary(32)", "not null" => "1", "default" => "", "comment" => ""],
1726 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1729 "PRIMARY" => ["pid"],
1730 "command" => ["command"],
1733 $database["profile"] = [
1734 "comment" => "user profiles data",
1736 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1737 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1738 "profile-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name of the profile"],
1739 "is-default" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Mark this profile as default profile"],
1740 "hide-friends" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Hide friend list from viewers of this profile"],
1741 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1742 "pdesc" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Title or description"],
1743 "dob" => ["type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00", "comment" => "Day of birth"],
1744 "address" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1745 "locality" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1746 "region" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1747 "postal-code" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1748 "country-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1749 "hometown" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1750 "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1751 "marital" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1752 "with" => ["type" => "text", "comment" => ""],
1753 "howlong" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1754 "sexual" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1755 "politic" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1756 "religion" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1757 "pub_keywords" => ["type" => "text", "comment" => ""],
1758 "prv_keywords" => ["type" => "text", "comment" => ""],
1759 "likes" => ["type" => "text", "comment" => ""],
1760 "dislikes" => ["type" => "text", "comment" => ""],
1761 "about" => ["type" => "text", "comment" => ""],
1762 "summary" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1763 "music" => ["type" => "text", "comment" => ""],
1764 "book" => ["type" => "text", "comment" => ""],
1765 "tv" => ["type" => "text", "comment" => ""],
1766 "film" => ["type" => "text", "comment" => ""],
1767 "interest" => ["type" => "text", "comment" => ""],
1768 "romance" => ["type" => "text", "comment" => ""],
1769 "work" => ["type" => "text", "comment" => ""],
1770 "education" => ["type" => "text", "comment" => ""],
1771 "contact" => ["type" => "text", "comment" => ""],
1772 "homepage" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1773 "xmpp" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1774 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1775 "thumb" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1776 "publish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "publish default profile in local directory"],
1777 "net-publish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "publish profile in global directory"],
1780 "PRIMARY" => ["id"],
1781 "uid_is-default" => ["uid", "is-default"],
1784 $database["profile_check"] = [
1785 "comment" => "DFRN remote auth use",
1787 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1788 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1789 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id"],
1790 "dfrn_id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1791 "sec" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1792 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1795 "PRIMARY" => ["id"],
1798 $database["push_subscriber"] = [
1799 "comment" => "Used for OStatus: Contains feed subscribers",
1801 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1802 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1803 "callback_url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1804 "topic" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1805 "nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1806 "push" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Retrial counter"],
1807 "last_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last successful trial"],
1808 "next_try" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Next retrial date"],
1809 "renewed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last subscription renewal"],
1810 "secret" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1813 "PRIMARY" => ["id"],
1814 "next_try" => ["next_try"],
1817 $database["queue"] = [
1818 "comment" => "Queue for messages that couldn't be delivered",
1820 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1821 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Message receiver"],
1822 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Receiver's network"],
1823 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Unique GUID of the message"],
1824 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date, when the message was created"],
1825 "last" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last trial"],
1826 "next" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Next retrial date"],
1827 "retrial" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Retrial counter"],
1828 "content" => ["type" => "mediumtext", "comment" => ""],
1829 "batch" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1832 "PRIMARY" => ["id"],
1837 $database["register"] = [
1838 "comment" => "registrations requiring admin approval",
1840 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1841 "hash" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1842 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1843 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1844 "password" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1845 "language" => ["type" => "varchar(16)", "not null" => "1", "default" => "", "comment" => ""],
1846 "note" => ["type" => "text", "comment" => ""],
1849 "PRIMARY" => ["id"],
1852 $database["search"] = [
1855 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1856 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1857 "term" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1860 "PRIMARY" => ["id"],
1864 $database["session"] = [
1865 "comment" => "web session storage",
1867 "id" => ["type" => "bigint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1868 "sid" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""],
1869 "data" => ["type" => "text", "comment" => ""],
1870 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1873 "PRIMARY" => ["id"],
1874 "sid" => ["sid(64)"],
1875 "expire" => ["expire"],
1878 $database["sign"] = [
1879 "comment" => "Diaspora signatures",
1881 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1882 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => "item.id"],
1883 "signed_text" => ["type" => "mediumtext", "comment" => ""],
1884 "signature" => ["type" => "text", "comment" => ""],
1885 "signer" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1888 "PRIMARY" => ["id"],
1889 "iid" => ["UNIQUE", "iid"],
1892 $database["term"] = [
1893 "comment" => "item taxonomy (categories, tags, etc.) table",
1895 "tid" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1896 "oid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1897 "otype" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1898 "type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1899 "term" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1900 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1901 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1902 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1903 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1904 "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1905 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1908 "PRIMARY" => ["tid"],
1909 "oid_otype_type_term" => ["oid","otype","type","term(32)"],
1910 "uid_otype_type_term_global_created" => ["uid","otype","type","term(32)","global","created"],
1911 "uid_otype_type_url" => ["uid","otype","type","url(64)"],
1912 "guid" => ["guid(64)"],
1915 $database["thread"] = [
1916 "comment" => "Thread related data",
1918 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["item" => "id"], "comment" => "sequential ID"],
1919 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1920 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1921 "owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Item owner"],
1922 "author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Item author"],
1923 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1924 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1925 "commented" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1926 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1927 "changed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1928 "wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1929 "private" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1930 "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1931 "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1932 "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1933 "starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1934 "ignored" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1935 "post-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Post type (personal note, bookmark, ...)"],
1936 "unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
1937 "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1938 "origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1939 "forum_mode" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1940 "mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1941 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
1942 "bookmark" => ["type" => "boolean", "comment" => ""],
1945 "PRIMARY" => ["iid"],
1946 "uid_network_commented" => ["uid","network","commented"],
1947 "uid_network_created" => ["uid","network","created"],
1948 "uid_contactid_commented" => ["uid","contact-id","commented"],
1949 "uid_contactid_created" => ["uid","contact-id","created"],
1950 "contactid" => ["contact-id"],
1951 "ownerid" => ["owner-id"],
1952 "authorid" => ["author-id"],
1953 "uid_created" => ["uid","created"],
1954 "uid_commented" => ["uid","commented"],
1955 "uid_wall_created" => ["uid","wall","created"],
1956 "private_wall_origin_commented" => ["private","wall","origin","commented"],
1959 $database["tokens"] = [
1960 "comment" => "OAuth usage",
1962 "id" => ["type" => "varchar(40)", "not null" => "1", "primary" => "1", "comment" => ""],
1963 "secret" => ["type" => "text", "comment" => ""],
1964 "client_id" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => ["clients" => "client_id"]],
1965 "expires" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
1966 "scope" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
1967 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1970 "PRIMARY" => ["id"],
1973 $database["user"] = [
1974 "comment" => "The local users",
1976 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1977 "parent-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "The parent user that has full control about this user"],
1978 "guid" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this user"],
1979 "username" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this user is known by"],
1980 "password" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "encrypted password"],
1981 "legacy_password" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Is the password hash double-hashed?"],
1982 "nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "nick- and user name"],
1983 "email" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "the users email address"],
1984 "openid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1985 "timezone" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => "PHP-legal timezone"],
1986 "language" => ["type" => "varchar(32)", "not null" => "1", "default" => "en", "comment" => "default language"],
1987 "register_date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "timestamp of registration"],
1988 "login_date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "timestamp of last login"],
1989 "default-location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Default for item.location"],
1990 "allow_location" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 allows to display the location"],
1991 "theme" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "user theme preference"],
1992 "pubkey" => ["type" => "text", "comment" => "RSA public key 4096 bit"],
1993 "prvkey" => ["type" => "text", "comment" => "RSA private key 4096 bit"],
1994 "spubkey" => ["type" => "text", "comment" => ""],
1995 "sprvkey" => ["type" => "text", "comment" => ""],
1996 "verified" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "user is verified through email"],
1997 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 for user is blocked"],
1998 "blockwall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Prohibit contacts to post to the profile page of the user"],
1999 "hidewall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Hide profile details from unkown viewers"],
2000 "blocktags" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Prohibit contacts to tag the post of this user"],
2001 "unkmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Permit unknown people to send private mails to this user"],
2002 "cntunkmail" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""],
2003 "notify-flags" => ["type" => "smallint unsigned", "not null" => "1", "default" => "65535", "comment" => "email notification options"],
2004 "page-flags" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "page/profile type"],
2005 "account-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
2006 "prvnets" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
2007 "pwdreset" => ["type" => "varchar(255)", "comment" => "Password reset request token"],
2008 "pwdreset_time" => ["type" => "datetime", "comment" => "Timestamp of the last password reset request"],
2009 "maxreq" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""],
2010 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
2011 "account_removed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if 1 the account is removed"],
2012 "account_expired" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
2013 "account_expires_on" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "timestamp when account expires and will be deleted"],
2014 "expire_notification_sent" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "timestamp of last warning of account expiration"],
2015 "def_gid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
2016 "allow_cid" => ["type" => "mediumtext", "comment" => "default permission for this user"],
2017 "allow_gid" => ["type" => "mediumtext", "comment" => "default permission for this user"],
2018 "deny_cid" => ["type" => "mediumtext", "comment" => "default permission for this user"],
2019 "deny_gid" => ["type" => "mediumtext", "comment" => "default permission for this user"],
2020 "openidserver" => ["type" => "text", "comment" => ""],
2023 "PRIMARY" => ["uid"],
2024 "nickname" => ["nickname(32)"],
2027 $database["userd"] = [
2028 "comment" => "Deleted usernames",
2030 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
2031 "username" => ["type" => "varchar(255)", "not null" => "1", "comment" => ""],
2034 "PRIMARY" => ["id"],
2035 "username" => ["username(32)"],
2038 $database["user-item"] = [
2039 "comment" => "User specific item data",
2041 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["item" => "id"], "comment" => "Item id"],
2042 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["user" => "uid"], "comment" => "User id"],
2043 "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Marker to hide an item from the user"],
2046 "PRIMARY" => ["uid", "iid"],
2049 $database["worker-ipc"] = [
2050 "comment" => "Inter process communication between the frontend and the worker",
2052 "key" => ["type" => "int", "not null" => "1", "primary" => "1", "comment" => ""],
2053 "jobs" => ["type" => "boolean", "comment" => "Flag for outstanding jobs"],
2056 "PRIMARY" => ["key"],
2058 "engine" => "MEMORY",
2061 $database["workerqueue"] = [
2062 "comment" => "Background tasks queue entries",
2064 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "Auto incremented worker task id"],
2065 "parameter" => ["type" => "mediumblob", "comment" => "Task command"],
2066 "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Task priority"],
2067 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Creation date"],
2068 "pid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "Process id of the worker"],
2069 "executed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Execution date"],
2070 "done" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Marked 1 when the task was done - will be deleted later"],
2073 "PRIMARY" => ["id"],
2075 "parameter" => ["parameter(64)"],
2076 "priority_created" => ["priority", "created"],
2077 "done_executed" => ["done", "executed"],
2081 Addon::callHooks('dbstructure_definition', $database);