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(': 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" => "Used to store different data that doesn't to be stored for a long time",
720 "k" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => ""],
721 "v" => ["type" => "mediumtext", "comment" => ""],
722 "expire_mode" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
723 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
727 "expire_mode_updated" => ["expire_mode", "updated"],
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)", "not null" => "1", "default" => "", "comment" => ""],
792 "thumb" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
793 "micro" => ["type" => "varchar(255)", "not null" => "1", "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 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1078 "last_poco_query" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1079 "last_contact" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1080 "last_failure" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1083 "PRIMARY" => ["id"],
1084 "nurl" => ["UNIQUE", "nurl(190)"],
1087 $database["hook"] = [
1088 "comment" => "addon hook registry",
1090 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1091 "hook" => ["type" => "varbinary(100)", "not null" => "1", "default" => "", "comment" => ""],
1092 "file" => ["type" => "varbinary(200)", "not null" => "1", "default" => "", "comment" => ""],
1093 "function" => ["type" => "varbinary(200)", "not null" => "1", "default" => "", "comment" => ""],
1094 "priority" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1097 "PRIMARY" => ["id"],
1098 "hook_file_function" => ["UNIQUE", "hook", "file", "function"],
1101 $database["intro"] = [
1104 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1105 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1106 "fid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["fcontact" => "id"], "comment" => ""],
1107 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1108 "knowyou" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1109 "duplex" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1110 "note" => ["type" => "text", "comment" => ""],
1111 "hash" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1112 "datetime" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1113 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
1114 "ignore" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1117 "PRIMARY" => ["id"],
1120 $database["item"] = [
1121 "comment" => "All posts",
1123 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => ["thread" => "iid"]],
1124 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1125 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1126 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1127 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1128 "type" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => ""],
1129 "wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1130 "gravity" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1131 "parent" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1132 "parent-uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1133 "extid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1134 "thr-parent" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1135 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1136 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1137 "commented" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1138 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1139 "changed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1140 "owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1141 "owner-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1142 "owner-link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1143 "owner-avatar" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1144 "author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1145 "author-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1146 "author-link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1147 "author-avatar" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1148 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1149 "content-warning" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1150 "body" => ["type" => "mediumtext", "comment" => ""],
1151 "app" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1152 "verb" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => ""],
1153 "object-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => ""],
1154 "object" => ["type" => "text", "comment" => ""],
1155 "target-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => ""],
1156 "target" => ["type" => "text", "comment" => ""],
1157 "postopts" => ["type" => "text", "comment" => ""],
1158 "plink" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1159 "resource-id" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1160 "event-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["event" => "id"], "comment" => ""],
1161 "tag" => ["type" => "mediumtext", "comment" => ""],
1162 "attach" => ["type" => "mediumtext", "comment" => ""],
1163 "inform" => ["type" => "mediumtext", "comment" => ""],
1164 "file" => ["type" => "mediumtext", "comment" => ""],
1165 "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1166 "coord" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1167 "allow_cid" => ["type" => "mediumtext", "comment" => ""],
1168 "allow_gid" => ["type" => "mediumtext", "comment" => ""],
1169 "deny_cid" => ["type" => "mediumtext", "comment" => ""],
1170 "deny_gid" => ["type" => "mediumtext", "comment" => ""],
1171 "private" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1172 "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1173 "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1174 "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1175 "spam" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1176 "starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1177 "bookmark" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1178 "unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
1179 "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1180 "origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1181 "forum_mode" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1182 "mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1183 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
1184 "rendered-hash" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1185 "rendered-html" => ["type" => "mediumtext", "comment" => ""],
1186 "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1189 "PRIMARY" => ["id"],
1190 "guid" => ["guid(191)"],
1191 "uri" => ["uri(191)"],
1192 "parent" => ["parent"],
1193 "parent-uri" => ["parent-uri(191)"],
1194 "extid" => ["extid(191)"],
1195 "uid_id" => ["uid","id"],
1196 "uid_contactid_id" => ["uid","contact-id","id"],
1197 "uid_created" => ["uid","created"],
1198 "uid_commented" => ["uid","commented"],
1199 "uid_unseen_contactid" => ["uid","unseen","contact-id"],
1200 "uid_network_received" => ["uid","network","received"],
1201 "uid_network_commented" => ["uid","network","commented"],
1202 "uid_thrparent" => ["uid","thr-parent(190)"],
1203 "uid_parenturi" => ["uid","parent-uri(190)"],
1204 "uid_contactid_created" => ["uid","contact-id","created"],
1205 "authorid_created" => ["author-id","created"],
1206 "ownerid" => ["owner-id"],
1207 "uid_uri" => ["uid", "uri(190)"],
1208 "resource-id" => ["resource-id"],
1209 "contactid_allowcid_allowpid_denycid_denygid" => ["contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"], //
1210 "uid_type_changed" => ["uid","type","changed"],
1211 "contactid_verb" => ["contact-id","verb"],
1212 "deleted_changed" => ["deleted","changed"],
1213 "uid_wall_changed" => ["uid","wall","changed"],
1214 "uid_eventid" => ["uid","event-id"],
1215 "uid_authorlink" => ["uid","author-link(190)"],
1216 "uid_ownerlink" => ["uid","owner-link(190)"],
1219 $database["locks"] = [
1222 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1223 "name" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => ""],
1224 "locked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1225 "pid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1228 "PRIMARY" => ["id"],
1231 $database["mail"] = [
1232 "comment" => "private messages",
1234 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1235 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1236 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1237 "from-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1238 "from-photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1239 "from-url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1240 "contact-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => ["contact" => "id"], "comment" => ""],
1241 "convid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["conv" => "id"], "comment" => ""],
1242 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1243 "body" => ["type" => "mediumtext", "comment" => ""],
1244 "seen" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1245 "reply" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1246 "replied" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1247 "unknown" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1248 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1249 "parent-uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1250 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1253 "PRIMARY" => ["id"],
1254 "uid_seen" => ["uid", "seen"],
1255 "convid" => ["convid"],
1256 "uri" => ["uri(64)"],
1257 "parent-uri" => ["parent-uri(64)"],
1258 "contactid" => ["contact-id(32)"],
1261 $database["mailacct"] = [
1262 "comment" => "Mail account data for fetching mails",
1264 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1265 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1266 "server" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1267 "port" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1268 "ssltype" => ["type" => "varchar(16)", "not null" => "1", "default" => "", "comment" => ""],
1269 "mailbox" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1270 "user" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1271 "pass" => ["type" => "text", "comment" => ""],
1272 "reply_to" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1273 "action" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1274 "movetofolder" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1275 "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1276 "last_check" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1279 "PRIMARY" => ["id"],
1282 $database["manage"] = [
1283 "comment" => "table of accounts that can manage each other",
1285 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1286 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1287 "mid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1290 "PRIMARY" => ["id"],
1291 "uid_mid" => ["UNIQUE", "uid","mid"],
1294 $database["notify"] = [
1295 "comment" => "notifications",
1297 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1298 "hash" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
1299 "type" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1300 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1301 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1302 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1303 "date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1304 "msg" => ["type" => "mediumtext", "comment" => ""],
1305 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1306 "link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1307 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1308 "parent" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1309 "seen" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1310 "verb" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => ""],
1311 "otype" => ["type" => "varchar(10)", "not null" => "1", "default" => "", "comment" => ""],
1312 "name_cache" => ["type" => "tinytext", "comment" => ""],
1313 "msg_cache" => ["type" => "mediumtext", "comment" => ""]
1316 "PRIMARY" => ["id"],
1317 "hash_uid" => ["hash", "uid"],
1318 "seen_uid_date" => ["seen", "uid", "date"],
1319 "uid_date" => ["uid", "date"],
1320 "uid_type_link" => ["uid", "type", "link(190)"],
1323 $database["notify-threads"] = [
1326 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1327 "notify-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["notify" => "id"], "comment" => ""],
1328 "master-parent-item" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1329 "parent-item" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1330 "receiver-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1333 "PRIMARY" => ["id"],
1336 $database["oembed"] = [
1337 "comment" => "cache for OEmbed queries",
1339 "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => ""],
1340 "maxwidth" => ["type" => "mediumint unsigned", "not null" => "1", "primary" => "1", "comment" => ""],
1341 "content" => ["type" => "mediumtext", "comment" => ""],
1342 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1345 "PRIMARY" => ["url", "maxwidth"],
1346 "created" => ["created"],
1349 $database["parsed_url"] = [
1350 "comment" => "cache for 'parse_url' queries",
1352 "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => ""],
1353 "guessing" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => ""],
1354 "oembed" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => ""],
1355 "content" => ["type" => "mediumtext", "comment" => ""],
1356 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1359 "PRIMARY" => ["url", "guessing", "oembed"],
1360 "created" => ["created"],
1363 $database["participation"] = [
1364 "comment" => "Storage for participation messages from Diaspora",
1366 "iid" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "relation" => ["item" => "id"], "comment" => ""],
1367 "server" => ["type" => "varchar(60)", "not null" => "1", "primary" => "1", "comment" => ""],
1368 "cid" => ["type" => "int unsigned", "not null" => "1", "relation" => ["contact" => "id"], "comment" => ""],
1369 "fid" => ["type" => "int unsigned", "not null" => "1", "relation" => ["fcontact" => "id"], "comment" => ""],
1372 "PRIMARY" => ["iid", "server"]
1375 $database["pconfig"] = [
1376 "comment" => "personal (per user) configuration storage",
1378 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1379 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1380 "cat" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""],
1381 "k" => ["type" => "varbinary(100)", "not null" => "1", "default" => "", "comment" => ""],
1382 "v" => ["type" => "mediumtext", "comment" => ""],
1385 "PRIMARY" => ["id"],
1386 "uid_cat_k" => ["UNIQUE", "uid", "cat", "k"],
1389 $database["photo"] = [
1390 "comment" => "photo storage",
1392 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1393 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1394 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1395 "guid" => ["type" => "char(16)", "not null" => "1", "default" => "", "comment" => ""],
1396 "resource-id" => ["type" => "char(32)", "not null" => "1", "default" => "", "comment" => ""],
1397 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1398 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1399 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1400 "desc" => ["type" => "text", "comment" => ""],
1401 "album" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1402 "filename" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1403 "type" => ["type" => "varchar(30)", "not null" => "1", "default" => "image/jpeg"],
1404 "height" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1405 "width" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1406 "datasize" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1407 "data" => ["type" => "mediumblob", "not null" => "1", "comment" => ""],
1408 "scale" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1409 "profile" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1410 "allow_cid" => ["type" => "mediumtext", "comment" => ""],
1411 "allow_gid" => ["type" => "mediumtext", "comment" => ""],
1412 "deny_cid" => ["type" => "mediumtext", "comment" => ""],
1413 "deny_gid" => ["type" => "mediumtext", "comment" => ""],
1416 "PRIMARY" => ["id"],
1417 "contactid" => ["contact-id"],
1418 "uid_contactid" => ["uid", "contact-id"],
1419 "uid_profile" => ["uid", "profile"],
1420 "uid_album_scale_created" => ["uid", "album(32)", "scale", "created"],
1421 "uid_album_resource-id_created" => ["uid", "album(32)", "resource-id", "created"],
1422 "resource-id" => ["resource-id"],
1425 $database["poll"] = [
1426 "comment" => "Currently unused table for storing poll results",
1428 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1429 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1430 "q0" => ["type" => "text", "comment" => ""],
1431 "q1" => ["type" => "text", "comment" => ""],
1432 "q2" => ["type" => "text", "comment" => ""],
1433 "q3" => ["type" => "text", "comment" => ""],
1434 "q4" => ["type" => "text", "comment" => ""],
1435 "q5" => ["type" => "text", "comment" => ""],
1436 "q6" => ["type" => "text", "comment" => ""],
1437 "q7" => ["type" => "text", "comment" => ""],
1438 "q8" => ["type" => "text", "comment" => ""],
1439 "q9" => ["type" => "text", "comment" => ""],
1442 "PRIMARY" => ["id"],
1446 $database["poll_result"] = [
1447 "comment" => "data for polls - currently unused",
1449 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1450 "poll_id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["poll" => "id"]],
1451 "choice" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1454 "PRIMARY" => ["id"],
1455 "poll_id" => ["poll_id"],
1458 $database["process"] = [
1459 "comment" => "Currently running system processes",
1461 "pid" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "comment" => ""],
1462 "command" => ["type" => "varbinary(32)", "not null" => "1", "default" => "", "comment" => ""],
1463 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1466 "PRIMARY" => ["pid"],
1467 "command" => ["command"],
1470 $database["profile"] = [
1471 "comment" => "user profiles data",
1473 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1474 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1475 "profile-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1476 "is-default" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1477 "hide-friends" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1478 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1479 "pdesc" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1480 "dob" => ["type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00", "comment" => ""],
1481 "address" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1482 "locality" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1483 "region" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1484 "postal-code" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1485 "country-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1486 "hometown" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1487 "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1488 "marital" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1489 "with" => ["type" => "text", "comment" => ""],
1490 "howlong" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1491 "sexual" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1492 "politic" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1493 "religion" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1494 "pub_keywords" => ["type" => "text", "comment" => ""],
1495 "prv_keywords" => ["type" => "text", "comment" => ""],
1496 "likes" => ["type" => "text", "comment" => ""],
1497 "dislikes" => ["type" => "text", "comment" => ""],
1498 "about" => ["type" => "text", "comment" => ""],
1499 "summary" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1500 "music" => ["type" => "text", "comment" => ""],
1501 "book" => ["type" => "text", "comment" => ""],
1502 "tv" => ["type" => "text", "comment" => ""],
1503 "film" => ["type" => "text", "comment" => ""],
1504 "interest" => ["type" => "text", "comment" => ""],
1505 "romance" => ["type" => "text", "comment" => ""],
1506 "work" => ["type" => "text", "comment" => ""],
1507 "education" => ["type" => "text", "comment" => ""],
1508 "contact" => ["type" => "text", "comment" => ""],
1509 "homepage" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1510 "xmpp" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1511 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1512 "thumb" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1513 "publish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1514 "net-publish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1517 "PRIMARY" => ["id"],
1518 "uid_is-default" => ["uid", "is-default"],
1521 $database["profile_check"] = [
1522 "comment" => "DFRN remote auth use",
1524 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1525 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1526 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1527 "dfrn_id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1528 "sec" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1529 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1532 "PRIMARY" => ["id"],
1535 $database["push_subscriber"] = [
1536 "comment" => "Used for OStatus: Contains feed subscribers",
1538 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1539 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1540 "callback_url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1541 "topic" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1542 "nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1543 "push" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1544 "last_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1545 "secret" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1548 "PRIMARY" => ["id"],
1551 $database["queue"] = [
1552 "comment" => "Queue for messages that couldn't be delivered",
1554 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1555 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Message receiver"],
1556 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Receiver's network"],
1557 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Unique GUID of the message"],
1558 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date, when the message was created"],
1559 "last" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last trial"],
1560 "next" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Next retrial date"],
1561 "retrial" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Retrial counter"],
1562 "content" => ["type" => "mediumtext", "comment" => ""],
1563 "batch" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1566 "PRIMARY" => ["id"],
1571 $database["register"] = [
1572 "comment" => "registrations requiring admin approval",
1574 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1575 "hash" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1576 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1577 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1578 "password" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1579 "language" => ["type" => "varchar(16)", "not null" => "1", "default" => "", "comment" => ""],
1580 "note" => ["type" => "text", "comment" => ""],
1583 "PRIMARY" => ["id"],
1586 $database["search"] = [
1589 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1590 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1591 "term" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1594 "PRIMARY" => ["id"],
1598 $database["session"] = [
1599 "comment" => "web session storage",
1601 "id" => ["type" => "bigint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1602 "sid" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""],
1603 "data" => ["type" => "text", "comment" => ""],
1604 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1607 "PRIMARY" => ["id"],
1608 "sid" => ["sid(64)"],
1609 "expire" => ["expire"],
1612 $database["sign"] = [
1613 "comment" => "Diaspora signatures",
1615 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1616 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1617 "signed_text" => ["type" => "mediumtext", "comment" => ""],
1618 "signature" => ["type" => "text", "comment" => ""],
1619 "signer" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1622 "PRIMARY" => ["id"],
1623 "iid" => ["UNIQUE", "iid"],
1626 $database["term"] = [
1627 "comment" => "item taxonomy (categories, tags, etc.) table",
1629 "tid" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1630 "oid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1631 "otype" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1632 "type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1633 "term" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1634 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1635 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1636 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1637 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1638 "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1639 "aid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1640 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1643 "PRIMARY" => ["tid"],
1644 "oid_otype_type_term" => ["oid","otype","type","term(32)"],
1645 "uid_otype_type_term_global_created" => ["uid","otype","type","term(32)","global","created"],
1646 "uid_otype_type_url" => ["uid","otype","type","url(64)"],
1647 "guid" => ["guid(64)"],
1650 $database["thread"] = [
1651 "comment" => "Thread related data",
1653 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["item" => "id"], "comment" => ""],
1654 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1655 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1656 "owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1657 "author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1658 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1659 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1660 "commented" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1661 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1662 "changed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1663 "wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1664 "private" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1665 "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1666 "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1667 "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1668 "spam" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1669 "starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1670 "ignored" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1671 "bookmark" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1672 "unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
1673 "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1674 "origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1675 "forum_mode" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1676 "mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1677 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
1680 "PRIMARY" => ["iid"],
1681 "uid_network_commented" => ["uid","network","commented"],
1682 "uid_network_created" => ["uid","network","created"],
1683 "uid_contactid_commented" => ["uid","contact-id","commented"],
1684 "uid_contactid_created" => ["uid","contact-id","created"],
1685 "contactid" => ["contact-id"],
1686 "ownerid" => ["owner-id"],
1687 "authorid" => ["author-id"],
1688 "uid_created" => ["uid","created"],
1689 "uid_commented" => ["uid","commented"],
1690 "uid_wall_created" => ["uid","wall","created"],
1691 "private_wall_origin_commented" => ["private","wall","origin","commented"],
1694 $database["tokens"] = [
1695 "comment" => "OAuth usage",
1697 "id" => ["type" => "varchar(40)", "not null" => "1", "primary" => "1", "comment" => ""],
1698 "secret" => ["type" => "text", "comment" => ""],
1699 "client_id" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => ["clients" => "client_id"]],
1700 "expires" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
1701 "scope" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
1702 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1705 "PRIMARY" => ["id"],
1708 $database["user"] = [
1709 "comment" => "The local users",
1711 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1712 "parent-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "The parent user that has full control about this user"],
1713 "guid" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
1714 "username" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1715 "password" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1716 "legacy_password" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Is the password hash double-hashed?"],
1717 "nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1718 "email" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1719 "openid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1720 "timezone" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => ""],
1721 "language" => ["type" => "varchar(32)", "not null" => "1", "default" => "en", "comment" => ""],
1722 "register_date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1723 "login_date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1724 "default-location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1725 "allow_location" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1726 "theme" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1727 "pubkey" => ["type" => "text", "comment" => ""],
1728 "prvkey" => ["type" => "text", "comment" => ""],
1729 "spubkey" => ["type" => "text", "comment" => ""],
1730 "sprvkey" => ["type" => "text", "comment" => ""],
1731 "verified" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1732 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1733 "blockwall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1734 "hidewall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1735 "blocktags" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1736 "unkmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1737 "cntunkmail" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""],
1738 "notify-flags" => ["type" => "smallint unsigned", "not null" => "1", "default" => "65535", "comment" => ""],
1739 "page-flags" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1740 "account-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1741 "prvnets" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1742 "pwdreset" => ["type" => "varchar(255)", "comment" => "Password reset request token"],
1743 "pwdreset_time" => ["type" => "datetime", "comment" => "Timestamp of the last password reset request"],
1744 "maxreq" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""],
1745 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1746 "account_removed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1747 "account_expired" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1748 "account_expires_on" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1749 "expire_notification_sent" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1750 "def_gid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1751 "allow_cid" => ["type" => "mediumtext", "comment" => ""],
1752 "allow_gid" => ["type" => "mediumtext", "comment" => ""],
1753 "deny_cid" => ["type" => "mediumtext", "comment" => ""],
1754 "deny_gid" => ["type" => "mediumtext", "comment" => ""],
1755 "openidserver" => ["type" => "text", "comment" => ""],
1758 "PRIMARY" => ["uid"],
1759 "nickname" => ["nickname(32)"],
1762 $database["userd"] = [
1763 "comment" => "Deleted usernames",
1765 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1766 "username" => ["type" => "varchar(255)", "not null" => "1", "comment" => ""],
1769 "PRIMARY" => ["id"],
1770 "username" => ["username(32)"],
1773 $database["workerqueue"] = [
1774 "comment" => "Background tasks queue entries",
1776 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "Auto incremented worker task id"],
1777 "parameter" => ["type" => "mediumblob", "comment" => "Task command"],
1778 "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Task priority"],
1779 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Creation date"],
1780 "pid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "Process id of the worker"],
1781 "executed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Execution date"],
1782 "done" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Marked when the task was done, will be deleted later"],
1785 "PRIMARY" => ["id"],
1787 "parameter" => ["parameter(64)"],
1788 "priority_created" => ["priority", "created"],
1789 "executed" => ["executed"],