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;
12 require_once 'boot.php';
13 require_once 'include/dba.php';
14 require_once 'include/enotify.php';
15 require_once 'include/text.php';
18 * @brief This class contain functions for the database management
20 * This class contains functions that doesn't need to know if pdo, mysqli or whatever is used.
25 * Converts all tables from MyISAM to InnoDB
27 public static function convertToInnoDB() {
28 $r = q("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `engine` = 'MyISAM' AND `table_schema` = '%s'",
29 dbesc(DBA::databaseName()));
31 if (!DBM::is_result($r)) {
32 echo L10n::t('There are no tables on MyISAM.')."\n";
36 foreach ($r AS $table) {
37 $sql = sprintf("ALTER TABLE `%s` engine=InnoDB;", dbesc($table['TABLE_NAME']));
40 $result = DBA::e($sql);
41 if (!DBM::is_result($result)) {
42 self::printUpdateError($sql);
48 * send the email and do what is needed to do on update fails
50 * @param update_id (int) number of failed update
51 * @param error_message (str) error message
53 public static function updateFail($update_id, $error_message) {
56 //send the administrators an e-mail
57 $admin_mail_list = "'".implode("','", array_map('dbesc', explode(",", str_replace(" ", "", Config::get('config', 'admin_email')))))."'";
58 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
63 if (!DBM::is_result($adminlist)) {
64 logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_INFO);
70 // every admin could had different language
71 foreach ($adminlist as $admin) {
72 $lang = (($admin['language'])?$admin['language']:'en');
73 L10n::pushLang($lang);
75 $preamble = deindent(L10n::t("
76 The friendica developers released update %s recently,
77 but when I tried to install it, something went terribly wrong.
78 This needs to be fixed soon and I can't do it alone. Please contact a
79 friendica developer if you can not help me on your own. My database might be invalid."));
80 $body = L10n::t("The error message is\n[pre]%s[/pre]");
81 $preamble = sprintf($preamble, $update_id);
82 $body = sprintf($body, $error_message);
85 'type' => SYSTEM_EMAIL,
86 'to_email' => $admin['email'],
87 'preamble' => $preamble,
94 logger("CRITICAL: Database structure update failed: ".$error_message);
98 private static function tableStructure($table) {
99 $structures = q("DESCRIBE `%s`", $table);
101 $full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table);
103 $indexes = q("SHOW INDEX FROM `%s`", $table);
105 $table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table);
107 if (DBM::is_result($table_status)) {
108 $table_status = $table_status[0];
116 if (DBM::is_result($indexes)) {
117 foreach ($indexes AS $index) {
118 if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
119 $indexdata[$index["Key_name"]] = ['UNIQUE'];
122 $column = $index["Column_name"];
124 if ($index["Sub_part"] != "") {
125 $column .= "(".$index["Sub_part"].")";
128 $indexdata[$index["Key_name"]][] = $column;
131 if (DBM::is_result($structures)) {
132 foreach ($structures AS $field) {
133 // Replace the default size values so that we don't have to define them
134 $search = ['tinyint(1)', 'tinyint(3) unsigned', 'tinyint(4)', 'smallint(5) unsigned', 'smallint(6)', 'mediumint(8) unsigned', 'mediumint(9)', 'bigint(20)', 'int(10) unsigned', 'int(11)'];
135 $replace = ['boolean', 'tinyint unsigned', 'tinyint', 'smallint unsigned', 'smallint', 'mediumint unsigned', 'mediumint', 'bigint', 'int unsigned', 'int'];
136 $field["Type"] = str_replace($search, $replace, $field["Type"]);
138 $fielddata[$field["Field"]]["type"] = $field["Type"];
139 if ($field["Null"] == "NO") {
140 $fielddata[$field["Field"]]["not null"] = true;
143 if (isset($field["Default"])) {
144 $fielddata[$field["Field"]]["default"] = $field["Default"];
147 if ($field["Extra"] != "") {
148 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
151 if ($field["Key"] == "PRI") {
152 $fielddata[$field["Field"]]["primary"] = true;
156 if (DBM::is_result($full_columns)) {
157 foreach ($full_columns AS $column) {
158 $fielddata[$column["Field"]]["Collation"] = $column["Collation"];
159 $fielddata[$column["Field"]]["comment"] = $column["Comment"];
163 return ["fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status];
166 public static function printStructure() {
167 $database = self::definition();
169 echo "-- ------------------------------------------\n";
170 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
171 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
172 echo "-- ------------------------------------------\n\n\n";
173 foreach ($database AS $name => $structure) {
175 echo "-- TABLE $name\n";
177 self::createTable($name, $structure, true, false);
184 * @brief Print out database error messages
186 * @param string $message Message to be added to the error message
188 * @return string Error message
190 private static function printUpdateError($message) {
191 echo L10n::t("\nError %d occurred during database update:\n%s\n",
192 DBA::errorNo(), DBA::errorMessage());
194 return L10n::t('Errors encountered performing database changes: ').$message.EOL;
198 * Updates DB structure and returns eventual errors messages
200 * @param bool $verbose
201 * @param bool $action Whether to actually apply the update
202 * @param bool $install Is this the initial update during the installation?
203 * @param array $tables An array of the database tables
204 * @param array $definition An array of the definition tables
205 * @return string Empty string if the update is successful, error messages otherwise
207 public static function update($verbose, $action, $install = false, array $tables = null, array $definition = null) {
208 if ($action && !$install) {
209 Config::set('system', 'maintenance', 1);
210 Config::set('system', 'maintenance_reason', L10n::t('%s: Database update', DBM::date().' '.date('e')));
215 logger('updating structure', LOGGER_DEBUG);
217 // Get the current structure
220 if (is_null($tables)) {
221 $tables = q("SHOW TABLES");
224 if (DBM::is_result($tables)) {
225 foreach ($tables AS $table) {
226 $table = current($table);
228 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
229 $database[$table] = self::tableStructure($table);
233 // Get the definition
234 if (is_null($definition)) {
235 $definition = self::definition();
238 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
239 if ((version_compare(DBA::serverInfo(), '5.7.4') >= 0) &&
240 !(strpos(DBA::serverInfo(), 'MariaDB') !== false)) {
247 foreach ($definition AS $name => $structure) {
248 $is_new_table = false;
253 if (!isset($database[$name])) {
254 $r = self::createTable($name, $structure, $verbose, $action);
255 if (!DBM::is_result($r)) {
256 $errors .= self::printUpdateError($name);
258 $is_new_table = true;
260 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
261 if (isset($database[$name]["indexes"][$indexname])) {
262 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
264 $current_index_definition = "__NOT_SET__";
266 $new_index_definition = implode(",",$fieldnames);
267 if ($current_index_definition != $new_index_definition) {
268 if ($fieldnames[0] == "UNIQUE") {
271 $temp_name = "temp-".$name;
278 * Drop the index if it isn't present in the definition
279 * or the definition differ from current status
280 * and index name doesn't start with "local_"
282 foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
283 $current_index_definition = implode(",",$fieldnames);
284 if (isset($structure["indexes"][$indexname])) {
285 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
287 $new_index_definition = "__NOT_SET__";
289 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
290 $sql2=self::dropIndex($indexname);
292 $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
298 // Compare the field structure field by field
299 foreach ($structure["fields"] AS $fieldname => $parameters) {
300 if (!isset($database[$name]["fields"][$fieldname])) {
301 $sql2=self::addTableField($fieldname, $parameters);
303 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
308 // Compare the field definition
309 $field_definition = $database[$name]["fields"][$fieldname];
311 // Remove the relation data that is used for the referential integrity
312 unset($parameters['relation']);
314 // We change the collation after the indexes had been changed.
315 // This is done to avoid index length problems.
316 // So here we always ensure that there is no need to change it.
317 unset($parameters['Collation']);
318 unset($field_definition['Collation']);
320 // Only update the comment when it is defined
321 if (!isset($parameters['comment'])) {
322 $parameters['comment'] = "";
325 $current_field_definition = DBA::cleanQuery(implode(",", $field_definition));
326 $new_field_definition = DBA::cleanQuery(implode(",", $parameters));
327 if ($current_field_definition != $new_field_definition) {
328 $sql2 = self::modifyTableField($fieldname, $parameters);
330 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
340 * Create the index if the index don't exists in database
341 * or the definition differ from the current status.
342 * Don't create keys if table is new
344 if (!$is_new_table) {
345 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
346 if (isset($database[$name]["indexes"][$indexname])) {
347 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
349 $current_index_definition = "__NOT_SET__";
351 $new_index_definition = implode(",",$fieldnames);
352 if ($current_index_definition != $new_index_definition) {
353 $sql2 = self::createIndex($indexname, $fieldnames);
355 // Fetch the "group by" fields for unique indexes
356 if ($fieldnames[0] == "UNIQUE") {
357 $group_by = self::groupBy($indexname, $fieldnames);
361 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
369 if (isset($database[$name]["table_status"]["Comment"])) {
370 if ($database[$name]["table_status"]["Comment"] != $structure['comment']) {
371 $sql2 = "COMMENT = '".dbesc($structure['comment'])."'";
374 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
381 if (isset($database[$name]["table_status"]["Engine"]) && isset($structure['engine'])) {
382 if ($database[$name]["table_status"]["Engine"] != $structure['engine']) {
383 $sql2 = "ENGINE = '".dbesc($structure['engine'])."'";
386 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
393 if (isset($database[$name]["table_status"]["Collation"])) {
394 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
395 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
398 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
409 // Now have a look at the field collations
410 // Compare the field structure field by field
411 foreach ($structure["fields"] AS $fieldname => $parameters) {
412 // Compare the field definition
413 $field_definition = defaults($database[$name]["fields"], $fieldname, ['Collation' => '']);
415 // Define the default collation if not given
416 if (!isset($parameters['Collation']) && !empty($field_definition['Collation'])) {
417 $parameters['Collation'] = 'utf8mb4_general_ci';
419 $parameters['Collation'] = null;
422 if ($field_definition['Collation'] != $parameters['Collation']) {
423 $sql2 = self::modifyTableField($fieldname, $parameters);
424 if (($sql3 == "") || (substr($sql3, -2, 2) == "; ")) {
425 $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
434 if (substr($sql3, -2, 2) != "; ") {
439 if ($is_unique && $ignore == '') {
440 foreach ($database[$name]["fields"] AS $fieldname => $parameters) {
441 $field_list .= 'ANY_VALUE(`' . $fieldname . '`),';
443 $field_list = rtrim($field_list, ',');
447 // Ensure index conversion to unique removes duplicates
448 if ($is_unique && ($temp_name != $name)) {
450 echo "SET session old_alter_table=1;\n";
452 echo "DROP TABLE IF EXISTS `".$temp_name."`;\n";
453 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
459 if ($is_unique && ($temp_name != $name)) {
461 echo "SET session old_alter_table=0;\n";
463 echo "INSERT INTO `".$temp_name."` SELECT ".DBA::anyValueFallback($field_list)." FROM `".$name."`".$group_by.";\n";
464 echo "DROP TABLE `".$name."`;\n";
465 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
472 Config::set('system', 'maintenance_reason', L10n::t('%s: updating %s table.', DBM::date().' '.date('e'), $name));
475 // Ensure index conversion to unique removes duplicates
476 if ($is_unique && ($temp_name != $name)) {
478 DBA::e("SET session old_alter_table=1;");
480 $r = DBA::e("DROP TABLE IF EXISTS `".$temp_name."`;");
481 if (!DBM::is_result($r)) {
482 $errors .= self::printUpdateError($sql3);
486 $r = DBA::e("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
487 if (!DBM::is_result($r)) {
488 $errors .= self::printUpdateError($sql3);
495 if (!DBM::is_result($r)) {
496 $errors .= self::printUpdateError($sql3);
498 if ($is_unique && ($temp_name != $name)) {
500 DBA::e("SET session old_alter_table=0;");
502 $r = DBA::e("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
503 if (!DBM::is_result($r)) {
504 $errors .= self::printUpdateError($sql3);
507 $r = DBA::e("DROP TABLE `".$name."`;");
508 if (!DBM::is_result($r)) {
509 $errors .= self::printUpdateError($sql3);
512 $r = DBA::e("RENAME TABLE `".$temp_name."` TO `".$name."`;");
513 if (!DBM::is_result($r)) {
514 $errors .= self::printUpdateError($sql3);
523 if ($action && !$install) {
524 Config::set('system', 'maintenance', 0);
525 Config::set('system', 'maintenance_reason', '');
528 Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
530 Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
537 private static function FieldCommand($parameters, $create = true) {
538 $fieldstruct = $parameters["type"];
540 if (isset($parameters["Collation"])) {
541 $fieldstruct .= " COLLATE ".$parameters["Collation"];
544 if (isset($parameters["not null"])) {
545 $fieldstruct .= " NOT NULL";
548 if (isset($parameters["default"])) {
549 if (strpos(strtolower($parameters["type"]),"int")!==false) {
550 $fieldstruct .= " DEFAULT ".$parameters["default"];
552 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
555 if (isset($parameters["extra"])) {
556 $fieldstruct .= " ".$parameters["extra"];
559 if (isset($parameters["comment"])) {
560 $fieldstruct .= " COMMENT '".dbesc($parameters["comment"])."'";
563 /*if (($parameters["primary"] != "") && $create)
564 $fieldstruct .= " PRIMARY KEY";*/
566 return($fieldstruct);
569 private static function createTable($name, $structure, $verbose, $action) {
576 foreach ($structure["fields"] AS $fieldname => $field) {
577 $sql_rows[] = "`".dbesc($fieldname)."` ".self::FieldCommand($field);
578 if (x($field,'primary') && $field['primary']!='') {
579 $primary_keys[] = $fieldname;
583 if (!empty($structure["indexes"])) {
584 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
585 $sql_index = self::createIndex($indexname, $fieldnames, "");
586 if (!is_null($sql_index)) {
587 $sql_rows[] = $sql_index;
592 if (isset($structure["engine"])) {
593 $engine = " ENGINE=" . $structure["engine"];
596 if (isset($structure["comment"])) {
597 $comment = " COMMENT='" . dbesc($structure["comment"]) . "'";
600 $sql = implode(",\n\t", $sql_rows);
602 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql.
603 "\n)" . $engine . " DEFAULT COLLATE utf8mb4_general_ci" . $comment;
615 private static function addTableField($fieldname, $parameters) {
616 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), self::FieldCommand($parameters));
620 private static function modifyTableField($fieldname, $parameters) {
621 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), self::FieldCommand($parameters, false));
625 private static function dropIndex($indexname) {
626 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
630 private static function createIndex($indexname, $fieldnames, $method = "ADD") {
631 $method = strtoupper(trim($method));
632 if ($method!="" && $method!="ADD") {
633 throw new Exception("Invalid parameter 'method' in self::createIndex(): '$method'");
636 if ($fieldnames[0] == "UNIQUE") {
637 array_shift($fieldnames);
638 $method .= ' UNIQUE';
642 foreach ($fieldnames AS $fieldname) {
647 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
648 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
650 $names .= "`".dbesc($fieldname)."`";
654 if ($indexname == "PRIMARY") {
655 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
659 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
663 private static function groupBy($indexname, $fieldnames) {
664 if ($fieldnames[0] != "UNIQUE") {
668 array_shift($fieldnames);
671 foreach ($fieldnames AS $fieldname) {
676 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
677 $names .= "`".dbesc($matches[1])."`";
679 $names .= "`".dbesc($fieldname)."`";
683 $sql = sprintf(" GROUP BY %s", $names);
688 * Check if a table exists
690 * @param string $table Table name
692 * @return boolean Does the table exist?
694 public static function existsTable($table)
700 $table = DBA::escape($table);
702 $sql = "SHOW TABLES LIKE '" . $table . "';";
704 $stmt = DBA::p($sql);
706 if (is_bool($stmt)) {
709 $retval = (DBA::numRows($stmt) > 0);
718 * Check if the columns of the table exists
720 * @param string $table Table name
721 * @param array $columns Columns to check ( Syntax: [ $col1, $col2, .. ] )
723 * @return boolean Does the table exist?
725 public static function existsColumn($table, $columns = []) {
730 if (is_null($columns) || empty($columns)) {
731 return self::existsTable($table);
734 $table = DBA::escape($table);
736 foreach ($columns AS $column) {
737 $sql = "SHOW COLUMNS FROM `" . $table . "` LIKE '" . $column . "';";
739 $stmt = DBA::p($sql);
741 if (is_bool($stmt)) {
744 $retval = (DBA::numRows($stmt) > 0);
757 const RENAME_COLUMN = 0;
758 const RENAME_PRIMARY_KEY = 1;
761 * Renames columns or the primary key of a table
762 * @todo You cannot rename a primary key if "auto increment" is set
764 * @param string $table Table name
765 * @param array $columns Columns Syntax for Rename: [ $old1 => [ $new1, $type1 ], $old2 => [ $new2, $type2 ], ... ] )
766 * Syntax for Primary Key: [ $col1, $col2, ...] )
767 * @param int $type The type of renaming (Default is Column)
769 * @return boolean Was the renaming successful?
772 public static function rename($table, $columns, $type = self::RENAME_COLUMN) {
773 if (empty($table) || empty($columns)) {
777 if (!is_array($columns)) {
781 $table = DBA::escape($table);
783 $sql = "ALTER TABLE `" . $table . "`";
785 case self::RENAME_COLUMN:
786 if (!self::existsColumn($table, array_keys($columns))) {
789 $sql .= implode(',', array_map(
790 function ($to, $from) {
791 return " CHANGE `" . $from . "` `" . $to[0] . "` " . $to[1];
797 case self::RENAME_PRIMARY_KEY:
798 if (!self::existsColumn($table, $columns)) {
801 $sql .= " DROP PRIMARY KEY, ADD PRIMARY KEY(`" . implode('`, `', $columns) . "`)";
809 $stmt = DBA::p($sql);
811 if (is_bool($stmt)) {
822 public static function definition() {
825 $database["addon"] = [
826 "comment" => "registered addons",
828 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
829 "name" => ["type" => "varchar(50)", "not null" => "1", "default" => "", "comment" => "addon base (file)name"],
830 "version" => ["type" => "varchar(50)", "not null" => "1", "default" => "", "comment" => "currently unused"],
831 "installed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "currently always 1"],
832 "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "currently unused"],
833 "timestamp" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "file timestamp to check for reloads"],
834 "plugin_admin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 = has admin config, 0 = has no admin config"],
838 "name" => ["UNIQUE", "name"],
841 $database["attach"] = [
842 "comment" => "file attachments",
844 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "generated index"],
845 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
846 "hash" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "hash"],
847 "filename" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "filename of original"],
848 "filetype" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "mimetype"],
849 "filesize" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "size in bytes"],
850 "data" => ["type" => "longblob", "not null" => "1", "comment" => "file data"],
851 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation time"],
852 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "last edit time"],
853 "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>"],
854 "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"],
855 "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"],
856 "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"],
862 $database["auth_codes"] = [
863 "comment" => "OAuth usage",
865 "id" => ["type" => "varchar(40)", "not null" => "1", "primary" => "1", "comment" => ""],
866 "client_id" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => ["clients" => "client_id"], "comment" => ""],
867 "redirect_uri" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
868 "expires" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
869 "scope" => ["type" => "varchar(250)", "not null" => "1", "default" => "", "comment" => ""],
875 $database["cache"] = [
876 "comment" => "Stores temporary data",
878 "k" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "cache key"],
879 "v" => ["type" => "mediumtext", "comment" => "cached serialized value"],
880 "expires" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of cache expiration"],
881 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of cache insertion"],
885 "k_expires" => ["k", "expires"],
888 $database["challenge"] = [
891 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
892 "challenge" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
893 "dfrn-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
894 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
895 "type" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
896 "last_update" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
902 $database["clients"] = [
903 "comment" => "OAuth usage",
905 "client_id" => ["type" => "varchar(20)", "not null" => "1", "primary" => "1", "comment" => ""],
906 "pw" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => ""],
907 "redirect_uri" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
908 "name" => ["type" => "text", "comment" => ""],
909 "icon" => ["type" => "text", "comment" => ""],
910 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
913 "PRIMARY" => ["client_id"],
916 $database["config"] = [
917 "comment" => "main configuration storage",
919 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
920 "cat" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""],
921 "k" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""],
922 "v" => ["type" => "mediumtext", "comment" => ""],
926 "cat_k" => ["UNIQUE", "cat", "k"],
929 $database["contact"] = [
930 "comment" => "contact table",
932 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
933 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
934 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
935 "self" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 if the contact is the user him/her self"],
936 "remote_self" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
937 "rel" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "The kind of the relation between the user and the contact"],
938 "duplex" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
939 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Network protocol of the contact"],
940 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this contact is known by"],
941 "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Nick- and user name of the contact"],
942 "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
943 "about" => ["type" => "text", "comment" => ""],
944 "keywords" => ["type" => "text", "comment" => "public keywords (interests) of the contact"],
945 "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
946 "xmpp" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
947 "attag" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
948 "avatar" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
949 "photo" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo of the contact"],
950 "thumb" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo (thumb size)"],
951 "micro" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo (micro size)"],
952 "site-pubkey" => ["type" => "text", "comment" => ""],
953 "issued-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
954 "dfrn-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
955 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
956 "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
957 "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
958 "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
959 "pubkey" => ["type" => "text", "comment" => "RSA public key 4096 bit"],
960 "prvkey" => ["type" => "text", "comment" => "RSA private key 4096 bit"],
961 "batch" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
962 "request" => ["type" => "varchar(255)", "comment" => ""],
963 "notify" => ["type" => "varchar(255)", "comment" => ""],
964 "poll" => ["type" => "varchar(255)", "comment" => ""],
965 "confirm" => ["type" => "varchar(255)", "comment" => ""],
966 "poco" => ["type" => "varchar(255)", "comment" => ""],
967 "aes_allow" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
968 "ret-aes" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
969 "usehub" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
970 "subhub" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
971 "hub-verify" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
972 "last-update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of the last try to update the contact info"],
973 "success_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of the last successful contact update"],
974 "failure_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of the last failed update"],
975 "name-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
976 "uri-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
977 "avatar-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
978 "term-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
979 "last-item" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "date of the last post"],
980 "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
981 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
982 "readonly" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "posts of the contact are readonly"],
983 "writable" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
984 "forum" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "contact is a forum"],
985 "prv" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "contact is a private group"],
986 "contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
987 "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
988 "archive" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
989 "pending" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
990 "rating" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
991 "reason" => ["type" => "text", "comment" => ""],
992 "closeness" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "99", "comment" => ""],
993 "info" => ["type" => "mediumtext", "comment" => ""],
994 "profile-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
995 "bdyear" => ["type" => "varchar(4)", "not null" => "1", "default" => "", "comment" => ""],
996 "bd" => ["type" => "date", "not null" => "1", "default" => "0001-01-01", "comment" => ""],
997 "notify_new_posts" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
998 "fetch_further_information" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
999 "ffi_keyword_blacklist" => ["type" => "text", "comment" => ""],
1002 "PRIMARY" => ["id"],
1003 "uid_name" => ["uid", "name(190)"],
1004 "self_uid" => ["self", "uid"],
1005 "alias_uid" => ["alias(32)", "uid"],
1006 "pending_uid" => ["pending", "uid"],
1007 "blocked_uid" => ["blocked", "uid"],
1008 "uid_rel_network_poll" => ["uid", "rel", "network", "poll(64)", "archive"],
1009 "uid_network_batch" => ["uid", "network", "batch(64)"],
1010 "addr_uid" => ["addr(32)", "uid"],
1011 "nurl_uid" => ["nurl(32)", "uid"],
1012 "nick_uid" => ["nick(32)", "uid"],
1013 "dfrn-id" => ["dfrn-id(64)"],
1014 "issued-id" => ["issued-id(64)"],
1017 $database["conv"] = [
1018 "comment" => "private messages",
1020 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1021 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this conversation"],
1022 "recips" => ["type" => "text", "comment" => "sender_handle;recipient_handle"],
1023 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1024 "creator" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "handle of creator"],
1025 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation timestamp"],
1026 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "edited timestamp"],
1027 "subject" => ["type" => "text", "comment" => "subject of initial message"],
1030 "PRIMARY" => ["id"],
1034 $database["conversation"] = [
1035 "comment" => "Raw data and structure information for messages",
1037 "item-uri" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "URI of the item"],
1038 "reply-to-uri" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => "URI to which this item is a reply"],
1039 "conversation-uri" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => "GNU Social conversation URI"],
1040 "conversation-href" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => "GNU Social conversation link"],
1041 "protocol" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "The protocol of the item"],
1042 "source" => ["type" => "mediumtext", "comment" => "Original source"],
1043 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Receiving date"],
1046 "PRIMARY" => ["item-uri"],
1047 "conversation-uri" => ["conversation-uri"],
1048 "received" => ["received"],
1051 $database["event"] = [
1052 "comment" => "Events",
1054 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1055 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1056 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1057 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact_id (ID of the contact in contact table)"],
1058 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1059 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation time"],
1060 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "last edit time"],
1061 "start" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "event start time"],
1062 "finish" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "event end time"],
1063 "summary" => ["type" => "text", "comment" => "short description or title of the event"],
1064 "desc" => ["type" => "text", "comment" => "event description"],
1065 "location" => ["type" => "text", "comment" => "event location"],
1066 "type" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => "event or birthday"],
1067 "nofinish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if event does have no end this is 1"],
1068 "adjust" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => "adjust to timezone of the recipient (0 or 1)"],
1069 "ignore" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "0 or 1"],
1070 "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>'"],
1071 "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"],
1072 "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"],
1073 "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"],
1076 "PRIMARY" => ["id"],
1077 "uid_start" => ["uid", "start"],
1080 $database["fcontact"] = [
1081 "comment" => "Diaspora compatible contacts - used in the Diaspora implementation",
1083 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1084 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "unique id"],
1085 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1086 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1087 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1088 "request" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1089 "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1090 "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1091 "batch" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1092 "notify" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1093 "poll" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1094 "confirm" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1095 "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1096 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
1097 "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1098 "pubkey" => ["type" => "text", "comment" => ""],
1099 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1102 "PRIMARY" => ["id"],
1103 "addr" => ["addr(32)"],
1104 "url" => ["UNIQUE", "url(190)"],
1107 $database["fsuggest"] = [
1108 "comment" => "friend suggestion stuff",
1110 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1111 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1112 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1113 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1114 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1115 "request" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1116 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1117 "note" => ["type" => "text", "comment" => ""],
1118 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1121 "PRIMARY" => ["id"],
1124 $database["gcign"] = [
1125 "comment" => "contacts ignored by friend suggestions",
1127 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1128 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Local User id"],
1129 "gcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => "gcontact.id of ignored contact"],
1132 "PRIMARY" => ["id"],
1137 $database["gcontact"] = [
1138 "comment" => "global contacts",
1140 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1141 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this contact is known by"],
1142 "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Nick- and user name of the contact"],
1143 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Link to the contacts profile page"],
1144 "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1145 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Link to the profile photo"],
1146 "connect" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1147 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1148 "updated" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1149 "last_contact" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1150 "last_failure" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1151 "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1152 "about" => ["type" => "text", "comment" => ""],
1153 "keywords" => ["type" => "text", "comment" => "puplic keywords (interests)"],
1154 "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1155 "birthday" => ["type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01", "comment" => ""],
1156 "community" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 if contact is forum account"],
1157 "contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "-1", "comment" => ""],
1158 "hide" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 = should be hidden from search"],
1159 "nsfw" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 = contact posts nsfw content"],
1160 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "social network protocol"],
1161 "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1162 "notify" => ["type" => "varchar(255)", "comment" => ""],
1163 "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1164 "generation" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1165 "server_url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "baseurl of the contacts server"],
1168 "PRIMARY" => ["id"],
1169 "nurl" => ["UNIQUE", "nurl(190)"],
1170 "name" => ["name(64)"],
1171 "nick" => ["nick(32)"],
1172 "addr" => ["addr(64)"],
1173 "hide_network_updated" => ["hide", "network", "updated"],
1174 "updated" => ["updated"],
1177 $database["glink"] = [
1178 "comment" => "'friends of friends' linkages derived from poco",
1180 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1181 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1182 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1183 "gcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""],
1184 "zcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""],
1185 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1188 "PRIMARY" => ["id"],
1189 "cid_uid_gcid_zcid" => ["UNIQUE", "cid","uid","gcid","zcid"],
1193 $database["group"] = [
1194 "comment" => "privacy groups, group info",
1196 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1197 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1198 "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 indicates the member list is not private"],
1199 "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 indicates the group has been deleted"],
1200 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "human readable name of group"],
1203 "PRIMARY" => ["id"],
1207 $database["group_member"] = [
1208 "comment" => "privacy groups, member info",
1210 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1211 "gid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["group" => "id"], "comment" => "groups.id of the associated group"],
1212 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id of the member assigned to the associated group"],
1215 "PRIMARY" => ["id"],
1216 "contactid" => ["contact-id"],
1217 "gid_contactid" => ["UNIQUE", "gid", "contact-id"],
1220 $database["gserver"] = [
1221 "comment" => "Global servers",
1223 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1224 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1225 "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1226 "version" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1227 "site_name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1228 "info" => ["type" => "text", "comment" => ""],
1229 "register_policy" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
1230 "registered-users" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "Number of registered users"],
1231 "poco" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1232 "noscrape" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1233 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
1234 "platform" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1235 "relay-subscribe" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Has the server subscribed to the relay system"],
1236 "relay-scope" => ["type" => "varchar(10)", "not null" => "1", "default" => "", "comment" => "The scope of messages that the server wants to get"],
1237 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1238 "last_poco_query" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1239 "last_contact" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1240 "last_failure" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1243 "PRIMARY" => ["id"],
1244 "nurl" => ["UNIQUE", "nurl(190)"],
1247 $database["gserver-tag"] = [
1248 "comment" => "Tags that the server has subscribed",
1250 "gserver-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gserver" => "id"], "primary" => "1", "comment" => "The id of the gserver"],
1251 "tag" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "primary" => "1", "comment" => "Tag that the server has subscribed"],
1254 "PRIMARY" => ["gserver-id", "tag"],
1258 $database["hook"] = [
1259 "comment" => "addon hook registry",
1261 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1262 "hook" => ["type" => "varbinary(100)", "not null" => "1", "default" => "", "comment" => "name of hook"],
1263 "file" => ["type" => "varbinary(200)", "not null" => "1", "default" => "", "comment" => "relative filename of hook handler"],
1264 "function" => ["type" => "varbinary(200)", "not null" => "1", "default" => "", "comment" => "function name of hook handler"],
1265 "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"],
1268 "PRIMARY" => ["id"],
1269 "hook_file_function" => ["UNIQUE", "hook", "file", "function"],
1272 $database["intro"] = [
1275 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1276 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1277 "fid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["fcontact" => "id"], "comment" => ""],
1278 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1279 "knowyou" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1280 "duplex" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1281 "note" => ["type" => "text", "comment" => ""],
1282 "hash" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1283 "datetime" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1284 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
1285 "ignore" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1288 "PRIMARY" => ["id"],
1291 $database["item"] = [
1292 "comment" => "Structure for all posts",
1294 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => ["thread" => "iid"]],
1295 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this item"],
1296 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1297 "uri-hash" => ["type" => "varchar(80)", "not null" => "1", "default" => "", "comment" => "RIPEMD-128 hash from uri"],
1298 "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"],
1299 "parent-uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "uri of the parent to this item"],
1300 "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"],
1301 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Creation timestamp."],
1302 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last edit (default is created)"],
1303 "commented" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last comment/reply to this item"],
1304 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime"],
1305 "changed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date that something in the conversation changed, indicating clients should fetch the conversation again"],
1306 "gravity" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1307 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Network from where the item comes from"],
1308 "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"],
1309 "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"],
1310 "icid" => ["type" => "int unsigned", "relation" => ["item-content" => "id"], "comment" => "Id of the item-content table entry that contains the whole item content"],
1311 "iaid" => ["type" => "int unsigned", "relation" => ["item-activity" => "id"], "comment" => "Id of the item-activity table entry that contains the activity data"],
1312 "extid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1313 "post-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Post type (personal note, bookmark, ...)"],
1314 "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1315 "private" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "distribution is restricted"],
1316 "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1317 "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1318 "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been deleted"],
1319 // User specific fields. Eventually they will move to user-item
1320 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner id which owns this copy of the item"],
1321 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id"],
1322 "wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "This item was posted to the wall of uid"],
1323 "origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item originated at this site"],
1324 "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1325 "starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been favourited"],
1326 "unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => "item has not been seen"],
1327 "mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "The owner of this item was mentioned in it"],
1328 "forum_mode" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1329 "psid" => ["type" => "int unsigned", "relation" => ["permissionset" => "id"], "comment" => "ID of the permission set of this post"],
1330 // These fields will be replaced by the "psid" from above
1331 "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>'"],
1332 "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"],
1333 "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"],
1334 "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"],
1335 // It is to be decided whether these fields belong to the user or the structure
1336 "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"],
1337 "event-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["event" => "id"], "comment" => "Used to link to the event.id"],
1338 // Could possibly be replaced by the "attach" table?
1339 "attach" => ["type" => "mediumtext", "comment" => "JSON structure representing attachments to this item"],
1340 // Deprecated fields. Will be removed in upcoming versions
1341 "postopts" => ["type" => "text", "comment" => "Deprecated"],
1342 "inform" => ["type" => "mediumtext", "comment" => "Deprecated"],
1343 "type" => ["type" => "varchar(20)", "comment" => "Deprecated"],
1344 "bookmark" => ["type" => "boolean", "comment" => "Deprecated"],
1345 "file" => ["type" => "mediumtext", "comment" => "Deprecated"],
1346 "location" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1347 "coord" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1348 "tag" => ["type" => "mediumtext", "comment" => "Deprecated"],
1349 "plink" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1350 "title" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1351 "content-warning" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1352 "body" => ["type" => "mediumtext", "comment" => "Deprecated"],
1353 "app" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1354 "verb" => ["type" => "varchar(100)", "comment" => "Deprecated"],
1355 "object-type" => ["type" => "varchar(100)", "comment" => "Deprecated"],
1356 "object" => ["type" => "text", "comment" => "Deprecated"],
1357 "target-type" => ["type" => "varchar(100)", "comment" => "Deprecated"],
1358 "target" => ["type" => "text", "comment" => "Deprecated"],
1359 "author-name" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1360 "author-link" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1361 "author-avatar" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1362 "owner-name" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1363 "owner-link" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1364 "owner-avatar" => ["type" => "varchar(255)", "comment" => "Deprecated"],
1365 "rendered-hash" => ["type" => "varchar(32)", "comment" => "Deprecated"],
1366 "rendered-html" => ["type" => "mediumtext", "comment" => "Deprecated"],
1369 "PRIMARY" => ["id"],
1370 "guid" => ["guid(191)"],
1371 "uri" => ["uri(191)"],
1372 "parent" => ["parent"],
1373 "parent-uri" => ["parent-uri(191)"],
1374 "extid" => ["extid(191)"],
1375 "uid_id" => ["uid","id"],
1376 "uid_contactid_id" => ["uid","contact-id","id"],
1377 "uid_created" => ["uid","created"],
1378 "uid_commented" => ["uid","commented"],
1379 "uid_unseen_contactid" => ["uid","unseen","contact-id"],
1380 "uid_network_received" => ["uid","network","received"],
1381 "uid_network_commented" => ["uid","network","commented"],
1382 "uid_thrparent" => ["uid","thr-parent(190)"],
1383 "uid_parenturi" => ["uid","parent-uri(190)"],
1384 "uid_contactid_created" => ["uid","contact-id","created"],
1385 "authorid_created" => ["author-id","created"],
1386 "ownerid" => ["owner-id"],
1387 "uid_uri" => ["uid", "uri(190)"],
1388 "resource-id" => ["resource-id"],
1389 "deleted_changed" => ["deleted","changed"],
1390 "uid_wall_changed" => ["uid","wall","changed"],
1391 "uid_eventid" => ["uid","event-id"],
1397 $database["item-activity"] = [
1398 "comment" => "Activities for items",
1400 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => ["thread" => "iid"]],
1401 "uri" => ["type" => "varchar(255)", "comment" => ""],
1402 "uri-hash" => ["type" => "varchar(80)", "not null" => "1", "default" => "", "comment" => "RIPEMD-128 hash from uri"],
1403 "activity" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1406 "PRIMARY" => ["id"],
1407 "uri-hash" => ["UNIQUE", "uri-hash"],
1408 "uri" => ["uri(191)"],
1411 $database["item-content"] = [
1412 "comment" => "Content for all posts",
1414 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => ["thread" => "iid"]],
1415 "uri" => ["type" => "varchar(255)", "comment" => ""],
1416 "uri-plink-hash" => ["type" => "varchar(80)", "not null" => "1", "default" => "", "comment" => "RIPEMD-128 hash from uri"],
1417 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "item title"],
1418 "content-warning" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1419 "body" => ["type" => "mediumtext", "comment" => "item body content"],
1420 "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "text location where this item originated"],
1421 "coord" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "longitude/latitude pair representing location where this item originated"],
1422 "language" => ["type" => "text", "comment" => "Language information about this post"],
1423 "app" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "application which generated this item"],
1424 "rendered-hash" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1425 "rendered-html" => ["type" => "mediumtext", "comment" => "item.body converted to html"],
1426 "object-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams object type"],
1427 "object" => ["type" => "text", "comment" => "JSON encoded object structure unless it is an implied object (normal post)"],
1428 "target-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams target type if applicable (URI)"],
1429 "target" => ["type" => "text", "comment" => "JSON encoded target structure if used"],
1430 "plink" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "permalink or URL to a displayable copy of the message at its source"],
1431 "verb" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams verb"],
1434 "PRIMARY" => ["id"],
1435 "uri-plink-hash" => ["UNIQUE", "uri-plink-hash"],
1436 "uri" => ["uri(191)"],
1439 $database["item-delivery-data"] = [
1440 "comment" => "Delivery data for items",
1442 "iid" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "relation" => ["item" => "id"], "comment" => "Item id"],
1443 "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"],
1444 "inform" => ["type" => "mediumtext", "comment" => "Additional receivers of the linked item"],
1447 "PRIMARY" => ["iid"],
1450 $database["locks"] = [
1453 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1454 "name" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => ""],
1455 "locked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1456 "pid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "Process ID"],
1457 "expires" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of cache expiration"],
1460 "PRIMARY" => ["id"],
1461 "name_expires" => ["name", "expires"]
1464 $database["mail"] = [
1465 "comment" => "private messages",
1467 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1468 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1469 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this private message"],
1470 "from-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "name of the sender"],
1471 "from-photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "contact photo link of the sender"],
1472 "from-url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "profile linke of the sender"],
1473 "contact-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => ["contact" => "id"], "comment" => "contact.id"],
1474 "convid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["conv" => "id"], "comment" => "conv.id"],
1475 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1476 "body" => ["type" => "mediumtext", "comment" => ""],
1477 "seen" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if message visited it is 1"],
1478 "reply" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1479 "replied" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1480 "unknown" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if sender not in the contact table this is 1"],
1481 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1482 "parent-uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1483 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation time of the private message"],
1486 "PRIMARY" => ["id"],
1487 "uid_seen" => ["uid", "seen"],
1488 "convid" => ["convid"],
1489 "uri" => ["uri(64)"],
1490 "parent-uri" => ["parent-uri(64)"],
1491 "contactid" => ["contact-id(32)"],
1494 $database["mailacct"] = [
1495 "comment" => "Mail account data for fetching mails",
1497 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1498 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1499 "server" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1500 "port" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1501 "ssltype" => ["type" => "varchar(16)", "not null" => "1", "default" => "", "comment" => ""],
1502 "mailbox" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1503 "user" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1504 "pass" => ["type" => "text", "comment" => ""],
1505 "reply_to" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1506 "action" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1507 "movetofolder" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1508 "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1509 "last_check" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1512 "PRIMARY" => ["id"],
1515 $database["manage"] = [
1516 "comment" => "table of accounts that can manage each other",
1518 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1519 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1520 "mid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1523 "PRIMARY" => ["id"],
1524 "uid_mid" => ["UNIQUE", "uid","mid"],
1527 $database["notify"] = [
1528 "comment" => "notifications",
1530 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1531 "hash" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
1532 "type" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1533 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1534 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1535 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1536 "date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1537 "msg" => ["type" => "mediumtext", "comment" => ""],
1538 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1539 "link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1540 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => "item.id"],
1541 "parent" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1542 "seen" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1543 "verb" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => ""],
1544 "otype" => ["type" => "varchar(10)", "not null" => "1", "default" => "", "comment" => ""],
1545 "name_cache" => ["type" => "tinytext", "comment" => "Cached bbcode parsing of name"],
1546 "msg_cache" => ["type" => "mediumtext", "comment" => "Cached bbcode parsing of msg"]
1549 "PRIMARY" => ["id"],
1550 "hash_uid" => ["hash", "uid"],
1551 "seen_uid_date" => ["seen", "uid", "date"],
1552 "uid_date" => ["uid", "date"],
1553 "uid_type_link" => ["uid", "type", "link(190)"],
1556 $database["notify-threads"] = [
1559 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1560 "notify-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["notify" => "id"], "comment" => ""],
1561 "master-parent-item" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1562 "parent-item" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1563 "receiver-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1566 "PRIMARY" => ["id"],
1569 $database["oembed"] = [
1570 "comment" => "cache for OEmbed queries",
1572 "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "page url"],
1573 "maxwidth" => ["type" => "mediumint unsigned", "not null" => "1", "primary" => "1", "comment" => "Maximum width passed to Oembed"],
1574 "content" => ["type" => "mediumtext", "comment" => "OEmbed data of the page"],
1575 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of creation"],
1578 "PRIMARY" => ["url", "maxwidth"],
1579 "created" => ["created"],
1582 $database["openwebauth-token"] = [
1583 "comment" => "Store OpenWebAuth token to verify contacts",
1585 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1586 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1587 "type" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => "Verify type"],
1588 "token" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A generated token"],
1589 "meta" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1590 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of creation"],
1593 "PRIMARY" => ["id"],
1596 $database["parsed_url"] = [
1597 "comment" => "cache for 'parse_url' queries",
1599 "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "page url"],
1600 "guessing" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => "is the 'guessing' mode active?"],
1601 "oembed" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => "is the data the result of oembed?"],
1602 "content" => ["type" => "mediumtext", "comment" => "page data"],
1603 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of creation"],
1606 "PRIMARY" => ["url", "guessing", "oembed"],
1607 "created" => ["created"],
1610 $database["participation"] = [
1611 "comment" => "Storage for participation messages from Diaspora",
1613 "iid" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "relation" => ["item" => "id"], "comment" => ""],
1614 "server" => ["type" => "varchar(60)", "not null" => "1", "primary" => "1", "comment" => ""],
1615 "cid" => ["type" => "int unsigned", "not null" => "1", "relation" => ["contact" => "id"], "comment" => ""],
1616 "fid" => ["type" => "int unsigned", "not null" => "1", "relation" => ["fcontact" => "id"], "comment" => ""],
1619 "PRIMARY" => ["iid", "server"]
1622 $database["pconfig"] = [
1623 "comment" => "personal (per user) configuration storage",
1625 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1626 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1627 "cat" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""],
1628 "k" => ["type" => "varbinary(100)", "not null" => "1", "default" => "", "comment" => ""],
1629 "v" => ["type" => "mediumtext", "comment" => ""],
1632 "PRIMARY" => ["id"],
1633 "uid_cat_k" => ["UNIQUE", "uid", "cat", "k"],
1636 $database["permissionset"] = [
1639 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1640 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner id of this permission set"],
1641 "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>'"],
1642 "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"],
1643 "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"],
1644 "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"],
1647 "PRIMARY" => ["id"],
1648 "uid_allow_cid_allow_gid_deny_cid_deny_gid" => ["allow_cid(50)", "allow_gid(30)", "deny_cid(50)", "deny_gid(30)"],
1651 $database["photo"] = [
1652 "comment" => "photo storage",
1654 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1655 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1656 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id"],
1657 "guid" => ["type" => "char(16)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this photo"],
1658 "resource-id" => ["type" => "char(32)", "not null" => "1", "default" => "", "comment" => ""],
1659 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation date"],
1660 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "last edited date"],
1661 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1662 "desc" => ["type" => "text", "comment" => ""],
1663 "album" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "The name of the album to which the photo belongs"],
1664 "filename" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1665 "type" => ["type" => "varchar(30)", "not null" => "1", "default" => "image/jpeg"],
1666 "height" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1667 "width" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1668 "datasize" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1669 "data" => ["type" => "mediumblob", "not null" => "1", "comment" => ""],
1670 "scale" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1671 "profile" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1672 "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>'"],
1673 "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"],
1674 "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"],
1675 "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"],
1678 "PRIMARY" => ["id"],
1679 "contactid" => ["contact-id"],
1680 "uid_contactid" => ["uid", "contact-id"],
1681 "uid_profile" => ["uid", "profile"],
1682 "uid_album_scale_created" => ["uid", "album(32)", "scale", "created"],
1683 "uid_album_resource-id_created" => ["uid", "album(32)", "resource-id", "created"],
1684 "resource-id" => ["resource-id"],
1687 $database["poll"] = [
1688 "comment" => "Currently unused table for storing poll results",
1690 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1691 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1692 "q0" => ["type" => "text", "comment" => ""],
1693 "q1" => ["type" => "text", "comment" => ""],
1694 "q2" => ["type" => "text", "comment" => ""],
1695 "q3" => ["type" => "text", "comment" => ""],
1696 "q4" => ["type" => "text", "comment" => ""],
1697 "q5" => ["type" => "text", "comment" => ""],
1698 "q6" => ["type" => "text", "comment" => ""],
1699 "q7" => ["type" => "text", "comment" => ""],
1700 "q8" => ["type" => "text", "comment" => ""],
1701 "q9" => ["type" => "text", "comment" => ""],
1704 "PRIMARY" => ["id"],
1708 $database["poll_result"] = [
1709 "comment" => "data for polls - currently unused",
1711 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1712 "poll_id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["poll" => "id"]],
1713 "choice" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1716 "PRIMARY" => ["id"],
1717 "poll_id" => ["poll_id"],
1720 $database["process"] = [
1721 "comment" => "Currently running system processes",
1723 "pid" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "comment" => ""],
1724 "command" => ["type" => "varbinary(32)", "not null" => "1", "default" => "", "comment" => ""],
1725 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1728 "PRIMARY" => ["pid"],
1729 "command" => ["command"],
1732 $database["profile"] = [
1733 "comment" => "user profiles data",
1735 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1736 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"],
1737 "profile-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name of the profile"],
1738 "is-default" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Mark this profile as default profile"],
1739 "hide-friends" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Hide friend list from viewers of this profile"],
1740 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1741 "pdesc" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Title or description"],
1742 "dob" => ["type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00", "comment" => "Day of birth"],
1743 "address" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1744 "locality" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1745 "region" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1746 "postal-code" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1747 "country-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1748 "hometown" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1749 "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1750 "marital" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1751 "with" => ["type" => "text", "comment" => ""],
1752 "howlong" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1753 "sexual" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1754 "politic" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1755 "religion" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1756 "pub_keywords" => ["type" => "text", "comment" => ""],
1757 "prv_keywords" => ["type" => "text", "comment" => ""],
1758 "likes" => ["type" => "text", "comment" => ""],
1759 "dislikes" => ["type" => "text", "comment" => ""],
1760 "about" => ["type" => "text", "comment" => ""],
1761 "summary" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1762 "music" => ["type" => "text", "comment" => ""],
1763 "book" => ["type" => "text", "comment" => ""],
1764 "tv" => ["type" => "text", "comment" => ""],
1765 "film" => ["type" => "text", "comment" => ""],
1766 "interest" => ["type" => "text", "comment" => ""],
1767 "romance" => ["type" => "text", "comment" => ""],
1768 "work" => ["type" => "text", "comment" => ""],
1769 "education" => ["type" => "text", "comment" => ""],
1770 "contact" => ["type" => "text", "comment" => ""],
1771 "homepage" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1772 "xmpp" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1773 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1774 "thumb" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1775 "publish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "publish default profile in local directory"],
1776 "net-publish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "publish profile in global directory"],
1779 "PRIMARY" => ["id"],
1780 "uid_is-default" => ["uid", "is-default"],
1783 $database["profile_check"] = [
1784 "comment" => "DFRN remote auth use",
1786 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1787 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1788 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id"],
1789 "dfrn_id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1790 "sec" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1791 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1794 "PRIMARY" => ["id"],
1797 $database["push_subscriber"] = [
1798 "comment" => "Used for OStatus: Contains feed subscribers",
1800 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1801 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1802 "callback_url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1803 "topic" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1804 "nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1805 "push" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Retrial counter"],
1806 "last_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last successful trial"],
1807 "next_try" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Next retrial date"],
1808 "renewed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last subscription renewal"],
1809 "secret" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1812 "PRIMARY" => ["id"],
1813 "next_try" => ["next_try"],
1816 $database["queue"] = [
1817 "comment" => "Queue for messages that couldn't be delivered",
1819 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1820 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Message receiver"],
1821 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Receiver's network"],
1822 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Unique GUID of the message"],
1823 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date, when the message was created"],
1824 "last" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last trial"],
1825 "next" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Next retrial date"],
1826 "retrial" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Retrial counter"],
1827 "content" => ["type" => "mediumtext", "comment" => ""],
1828 "batch" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1831 "PRIMARY" => ["id"],
1836 $database["register"] = [
1837 "comment" => "registrations requiring admin approval",
1839 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1840 "hash" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1841 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1842 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1843 "password" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1844 "language" => ["type" => "varchar(16)", "not null" => "1", "default" => "", "comment" => ""],
1845 "note" => ["type" => "text", "comment" => ""],
1848 "PRIMARY" => ["id"],
1851 $database["search"] = [
1854 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1855 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1856 "term" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1859 "PRIMARY" => ["id"],
1863 $database["session"] = [
1864 "comment" => "web session storage",
1866 "id" => ["type" => "bigint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1867 "sid" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""],
1868 "data" => ["type" => "text", "comment" => ""],
1869 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1872 "PRIMARY" => ["id"],
1873 "sid" => ["sid(64)"],
1874 "expire" => ["expire"],
1877 $database["sign"] = [
1878 "comment" => "Diaspora signatures",
1880 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1881 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => "item.id"],
1882 "signed_text" => ["type" => "mediumtext", "comment" => ""],
1883 "signature" => ["type" => "text", "comment" => ""],
1884 "signer" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1887 "PRIMARY" => ["id"],
1888 "iid" => ["UNIQUE", "iid"],
1891 $database["term"] = [
1892 "comment" => "item taxonomy (categories, tags, etc.) table",
1894 "tid" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1895 "oid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1896 "otype" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1897 "type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1898 "term" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1899 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1900 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1901 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1902 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1903 "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1904 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1907 "PRIMARY" => ["tid"],
1908 "oid_otype_type_term" => ["oid","otype","type","term(32)"],
1909 "uid_otype_type_term_global_created" => ["uid","otype","type","term(32)","global","created"],
1910 "uid_otype_type_url" => ["uid","otype","type","url(64)"],
1911 "guid" => ["guid(64)"],
1914 $database["thread"] = [
1915 "comment" => "Thread related data",
1917 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["item" => "id"], "comment" => "sequential ID"],
1918 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1919 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1920 "owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Item owner"],
1921 "author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Item author"],
1922 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1923 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1924 "commented" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1925 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1926 "changed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1927 "wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1928 "private" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1929 "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1930 "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1931 "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1932 "starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1933 "ignored" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1934 "post-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Post type (personal note, bookmark, ...)"],
1935 "unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
1936 "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1937 "origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1938 "forum_mode" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1939 "mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1940 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
1941 "bookmark" => ["type" => "boolean", "comment" => ""],
1944 "PRIMARY" => ["iid"],
1945 "uid_network_commented" => ["uid","network","commented"],
1946 "uid_network_created" => ["uid","network","created"],
1947 "uid_contactid_commented" => ["uid","contact-id","commented"],
1948 "uid_contactid_created" => ["uid","contact-id","created"],
1949 "contactid" => ["contact-id"],
1950 "ownerid" => ["owner-id"],
1951 "authorid" => ["author-id"],
1952 "uid_created" => ["uid","created"],
1953 "uid_commented" => ["uid","commented"],
1954 "uid_wall_created" => ["uid","wall","created"],
1955 "private_wall_origin_commented" => ["private","wall","origin","commented"],
1958 $database["tokens"] = [
1959 "comment" => "OAuth usage",
1961 "id" => ["type" => "varchar(40)", "not null" => "1", "primary" => "1", "comment" => ""],
1962 "secret" => ["type" => "text", "comment" => ""],
1963 "client_id" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => ["clients" => "client_id"]],
1964 "expires" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
1965 "scope" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
1966 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1969 "PRIMARY" => ["id"],
1972 $database["user"] = [
1973 "comment" => "The local users",
1975 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
1976 "parent-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "The parent user that has full control about this user"],
1977 "guid" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this user"],
1978 "username" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this user is known by"],
1979 "password" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "encrypted password"],
1980 "legacy_password" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Is the password hash double-hashed?"],
1981 "nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "nick- and user name"],
1982 "email" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "the users email address"],
1983 "openid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1984 "timezone" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => "PHP-legal timezone"],
1985 "language" => ["type" => "varchar(32)", "not null" => "1", "default" => "en", "comment" => "default language"],
1986 "register_date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "timestamp of registration"],
1987 "login_date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "timestamp of last login"],
1988 "default-location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Default for item.location"],
1989 "allow_location" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 allows to display the location"],
1990 "theme" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "user theme preference"],
1991 "pubkey" => ["type" => "text", "comment" => "RSA public key 4096 bit"],
1992 "prvkey" => ["type" => "text", "comment" => "RSA private key 4096 bit"],
1993 "spubkey" => ["type" => "text", "comment" => ""],
1994 "sprvkey" => ["type" => "text", "comment" => ""],
1995 "verified" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "user is verified through email"],
1996 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 for user is blocked"],
1997 "blockwall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Prohibit contacts to post to the profile page of the user"],
1998 "hidewall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Hide profile details from unkown viewers"],
1999 "blocktags" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Prohibit contacts to tag the post of this user"],
2000 "unkmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Permit unknown people to send private mails to this user"],
2001 "cntunkmail" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""],
2002 "notify-flags" => ["type" => "smallint unsigned", "not null" => "1", "default" => "65535", "comment" => "email notification options"],
2003 "page-flags" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "page/profile type"],
2004 "account-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
2005 "prvnets" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
2006 "pwdreset" => ["type" => "varchar(255)", "comment" => "Password reset request token"],
2007 "pwdreset_time" => ["type" => "datetime", "comment" => "Timestamp of the last password reset request"],
2008 "maxreq" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""],
2009 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
2010 "account_removed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if 1 the account is removed"],
2011 "account_expired" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
2012 "account_expires_on" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "timestamp when account expires and will be deleted"],
2013 "expire_notification_sent" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "timestamp of last warning of account expiration"],
2014 "def_gid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
2015 "allow_cid" => ["type" => "mediumtext", "comment" => "default permission for this user"],
2016 "allow_gid" => ["type" => "mediumtext", "comment" => "default permission for this user"],
2017 "deny_cid" => ["type" => "mediumtext", "comment" => "default permission for this user"],
2018 "deny_gid" => ["type" => "mediumtext", "comment" => "default permission for this user"],
2019 "openidserver" => ["type" => "text", "comment" => ""],
2022 "PRIMARY" => ["uid"],
2023 "nickname" => ["nickname(32)"],
2026 $database["userd"] = [
2027 "comment" => "Deleted usernames",
2029 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
2030 "username" => ["type" => "varchar(255)", "not null" => "1", "comment" => ""],
2033 "PRIMARY" => ["id"],
2034 "username" => ["username(32)"],
2037 $database["user-item"] = [
2038 "comment" => "User specific item data",
2040 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["item" => "id"], "comment" => "Item id"],
2041 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["user" => "uid"], "comment" => "User id"],
2042 "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Marker to hide an item from the user"],
2045 "PRIMARY" => ["uid", "iid"],
2048 $database["worker-ipc"] = [
2049 "comment" => "Inter process communication between the frontend and the worker",
2051 "key" => ["type" => "int", "not null" => "1", "primary" => "1", "comment" => ""],
2052 "jobs" => ["type" => "boolean", "comment" => "Flag for outstanding jobs"],
2055 "PRIMARY" => ["key"],
2057 "engine" => "MEMORY",
2060 $database["workerqueue"] = [
2061 "comment" => "Background tasks queue entries",
2063 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "Auto incremented worker task id"],
2064 "parameter" => ["type" => "mediumblob", "comment" => "Task command"],
2065 "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Task priority"],
2066 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Creation date"],
2067 "pid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "Process id of the worker"],
2068 "executed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Execution date"],
2069 "done" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Marked 1 when the task was done - will be deleted later"],
2072 "PRIMARY" => ["id"],
2074 "parameter" => ["parameter(64)"],
2075 "priority_created" => ["priority", "created"],
2076 "done_executed" => ["done", "executed"],
2080 Addon::callHooks('dbstructure_definition', $database);