3 * @file src/Database/DBStructure.php
5 namespace Friendica\Database;
7 use Friendica\Core\Config;
8 use Friendica\Core\L10n;
9 use Friendica\Database\DBM;
12 require_once 'boot.php';
13 require_once 'include/dba.php';
14 require_once 'include/enotify.php';
15 require_once 'include/text.php';
18 * @brief This class contain functions for the database management
20 * This class contains functions that doesn't need to know if pdo, mysqli or whatever is used.
25 * Converts all tables from MyISAM to InnoDB
27 public static function convertToInnoDB() {
28 $r = q("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `engine` = 'MyISAM' AND `table_schema` = '%s'",
29 dbesc(dba::database_name()));
31 if (!DBM::is_result($r)) {
32 echo L10n::t('There are no tables on MyISAM.')."\n";
36 foreach ($r AS $table) {
37 $sql = sprintf("ALTER TABLE `%s` engine=InnoDB;", dbesc($table['TABLE_NAME']));
40 $result = dba::e($sql);
41 if (!DBM::is_result($result)) {
42 self::printUpdateError($sql);
48 * send the email and do what is needed to do on update fails
50 * @param update_id (int) number of failed update
51 * @param error_message (str) error message
53 public static function updateFail($update_id, $error_message) {
56 //send the administrators an e-mail
57 $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
58 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
63 if (!DBM::is_result($adminlist)) {
64 logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_NORMAL);
70 // every admin could had different language
71 foreach ($adminlist as $admin) {
72 $lang = (($admin['language'])?$admin['language']:'en');
73 L10n::pushLang($lang);
75 $preamble = deindent(L10n::t("
76 The friendica developers released update %s recently,
77 but when I tried to install it, something went terribly wrong.
78 This needs to be fixed soon and I can't do it alone. Please contact a
79 friendica developer if you can not help me on your own. My database might be invalid."));
80 $body = L10n::t("The error message is\n[pre]%s[/pre]");
81 $preamble = sprintf($preamble, $update_id);
82 $body = sprintf($body, $error_message);
85 'type' => SYSTEM_EMAIL,
86 'to_email' => $admin['email'],
87 'preamble' => $preamble,
94 logger("CRITICAL: Database structure update failed: ".$error_message);
98 private static function tableStructure($table) {
99 $structures = q("DESCRIBE `%s`", $table);
101 $full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table);
103 $indexes = q("SHOW INDEX FROM `%s`", $table);
105 $table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table);
107 if (DBM::is_result($table_status)) {
108 $table_status = $table_status[0];
116 if (DBM::is_result($indexes)) {
117 foreach ($indexes AS $index) {
118 if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
119 $indexdata[$index["Key_name"]] = ['UNIQUE'];
122 $column = $index["Column_name"];
124 if ($index["Sub_part"] != "") {
125 $column .= "(".$index["Sub_part"].")";
128 $indexdata[$index["Key_name"]][] = $column;
131 if (DBM::is_result($structures)) {
132 foreach ($structures AS $field) {
133 // Replace the default size values so that we don't have to define them
134 $search = ['tinyint(1)', 'tinyint(3) unsigned', 'tinyint(4)', 'smallint(5) unsigned', 'smallint(6)', 'mediumint(8) unsigned', 'mediumint(9)', 'bigint(20)', 'int(10) unsigned', 'int(11)'];
135 $replace = ['boolean', 'tinyint unsigned', 'tinyint', 'smallint unsigned', 'smallint', 'mediumint unsigned', 'mediumint', 'bigint', 'int unsigned', 'int'];
136 $field["Type"] = str_replace($search, $replace, $field["Type"]);
138 $fielddata[$field["Field"]]["type"] = $field["Type"];
139 if ($field["Null"] == "NO") {
140 $fielddata[$field["Field"]]["not null"] = true;
143 if (isset($field["Default"])) {
144 $fielddata[$field["Field"]]["default"] = $field["Default"];
147 if ($field["Extra"] != "") {
148 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
151 if ($field["Key"] == "PRI") {
152 $fielddata[$field["Field"]]["primary"] = true;
156 if (DBM::is_result($full_columns)) {
157 foreach ($full_columns AS $column) {
158 $fielddata[$column["Field"]]["Collation"] = $column["Collation"];
159 $fielddata[$column["Field"]]["comment"] = $column["Comment"];
163 return ["fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status];
166 public static function printStructure() {
167 $database = self::definition();
169 echo "-- ------------------------------------------\n";
170 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
171 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
172 echo "-- ------------------------------------------\n\n\n";
173 foreach ($database AS $name => $structure) {
175 echo "-- TABLE $name\n";
177 self::createTable($name, $structure['fields'], true, false, $structure["indexes"]);
184 * @brief Print out database error messages
186 * @param string $message Message to be added to the error message
188 * @return string Error message
190 private static function printUpdateError($message) {
191 echo L10n::t("\nError %d occurred during database update:\n%s\n",
192 dba::errorNo(), dba::errorMessage());
194 return L10n::t('Errors encountered performing database changes: ').$message.EOL;
198 * Updates DB structure and returns eventual errors messages
200 * @param bool $verbose
201 * @param bool $action Whether to actually apply the update
202 * @param bool $install Is this the initial update during the installation?
203 * @param array $tables An array of the database tables
204 * @param array $definition An array of the definition tables
205 * @return string Empty string if the update is successful, error messages otherwise
207 public static function update($verbose, $action, $install = false, array $tables = null, array $definition = null) {
208 if ($action && !$install) {
209 Config::set('system', 'maintenance', 1);
210 Config::set('system', 'maintenance_reason', L10n::t('%s: Database update', DBM::date().' '.date('e')));
215 logger('updating structure', LOGGER_DEBUG);
217 // Get the current structure
220 if (is_null($tables)) {
221 $tables = q("SHOW TABLES");
224 if (DBM::is_result($tables)) {
225 foreach ($tables AS $table) {
226 $table = current($table);
228 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
229 $database[$table] = self::tableStructure($table);
233 // Get the definition
234 if (is_null($definition)) {
235 $definition = self::definition();
238 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
239 if ((version_compare(dba::server_info(), '5.7.4') >= 0) &&
240 !(strpos(dba::server_info(), 'MariaDB') !== false)) {
247 foreach ($definition AS $name => $structure) {
248 $is_new_table = false;
253 if (!isset($database[$name])) {
254 $r = self::createTable($name, $structure["fields"], $verbose, $action, $structure['indexes']);
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 = implode(",", $field_definition);
326 $new_field_definition = 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"]["Collation"])) {
382 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
383 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
386 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
397 // Now have a look at the field collations
398 // Compare the field structure field by field
399 foreach ($structure["fields"] AS $fieldname => $parameters) {
400 // Compare the field definition
401 $field_definition = $database[$name]["fields"][$fieldname];
403 // Define the default collation if not given
404 if (!isset($parameters['Collation']) && !is_null($field_definition['Collation'])) {
405 $parameters['Collation'] = 'utf8mb4_general_ci';
407 $parameters['Collation'] = null;
410 if ($field_definition['Collation'] != $parameters['Collation']) {
411 $sql2 = self::modifyTableField($fieldname, $parameters);
412 if (($sql3 == "") || (substr($sql3, -2, 2) == "; ")) {
413 $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
422 if (substr($sql3, -2, 2) != "; ") {
427 if ($is_unique && $ignore == '') {
428 foreach ($database[$name]["fields"] AS $fieldname => $parameters) {
429 $field_list .= 'ANY_VALUE(`' . $fieldname . '`),';
431 $field_list = rtrim($field_list, ',');
435 // Ensure index conversion to unique removes duplicates
436 if ($is_unique && ($temp_name != $name)) {
438 echo "SET session old_alter_table=1;\n";
440 echo "DROP TABLE IF EXISTS `".$temp_name."`;\n";
441 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
447 if ($is_unique && ($temp_name != $name)) {
449 echo "SET session old_alter_table=0;\n";
451 echo "INSERT INTO `".$temp_name."` SELECT ".dba::any_value_fallback($field_list)." FROM `".$name."`".$group_by.";\n";
452 echo "DROP TABLE `".$name."`;\n";
453 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
460 Config::set('system', 'maintenance_reason', L10n::t('%s: updating %s table.', DBM::date().' '.date('e'), $name));
463 // Ensure index conversion to unique removes duplicates
464 if ($is_unique && ($temp_name != $name)) {
466 dba::e("SET session old_alter_table=1;");
468 $r = dba::e("DROP TABLE IF EXISTS `".$temp_name."`;");
469 if (!DBM::is_result($r)) {
470 $errors .= self::printUpdateError($sql3);
474 $r = dba::e("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
475 if (!DBM::is_result($r)) {
476 $errors .= self::printUpdateError($sql3);
483 if (!DBM::is_result($r)) {
484 $errors .= self::printUpdateError($sql3);
486 if ($is_unique && ($temp_name != $name)) {
488 dba::e("SET session old_alter_table=0;");
490 $r = dba::e("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
491 if (!DBM::is_result($r)) {
492 $errors .= self::printUpdateError($sql3);
495 $r = dba::e("DROP TABLE `".$name."`;");
496 if (!DBM::is_result($r)) {
497 $errors .= self::printUpdateError($sql3);
500 $r = dba::e("RENAME TABLE `".$temp_name."` TO `".$name."`;");
501 if (!DBM::is_result($r)) {
502 $errors .= self::printUpdateError($sql3);
511 if ($action && !$install) {
512 Config::set('system', 'maintenance', 0);
513 Config::set('system', 'maintenance_reason', '');
516 Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
518 Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
525 private static function FieldCommand($parameters, $create = true) {
526 $fieldstruct = $parameters["type"];
528 if (!is_null($parameters["Collation"])) {
529 $fieldstruct .= " COLLATE ".$parameters["Collation"];
532 if ($parameters["not null"]) {
533 $fieldstruct .= " NOT NULL";
536 if (isset($parameters["default"])) {
537 if (strpos(strtolower($parameters["type"]),"int")!==false) {
538 $fieldstruct .= " DEFAULT ".$parameters["default"];
540 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
543 if ($parameters["extra"] != "") {
544 $fieldstruct .= " ".$parameters["extra"];
547 if (!is_null($parameters["comment"])) {
548 $fieldstruct .= " COMMENT '".dbesc($parameters["comment"])."'";
551 /*if (($parameters["primary"] != "") && $create)
552 $fieldstruct .= " PRIMARY KEY";*/
554 return($fieldstruct);
557 private static function createTable($name, $fields, $verbose, $action, $indexes=null) {
562 foreach ($fields AS $fieldname => $field) {
563 $sql_rows[] = "`".dbesc($fieldname)."` ".self::FieldCommand($field);
564 if (x($field,'primary') && $field['primary']!='') {
565 $primary_keys[] = $fieldname;
569 if (!is_null($indexes)) {
570 foreach ($indexes AS $indexname => $fieldnames) {
571 $sql_index = self::createIndex($indexname, $fieldnames, "");
572 if (!is_null($sql_index)) {
573 $sql_rows[] = $sql_index;
578 $sql = implode(",\n\t", $sql_rows);
580 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
592 private static function addTableField($fieldname, $parameters) {
593 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), self::FieldCommand($parameters));
597 private static function modifyTableField($fieldname, $parameters) {
598 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), self::FieldCommand($parameters, false));
602 private static function dropIndex($indexname) {
603 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
607 private static function createIndex($indexname, $fieldnames, $method = "ADD") {
608 $method = strtoupper(trim($method));
609 if ($method!="" && $method!="ADD") {
610 throw new \Exception("Invalid parameter 'method' in self::createIndex(): '$method'");
613 if ($fieldnames[0] == "UNIQUE") {
614 array_shift($fieldnames);
615 $method .= ' UNIQUE';
619 foreach ($fieldnames AS $fieldname) {
624 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
625 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
627 $names .= "`".dbesc($fieldname)."`";
631 if ($indexname == "PRIMARY") {
632 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
636 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
640 private static function groupBy($indexname, $fieldnames) {
641 if ($fieldnames[0] != "UNIQUE") {
645 array_shift($fieldnames);
648 foreach ($fieldnames AS $fieldname) {
653 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
654 $names .= "`".dbesc($matches[1])."`";
656 $names .= "`".dbesc($fieldname)."`";
660 $sql = sprintf(" GROUP BY %s", $names);
664 public static function definition() {
667 $database["addon"] = [
668 "comment" => "registered addons",
670 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
671 "name" => ["type" => "varchar(50)", "not null" => "1", "default" => "", "comment" => ""],
672 "version" => ["type" => "varchar(50)", "not null" => "1", "default" => "", "comment" => ""],
673 "installed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
674 "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
675 "timestamp" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
676 "plugin_admin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
680 "name" => ["UNIQUE", "name"],
683 $database["attach"] = [
684 "comment" => "file attachments",
686 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
687 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
688 "hash" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
689 "filename" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
690 "filetype" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
691 "filesize" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
692 "data" => ["type" => "longblob", "not null" => "1", "comment" => ""],
693 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
694 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
695 "allow_cid" => ["type" => "mediumtext", "comment" => ""],
696 "allow_gid" => ["type" => "mediumtext", "comment" => ""],
697 "deny_cid" => ["type" => "mediumtext", "comment" => ""],
698 "deny_gid" => ["type" => "mediumtext", "comment" => ""],
704 $database["auth_codes"] = [
705 "comment" => "OAuth usage",
707 "id" => ["type" => "varchar(40)", "not null" => "1", "primary" => "1", "comment" => ""],
708 "client_id" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => ["clients" => "client_id"], "comment" => ""],
709 "redirect_uri" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
710 "expires" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
711 "scope" => ["type" => "varchar(250)", "not null" => "1", "default" => "", "comment" => ""],
717 $database["cache"] = [
718 "comment" => "Stores temporary data",
720 "k" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "cache key"],
721 "v" => ["type" => "mediumtext", "comment" => "cached serialized value"],
722 "expires" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of cache expiration"],
723 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of cache insertion"],
727 "k_expires" => ["k", "expires"],
730 $database["challenge"] = [
733 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
734 "challenge" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
735 "dfrn-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
736 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
737 "type" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
738 "last_update" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
744 $database["clients"] = [
745 "comment" => "OAuth usage",
747 "client_id" => ["type" => "varchar(20)", "not null" => "1", "primary" => "1", "comment" => ""],
748 "pw" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => ""],
749 "redirect_uri" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
750 "name" => ["type" => "text", "comment" => ""],
751 "icon" => ["type" => "text", "comment" => ""],
752 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
755 "PRIMARY" => ["client_id"],
758 $database["config"] = [
759 "comment" => "main configuration storage",
761 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
762 "cat" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""],
763 "k" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""],
764 "v" => ["type" => "mediumtext", "comment" => ""],
768 "cat_k" => ["UNIQUE", "cat", "k"],
771 $database["contact"] = [
772 "comment" => "contact table",
774 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
775 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
776 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
777 "self" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
778 "remote_self" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
779 "rel" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
780 "duplex" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
781 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
782 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
783 "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
784 "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
785 "about" => ["type" => "text", "comment" => ""],
786 "keywords" => ["type" => "text", "comment" => ""],
787 "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
788 "xmpp" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
789 "attag" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
790 "avatar" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
791 "photo" => ["type" => "varchar(255)", "default" => "", "comment" => ""],
792 "thumb" => ["type" => "varchar(255)", "default" => "", "comment" => ""],
793 "micro" => ["type" => "varchar(255)", "default" => "", "comment" => ""],
794 "site-pubkey" => ["type" => "text", "comment" => ""],
795 "issued-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
796 "dfrn-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
797 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
798 "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
799 "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
800 "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
801 "pubkey" => ["type" => "text", "comment" => ""],
802 "prvkey" => ["type" => "text", "comment" => ""],
803 "batch" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
804 "request" => ["type" => "varchar(255)", "comment" => ""],
805 "notify" => ["type" => "varchar(255)", "comment" => ""],
806 "poll" => ["type" => "varchar(255)", "comment" => ""],
807 "confirm" => ["type" => "varchar(255)", "comment" => ""],
808 "poco" => ["type" => "varchar(255)", "comment" => ""],
809 "aes_allow" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
810 "ret-aes" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
811 "usehub" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
812 "subhub" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
813 "hub-verify" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
814 "last-update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
815 "success_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
816 "failure_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
817 "name-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
818 "uri-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
819 "avatar-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
820 "term-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
821 "last-item" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
822 "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
823 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
824 "readonly" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
825 "writable" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
826 "forum" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
827 "prv" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
828 "contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
829 "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
830 "archive" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
831 "pending" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
832 "rating" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
833 "reason" => ["type" => "text", "comment" => ""],
834 "closeness" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "99", "comment" => ""],
835 "info" => ["type" => "mediumtext", "comment" => ""],
836 "profile-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
837 "bdyear" => ["type" => "varchar(4)", "not null" => "1", "default" => "", "comment" => ""],
838 "bd" => ["type" => "date", "not null" => "1", "default" => "0001-01-01", "comment" => ""],
839 "notify_new_posts" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
840 "fetch_further_information" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
841 "ffi_keyword_blacklist" => ["type" => "text", "comment" => ""],
845 "uid_name" => ["uid", "name(190)"],
846 "self_uid" => ["self", "uid"],
847 "alias_uid" => ["alias(32)", "uid"],
848 "pending_uid" => ["pending", "uid"],
849 "blocked_uid" => ["blocked", "uid"],
850 "uid_rel_network_poll" => ["uid", "rel", "network", "poll(64)", "archive"],
851 "uid_network_batch" => ["uid", "network", "batch(64)"],
852 "addr_uid" => ["addr(32)", "uid"],
853 "nurl_uid" => ["nurl(32)", "uid"],
854 "nick_uid" => ["nick(32)", "uid"],
855 "dfrn-id" => ["dfrn-id(64)"],
856 "issued-id" => ["issued-id(64)"],
859 $database["conv"] = [
860 "comment" => "private messages",
862 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
863 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
864 "recips" => ["type" => "text", "comment" => ""],
865 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
866 "creator" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
867 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
868 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
869 "subject" => ["type" => "text", "comment" => ""],
876 $database["conversation"] = [
877 "comment" => "Raw data and structure information for messages",
879 "item-uri" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => ""],
880 "reply-to-uri" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""],
881 "conversation-uri" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""],
882 "conversation-href" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""],
883 "protocol" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
884 "source" => ["type" => "mediumtext", "comment" => ""],
885 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
888 "PRIMARY" => ["item-uri"],
889 "conversation-uri" => ["conversation-uri"],
890 "received" => ["received"],
893 $database["event"] = [
894 "comment" => "Events",
896 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
897 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
898 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
899 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
900 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
901 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
902 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
903 "start" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
904 "finish" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
905 "summary" => ["type" => "text", "comment" => ""],
906 "desc" => ["type" => "text", "comment" => ""],
907 "location" => ["type" => "text", "comment" => ""],
908 "type" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => ""],
909 "nofinish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
910 "adjust" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
911 "ignore" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
912 "allow_cid" => ["type" => "mediumtext", "comment" => ""],
913 "allow_gid" => ["type" => "mediumtext", "comment" => ""],
914 "deny_cid" => ["type" => "mediumtext", "comment" => ""],
915 "deny_gid" => ["type" => "mediumtext", "comment" => ""],
919 "uid_start" => ["uid", "start"],
922 $database["fcontact"] = [
923 "comment" => "Diaspora compatible contacts - used in the Diaspora implementation",
925 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
926 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
927 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
928 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
929 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
930 "request" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
931 "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
932 "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
933 "batch" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
934 "notify" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
935 "poll" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
936 "confirm" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
937 "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
938 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
939 "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
940 "pubkey" => ["type" => "text", "comment" => ""],
941 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
945 "addr" => ["addr(32)"],
946 "url" => ["UNIQUE", "url(190)"],
949 $database["fsuggest"] = [
950 "comment" => "friend suggestion stuff",
952 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
953 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
954 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
955 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
956 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
957 "request" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
958 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
959 "note" => ["type" => "text", "comment" => ""],
960 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
966 $database["gcign"] = [
967 "comment" => "contacts ignored by friend suggestions",
969 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
970 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
971 "gcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""],
979 $database["gcontact"] = [
980 "comment" => "global contacts",
982 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
983 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
984 "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
985 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
986 "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
987 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
988 "connect" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
989 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
990 "updated" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
991 "last_contact" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
992 "last_failure" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
993 "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
994 "about" => ["type" => "text", "comment" => ""],
995 "keywords" => ["type" => "text", "comment" => ""],
996 "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
997 "birthday" => ["type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01", "comment" => ""],
998 "community" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
999 "contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "-1", "comment" => ""],
1000 "hide" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1001 "nsfw" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1002 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
1003 "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1004 "notify" => ["type" => "varchar(255)", "comment" => ""],
1005 "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1006 "generation" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1007 "server_url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1010 "PRIMARY" => ["id"],
1011 "nurl" => ["UNIQUE", "nurl(190)"],
1012 "name" => ["name(64)"],
1013 "nick" => ["nick(32)"],
1014 "addr" => ["addr(64)"],
1015 "hide_network_updated" => ["hide", "network", "updated"],
1016 "updated" => ["updated"],
1019 $database["glink"] = [
1020 "comment" => "'friends of friends' linkages derived from poco",
1022 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1023 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1024 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1025 "gcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""],
1026 "zcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""],
1027 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1030 "PRIMARY" => ["id"],
1031 "cid_uid_gcid_zcid" => ["UNIQUE", "cid","uid","gcid","zcid"],
1035 $database["group"] = [
1036 "comment" => "privacy groups, group info",
1038 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1039 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1040 "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1041 "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1042 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1045 "PRIMARY" => ["id"],
1049 $database["group_member"] = [
1050 "comment" => "privacy groups, member info",
1052 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1053 "gid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["group" => "id"], "comment" => ""],
1054 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1057 "PRIMARY" => ["id"],
1058 "contactid" => ["contact-id"],
1059 "gid_contactid" => ["UNIQUE", "gid", "contact-id"],
1062 $database["gserver"] = [
1063 "comment" => "Global servers",
1065 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1066 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1067 "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1068 "version" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1069 "site_name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1070 "info" => ["type" => "text", "comment" => ""],
1071 "register_policy" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
1072 "registered-users" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1073 "poco" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1074 "noscrape" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1075 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
1076 "platform" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1077 "relay-subscribe" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Has the server subscribed to the relay system"],
1078 "relay-scope" => ["type" => "varchar(10)", "not null" => "1", "default" => "", "comment" => "The scope of messages that the server wants to get"],
1079 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1080 "last_poco_query" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1081 "last_contact" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1082 "last_failure" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1085 "PRIMARY" => ["id"],
1086 "nurl" => ["UNIQUE", "nurl(190)"],
1089 $database["gserver-tag"] = [
1090 "comment" => "Tags that the server has subscribed",
1092 "gserver-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gserver" => "id"], "primary" => "1", "comment" => "The id of the gserver"],
1093 "tag" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "primary" => "1", "comment" => "Tag that the server has subscribed"],
1096 "PRIMARY" => ["gserver-id", "tag"],
1100 $database["hook"] = [
1101 "comment" => "addon hook registry",
1103 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1104 "hook" => ["type" => "varbinary(100)", "not null" => "1", "default" => "", "comment" => ""],
1105 "file" => ["type" => "varbinary(200)", "not null" => "1", "default" => "", "comment" => ""],
1106 "function" => ["type" => "varbinary(200)", "not null" => "1", "default" => "", "comment" => ""],
1107 "priority" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1110 "PRIMARY" => ["id"],
1111 "hook_file_function" => ["UNIQUE", "hook", "file", "function"],
1114 $database["intro"] = [
1117 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1118 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1119 "fid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["fcontact" => "id"], "comment" => ""],
1120 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1121 "knowyou" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1122 "duplex" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1123 "note" => ["type" => "text", "comment" => ""],
1124 "hash" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1125 "datetime" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1126 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
1127 "ignore" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1130 "PRIMARY" => ["id"],
1133 $database["item"] = [
1134 "comment" => "All posts",
1136 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => ["thread" => "iid"]],
1137 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1138 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1139 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1140 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1141 "type" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => ""],
1142 "wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1143 "gravity" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1144 "parent" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1145 "parent-uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1146 "extid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1147 "thr-parent" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1148 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1149 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1150 "commented" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1151 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1152 "changed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1153 "owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1154 "owner-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1155 "owner-link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1156 "owner-avatar" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1157 "author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1158 "author-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1159 "author-link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1160 "author-avatar" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1161 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1162 "content-warning" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1163 "body" => ["type" => "mediumtext", "comment" => ""],
1164 "app" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1165 "verb" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => ""],
1166 "object-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => ""],
1167 "object" => ["type" => "text", "comment" => ""],
1168 "target-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => ""],
1169 "target" => ["type" => "text", "comment" => ""],
1170 "postopts" => ["type" => "text", "comment" => ""],
1171 "plink" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1172 "resource-id" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1173 "event-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["event" => "id"], "comment" => ""],
1174 "tag" => ["type" => "mediumtext", "comment" => ""],
1175 "attach" => ["type" => "mediumtext", "comment" => ""],
1176 "inform" => ["type" => "mediumtext", "comment" => ""],
1177 "file" => ["type" => "mediumtext", "comment" => ""],
1178 "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1179 "coord" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1180 "allow_cid" => ["type" => "mediumtext", "comment" => ""],
1181 "allow_gid" => ["type" => "mediumtext", "comment" => ""],
1182 "deny_cid" => ["type" => "mediumtext", "comment" => ""],
1183 "deny_gid" => ["type" => "mediumtext", "comment" => ""],
1184 "private" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1185 "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1186 "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1187 "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1188 "spam" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1189 "starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1190 "bookmark" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1191 "unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
1192 "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1193 "origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1194 "forum_mode" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1195 "mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1196 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
1197 "rendered-hash" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1198 "rendered-html" => ["type" => "mediumtext", "comment" => ""],
1199 "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1202 "PRIMARY" => ["id"],
1203 "guid" => ["guid(191)"],
1204 "uri" => ["uri(191)"],
1205 "parent" => ["parent"],
1206 "parent-uri" => ["parent-uri(191)"],
1207 "extid" => ["extid(191)"],
1208 "uid_id" => ["uid","id"],
1209 "uid_contactid_id" => ["uid","contact-id","id"],
1210 "uid_created" => ["uid","created"],
1211 "uid_commented" => ["uid","commented"],
1212 "uid_unseen_contactid" => ["uid","unseen","contact-id"],
1213 "uid_network_received" => ["uid","network","received"],
1214 "uid_network_commented" => ["uid","network","commented"],
1215 "uid_thrparent" => ["uid","thr-parent(190)"],
1216 "uid_parenturi" => ["uid","parent-uri(190)"],
1217 "uid_contactid_created" => ["uid","contact-id","created"],
1218 "authorid_created" => ["author-id","created"],
1219 "ownerid" => ["owner-id"],
1220 "uid_uri" => ["uid", "uri(190)"],
1221 "resource-id" => ["resource-id"],
1222 "contactid_allowcid_allowpid_denycid_denygid" => ["contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"], //
1223 "uid_type_changed" => ["uid","type","changed"],
1224 "contactid_verb" => ["contact-id","verb"],
1225 "deleted_changed" => ["deleted","changed"],
1226 "uid_wall_changed" => ["uid","wall","changed"],
1227 "uid_eventid" => ["uid","event-id"],
1228 "uid_authorlink" => ["uid","author-link(190)"],
1229 "uid_ownerlink" => ["uid","owner-link(190)"],
1232 $database["locks"] = [
1235 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1236 "name" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => ""],
1237 "locked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1238 "pid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1241 "PRIMARY" => ["id"],
1244 $database["mail"] = [
1245 "comment" => "private messages",
1247 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1248 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1249 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1250 "from-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1251 "from-photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1252 "from-url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1253 "contact-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => ["contact" => "id"], "comment" => ""],
1254 "convid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["conv" => "id"], "comment" => ""],
1255 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1256 "body" => ["type" => "mediumtext", "comment" => ""],
1257 "seen" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1258 "reply" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1259 "replied" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1260 "unknown" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1261 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1262 "parent-uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1263 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1266 "PRIMARY" => ["id"],
1267 "uid_seen" => ["uid", "seen"],
1268 "convid" => ["convid"],
1269 "uri" => ["uri(64)"],
1270 "parent-uri" => ["parent-uri(64)"],
1271 "contactid" => ["contact-id(32)"],
1274 $database["mailacct"] = [
1275 "comment" => "Mail account data for fetching mails",
1277 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1278 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1279 "server" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1280 "port" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1281 "ssltype" => ["type" => "varchar(16)", "not null" => "1", "default" => "", "comment" => ""],
1282 "mailbox" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1283 "user" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1284 "pass" => ["type" => "text", "comment" => ""],
1285 "reply_to" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1286 "action" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1287 "movetofolder" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1288 "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1289 "last_check" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1292 "PRIMARY" => ["id"],
1295 $database["manage"] = [
1296 "comment" => "table of accounts that can manage each other",
1298 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1299 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1300 "mid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1303 "PRIMARY" => ["id"],
1304 "uid_mid" => ["UNIQUE", "uid","mid"],
1307 $database["notify"] = [
1308 "comment" => "notifications",
1310 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1311 "hash" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
1312 "type" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1313 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1314 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1315 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1316 "date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1317 "msg" => ["type" => "mediumtext", "comment" => ""],
1318 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1319 "link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1320 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1321 "parent" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1322 "seen" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1323 "verb" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => ""],
1324 "otype" => ["type" => "varchar(10)", "not null" => "1", "default" => "", "comment" => ""],
1325 "name_cache" => ["type" => "tinytext", "comment" => ""],
1326 "msg_cache" => ["type" => "mediumtext", "comment" => ""]
1329 "PRIMARY" => ["id"],
1330 "hash_uid" => ["hash", "uid"],
1331 "seen_uid_date" => ["seen", "uid", "date"],
1332 "uid_date" => ["uid", "date"],
1333 "uid_type_link" => ["uid", "type", "link(190)"],
1336 $database["notify-threads"] = [
1339 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1340 "notify-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["notify" => "id"], "comment" => ""],
1341 "master-parent-item" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1342 "parent-item" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1343 "receiver-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1346 "PRIMARY" => ["id"],
1349 $database["oembed"] = [
1350 "comment" => "cache for OEmbed queries",
1352 "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => ""],
1353 "maxwidth" => ["type" => "mediumint unsigned", "not null" => "1", "primary" => "1", "comment" => ""],
1354 "content" => ["type" => "mediumtext", "comment" => ""],
1355 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1358 "PRIMARY" => ["url", "maxwidth"],
1359 "created" => ["created"],
1362 $database["parsed_url"] = [
1363 "comment" => "cache for 'parse_url' queries",
1365 "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => ""],
1366 "guessing" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => ""],
1367 "oembed" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => ""],
1368 "content" => ["type" => "mediumtext", "comment" => ""],
1369 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1372 "PRIMARY" => ["url", "guessing", "oembed"],
1373 "created" => ["created"],
1376 $database["participation"] = [
1377 "comment" => "Storage for participation messages from Diaspora",
1379 "iid" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "relation" => ["item" => "id"], "comment" => ""],
1380 "server" => ["type" => "varchar(60)", "not null" => "1", "primary" => "1", "comment" => ""],
1381 "cid" => ["type" => "int unsigned", "not null" => "1", "relation" => ["contact" => "id"], "comment" => ""],
1382 "fid" => ["type" => "int unsigned", "not null" => "1", "relation" => ["fcontact" => "id"], "comment" => ""],
1385 "PRIMARY" => ["iid", "server"]
1388 $database["pconfig"] = [
1389 "comment" => "personal (per user) configuration storage",
1391 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1392 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1393 "cat" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""],
1394 "k" => ["type" => "varbinary(100)", "not null" => "1", "default" => "", "comment" => ""],
1395 "v" => ["type" => "mediumtext", "comment" => ""],
1398 "PRIMARY" => ["id"],
1399 "uid_cat_k" => ["UNIQUE", "uid", "cat", "k"],
1402 $database["photo"] = [
1403 "comment" => "photo storage",
1405 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1406 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1407 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1408 "guid" => ["type" => "char(16)", "not null" => "1", "default" => "", "comment" => ""],
1409 "resource-id" => ["type" => "char(32)", "not null" => "1", "default" => "", "comment" => ""],
1410 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1411 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1412 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1413 "desc" => ["type" => "text", "comment" => ""],
1414 "album" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1415 "filename" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1416 "type" => ["type" => "varchar(30)", "not null" => "1", "default" => "image/jpeg"],
1417 "height" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1418 "width" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1419 "datasize" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1420 "data" => ["type" => "mediumblob", "not null" => "1", "comment" => ""],
1421 "scale" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1422 "profile" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1423 "allow_cid" => ["type" => "mediumtext", "comment" => ""],
1424 "allow_gid" => ["type" => "mediumtext", "comment" => ""],
1425 "deny_cid" => ["type" => "mediumtext", "comment" => ""],
1426 "deny_gid" => ["type" => "mediumtext", "comment" => ""],
1429 "PRIMARY" => ["id"],
1430 "contactid" => ["contact-id"],
1431 "uid_contactid" => ["uid", "contact-id"],
1432 "uid_profile" => ["uid", "profile"],
1433 "uid_album_scale_created" => ["uid", "album(32)", "scale", "created"],
1434 "uid_album_resource-id_created" => ["uid", "album(32)", "resource-id", "created"],
1435 "resource-id" => ["resource-id"],
1438 $database["poll"] = [
1439 "comment" => "Currently unused table for storing poll results",
1441 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1442 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1443 "q0" => ["type" => "text", "comment" => ""],
1444 "q1" => ["type" => "text", "comment" => ""],
1445 "q2" => ["type" => "text", "comment" => ""],
1446 "q3" => ["type" => "text", "comment" => ""],
1447 "q4" => ["type" => "text", "comment" => ""],
1448 "q5" => ["type" => "text", "comment" => ""],
1449 "q6" => ["type" => "text", "comment" => ""],
1450 "q7" => ["type" => "text", "comment" => ""],
1451 "q8" => ["type" => "text", "comment" => ""],
1452 "q9" => ["type" => "text", "comment" => ""],
1455 "PRIMARY" => ["id"],
1459 $database["poll_result"] = [
1460 "comment" => "data for polls - currently unused",
1462 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1463 "poll_id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["poll" => "id"]],
1464 "choice" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1467 "PRIMARY" => ["id"],
1468 "poll_id" => ["poll_id"],
1471 $database["process"] = [
1472 "comment" => "Currently running system processes",
1474 "pid" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "comment" => ""],
1475 "command" => ["type" => "varbinary(32)", "not null" => "1", "default" => "", "comment" => ""],
1476 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1479 "PRIMARY" => ["pid"],
1480 "command" => ["command"],
1483 $database["profile"] = [
1484 "comment" => "user profiles data",
1486 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1487 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1488 "profile-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1489 "is-default" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1490 "hide-friends" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1491 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1492 "pdesc" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1493 "dob" => ["type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00", "comment" => ""],
1494 "address" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1495 "locality" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1496 "region" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1497 "postal-code" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1498 "country-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1499 "hometown" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1500 "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1501 "marital" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1502 "with" => ["type" => "text", "comment" => ""],
1503 "howlong" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1504 "sexual" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1505 "politic" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1506 "religion" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1507 "pub_keywords" => ["type" => "text", "comment" => ""],
1508 "prv_keywords" => ["type" => "text", "comment" => ""],
1509 "likes" => ["type" => "text", "comment" => ""],
1510 "dislikes" => ["type" => "text", "comment" => ""],
1511 "about" => ["type" => "text", "comment" => ""],
1512 "summary" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1513 "music" => ["type" => "text", "comment" => ""],
1514 "book" => ["type" => "text", "comment" => ""],
1515 "tv" => ["type" => "text", "comment" => ""],
1516 "film" => ["type" => "text", "comment" => ""],
1517 "interest" => ["type" => "text", "comment" => ""],
1518 "romance" => ["type" => "text", "comment" => ""],
1519 "work" => ["type" => "text", "comment" => ""],
1520 "education" => ["type" => "text", "comment" => ""],
1521 "contact" => ["type" => "text", "comment" => ""],
1522 "homepage" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1523 "xmpp" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1524 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1525 "thumb" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1526 "publish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1527 "net-publish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1530 "PRIMARY" => ["id"],
1531 "uid_is-default" => ["uid", "is-default"],
1534 $database["profile_check"] = [
1535 "comment" => "DFRN remote auth use",
1537 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1538 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1539 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1540 "dfrn_id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1541 "sec" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1542 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1545 "PRIMARY" => ["id"],
1548 $database["push_subscriber"] = [
1549 "comment" => "Used for OStatus: Contains feed subscribers",
1551 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1552 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1553 "callback_url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1554 "topic" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1555 "nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1556 "push" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Retrial counter"],
1557 "last_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last successful trial"],
1558 "next_try" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Next retrial date"],
1559 "renewed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last subscription renewal"],
1560 "secret" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1563 "PRIMARY" => ["id"],
1564 "next_try" => ["next_try"],
1567 $database["queue"] = [
1568 "comment" => "Queue for messages that couldn't be delivered",
1570 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1571 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Message receiver"],
1572 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Receiver's network"],
1573 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Unique GUID of the message"],
1574 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date, when the message was created"],
1575 "last" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last trial"],
1576 "next" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Next retrial date"],
1577 "retrial" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Retrial counter"],
1578 "content" => ["type" => "mediumtext", "comment" => ""],
1579 "batch" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1582 "PRIMARY" => ["id"],
1587 $database["register"] = [
1588 "comment" => "registrations requiring admin approval",
1590 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1591 "hash" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1592 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1593 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1594 "password" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1595 "language" => ["type" => "varchar(16)", "not null" => "1", "default" => "", "comment" => ""],
1596 "note" => ["type" => "text", "comment" => ""],
1599 "PRIMARY" => ["id"],
1602 $database["search"] = [
1605 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1606 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1607 "term" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1610 "PRIMARY" => ["id"],
1614 $database["session"] = [
1615 "comment" => "web session storage",
1617 "id" => ["type" => "bigint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1618 "sid" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""],
1619 "data" => ["type" => "text", "comment" => ""],
1620 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1623 "PRIMARY" => ["id"],
1624 "sid" => ["sid(64)"],
1625 "expire" => ["expire"],
1628 $database["sign"] = [
1629 "comment" => "Diaspora signatures",
1631 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1632 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1633 "signed_text" => ["type" => "mediumtext", "comment" => ""],
1634 "signature" => ["type" => "text", "comment" => ""],
1635 "signer" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1638 "PRIMARY" => ["id"],
1639 "iid" => ["UNIQUE", "iid"],
1642 $database["term"] = [
1643 "comment" => "item taxonomy (categories, tags, etc.) table",
1645 "tid" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1646 "oid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1647 "otype" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1648 "type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1649 "term" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1650 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1651 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1652 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1653 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1654 "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1655 "aid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1656 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1659 "PRIMARY" => ["tid"],
1660 "oid_otype_type_term" => ["oid","otype","type","term(32)"],
1661 "uid_otype_type_term_global_created" => ["uid","otype","type","term(32)","global","created"],
1662 "uid_otype_type_url" => ["uid","otype","type","url(64)"],
1663 "guid" => ["guid(64)"],
1666 $database["thread"] = [
1667 "comment" => "Thread related data",
1669 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["item" => "id"], "comment" => ""],
1670 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1671 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1672 "owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1673 "author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1674 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1675 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1676 "commented" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1677 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1678 "changed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1679 "wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1680 "private" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1681 "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1682 "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1683 "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1684 "spam" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1685 "starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1686 "ignored" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1687 "bookmark" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1688 "unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
1689 "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1690 "origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1691 "forum_mode" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1692 "mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1693 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
1696 "PRIMARY" => ["iid"],
1697 "uid_network_commented" => ["uid","network","commented"],
1698 "uid_network_created" => ["uid","network","created"],
1699 "uid_contactid_commented" => ["uid","contact-id","commented"],
1700 "uid_contactid_created" => ["uid","contact-id","created"],
1701 "contactid" => ["contact-id"],
1702 "ownerid" => ["owner-id"],
1703 "authorid" => ["author-id"],
1704 "uid_created" => ["uid","created"],
1705 "uid_commented" => ["uid","commented"],
1706 "uid_wall_created" => ["uid","wall","created"],
1707 "private_wall_origin_commented" => ["private","wall","origin","commented"],
1710 $database["tokens"] = [
1711 "comment" => "OAuth usage",
1713 "id" => ["type" => "varchar(40)", "not null" => "1", "primary" => "1", "comment" => ""],
1714 "secret" => ["type" => "text", "comment" => ""],
1715 "client_id" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => ["clients" => "client_id"]],
1716 "expires" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
1717 "scope" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
1718 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1721 "PRIMARY" => ["id"],
1724 $database["user"] = [
1725 "comment" => "The local users",
1727 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1728 "parent-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "The parent user that has full control about this user"],
1729 "guid" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
1730 "username" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1731 "password" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1732 "legacy_password" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Is the password hash double-hashed?"],
1733 "nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1734 "email" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1735 "openid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1736 "timezone" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => ""],
1737 "language" => ["type" => "varchar(32)", "not null" => "1", "default" => "en", "comment" => ""],
1738 "register_date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1739 "login_date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1740 "default-location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1741 "allow_location" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1742 "theme" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1743 "pubkey" => ["type" => "text", "comment" => ""],
1744 "prvkey" => ["type" => "text", "comment" => ""],
1745 "spubkey" => ["type" => "text", "comment" => ""],
1746 "sprvkey" => ["type" => "text", "comment" => ""],
1747 "verified" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1748 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1749 "blockwall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1750 "hidewall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1751 "blocktags" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1752 "unkmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1753 "cntunkmail" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""],
1754 "notify-flags" => ["type" => "smallint unsigned", "not null" => "1", "default" => "65535", "comment" => ""],
1755 "page-flags" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1756 "account-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1757 "prvnets" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1758 "pwdreset" => ["type" => "varchar(255)", "comment" => "Password reset request token"],
1759 "pwdreset_time" => ["type" => "datetime", "comment" => "Timestamp of the last password reset request"],
1760 "maxreq" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""],
1761 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1762 "account_removed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1763 "account_expired" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1764 "account_expires_on" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1765 "expire_notification_sent" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1766 "def_gid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1767 "allow_cid" => ["type" => "mediumtext", "comment" => ""],
1768 "allow_gid" => ["type" => "mediumtext", "comment" => ""],
1769 "deny_cid" => ["type" => "mediumtext", "comment" => ""],
1770 "deny_gid" => ["type" => "mediumtext", "comment" => ""],
1771 "openidserver" => ["type" => "text", "comment" => ""],
1774 "PRIMARY" => ["uid"],
1775 "nickname" => ["nickname(32)"],
1778 $database["userd"] = [
1779 "comment" => "Deleted usernames",
1781 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1782 "username" => ["type" => "varchar(255)", "not null" => "1", "comment" => ""],
1785 "PRIMARY" => ["id"],
1786 "username" => ["username(32)"],
1789 $database["workerqueue"] = [
1790 "comment" => "Background tasks queue entries",
1792 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "Auto incremented worker task id"],
1793 "parameter" => ["type" => "mediumblob", "comment" => "Task command"],
1794 "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Task priority"],
1795 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Creation date"],
1796 "pid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "Process id of the worker"],
1797 "executed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Execution date"],
1798 "done" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Marked when the task was done, will be deleted later"],
1801 "PRIMARY" => ["id"],
1803 "parameter" => ["parameter(64)"],
1804 "priority_created" => ["priority", "created"],
1805 "done_executed" => ["done", "executed"],
1809 \Friendica\Core\Addon::callHooks('dbstructure_definition', $database);