3 * @file src/Database/DBStructure.php
5 namespace Friendica\Database;
7 use Friendica\Core\Config;
8 use Friendica\Database\DBM;
11 require_once "boot.php";
12 require_once 'include/dba.php';
13 require_once 'include/enotify.php';
14 require_once "include/text.php";
17 * @brief This class contain functions for the database management
19 * This class contains functions that doesn't need to know if pdo, mysqli or whatever is used.
23 * Converts all tables from MyISAM to InnoDB
25 public static function convertToInnoDB() {
26 $r = q("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `engine` = 'MyISAM' AND `table_schema` = '%s'",
27 dbesc(dba::database_name()));
29 if (!DBM::is_result($r)) {
30 echo t('There are no tables on MyISAM.')."\n";
34 foreach ($r AS $table) {
35 $sql = sprintf("ALTER TABLE `%s` engine=InnoDB;", dbesc($table['TABLE_NAME']));
38 $result = dba::e($sql);
39 if (!DBM::is_result($result)) {
40 self::printUpdateError($sql);
46 * send the email and do what is needed to do on update fails
48 * @param update_id (int) number of failed update
49 * @param error_message (str) error message
51 public static function updateFail($update_id, $error_message) {
54 //send the administrators an e-mail
55 $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
56 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
61 if (!DBM::is_result($adminlist)) {
62 logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_NORMAL);
68 // every admin could had different language
69 foreach ($adminlist as $admin) {
70 $lang = (($admin['language'])?$admin['language']:'en');
73 $preamble = deindent(t("
74 The friendica developers released update %s recently,
75 but when I tried to install it, something went terribly wrong.
76 This needs to be fixed soon and I can't do it alone. Please contact a
77 friendica developer if you can not help me on your own. My database might be invalid."));
78 $body = t("The error message is\n[pre]%s[/pre]");
79 $preamble = sprintf($preamble, $update_id);
80 $body = sprintf($body, $error_message);
83 'type' => SYSTEM_EMAIL,
84 'to_email' => $admin['email'],
85 'preamble' => $preamble,
92 logger("CRITICAL: Database structure update failed: ".$error_message);
96 private static function tableStructure($table) {
97 $structures = q("DESCRIBE `%s`", $table);
99 $full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table);
101 $indexes = q("SHOW INDEX FROM `%s`", $table);
103 $table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table);
105 if (DBM::is_result($table_status)) {
106 $table_status = $table_status[0];
114 if (DBM::is_result($indexes)) {
115 foreach ($indexes AS $index) {
116 if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
117 $indexdata[$index["Key_name"]] = ['UNIQUE'];
120 $column = $index["Column_name"];
122 if ($index["Sub_part"] != "") {
123 $column .= "(".$index["Sub_part"].")";
126 $indexdata[$index["Key_name"]][] = $column;
129 if (DBM::is_result($structures)) {
130 foreach ($structures AS $field) {
131 // Replace the default size values so that we don't have to define them
132 $search = ['tinyint(1)', 'tinyint(4)', 'smallint(5) unsigned', 'smallint(6)', 'mediumint(9)', 'bigint(20)', 'int(11)'];
133 $replace = ['boolean', 'tinyint', 'smallint unsigned', 'smallint', 'mediumint', 'bigint', 'int'];
134 $field["Type"] = str_replace($search, $replace, $field["Type"]);
136 $fielddata[$field["Field"]]["type"] = $field["Type"];
137 if ($field["Null"] == "NO") {
138 $fielddata[$field["Field"]]["not null"] = true;
141 if (isset($field["Default"])) {
142 $fielddata[$field["Field"]]["default"] = $field["Default"];
145 if ($field["Extra"] != "") {
146 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
149 if ($field["Key"] == "PRI") {
150 $fielddata[$field["Field"]]["primary"] = true;
154 if (DBM::is_result($full_columns)) {
155 foreach ($full_columns AS $column) {
156 $fielddata[$column["Field"]]["Collation"] = $column["Collation"];
157 $fielddata[$column["Field"]]["comment"] = $column["Comment"];
161 return ["fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status];
164 public static function printStructure() {
165 $database = self::definition();
167 echo "-- ------------------------------------------\n";
168 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
169 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
170 echo "-- ------------------------------------------\n\n\n";
171 foreach ($database AS $name => $structure) {
173 echo "-- TABLE $name\n";
175 self::createTable($name, $structure['fields'], true, false, $structure["indexes"]);
182 * @brief Print out database error messages
184 * @param string $message Message to be added to the error message
186 * @return string Error message
188 private static function printUpdateError($message) {
189 echo sprintf(t("\nError %d occurred during database update:\n%s\n"),
190 dba::errorNo(), dba::errorMessage());
192 return t('Errors encountered performing database changes: ').$message.EOL;
196 * Updates DB structure and returns eventual errors messages
198 * @param bool $verbose
199 * @param bool $action Whether to actually apply the update
200 * @param array $tables An array of the database tables
201 * @param array $definition An array of the definition tables
202 * @return string Empty string if the update is successful, error messages otherwise
204 public static function update($verbose, $action, array $tables = null, array $definition = null) {
206 Config::set('system', 'maintenance', 1);
207 Config::set('system', 'maintenance_reason', sprintf(t(': Database update'), DBM::date().' '.date('e')));
212 logger('updating structure', LOGGER_DEBUG);
214 // Get the current structure
217 if (is_null($tables)) {
218 $tables = q("SHOW TABLES");
221 if (DBM::is_result($tables)) {
222 foreach ($tables AS $table) {
223 $table = current($table);
225 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
226 $database[$table] = self::tableStructure($table);
230 // Get the definition
231 if (is_null($definition)) {
232 $definition = self::definition();
235 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
236 if ((version_compare(dba::server_info(), '5.7.4') >= 0) &&
237 !(strpos(dba::server_info(), 'MariaDB') !== false)) {
244 foreach ($definition AS $name => $structure) {
245 $is_new_table = False;
248 if (!isset($database[$name])) {
249 $r = self::createTable($name, $structure["fields"], $verbose, $action, $structure['indexes']);
250 if (!DBM::is_result($r)) {
251 $errors .= self::printUpdateError($name);
253 $is_new_table = True;
258 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
259 if (isset($database[$name]["indexes"][$indexname])) {
260 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
262 $current_index_definition = "__NOT_SET__";
264 $new_index_definition = implode(",",$fieldnames);
265 if ($current_index_definition != $new_index_definition) {
266 if ($fieldnames[0] == "UNIQUE") {
269 $temp_name = "temp-".$name;
276 * Drop the index if it isn't present in the definition
277 * or the definition differ from current status
278 * and index name doesn't start with "local_"
280 foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
281 $current_index_definition = implode(",",$fieldnames);
282 if (isset($structure["indexes"][$indexname])) {
283 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
285 $new_index_definition = "__NOT_SET__";
287 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
288 $sql2=self::dropIndex($indexname);
290 $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
296 // Compare the field structure field by field
297 foreach ($structure["fields"] AS $fieldname => $parameters) {
298 if (!isset($database[$name]["fields"][$fieldname])) {
299 $sql2=self::addTableField($fieldname, $parameters);
301 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
306 // Compare the field definition
307 $field_definition = $database[$name]["fields"][$fieldname];
309 // Remove the relation data that is used for the referential integrity
310 unset($parameters['relation']);
312 // We change the collation after the indexes had been changed.
313 // This is done to avoid index length problems.
314 // So here we always ensure that there is no need to change it.
315 unset($parameters['Collation']);
316 unset($field_definition['Collation']);
318 // Only update the comment when it is defined
319 if (!isset($parameters['comment'])) {
320 $parameters['comment'] = "";
323 $current_field_definition = implode(",", $field_definition);
324 $new_field_definition = implode(",", $parameters);
325 if ($current_field_definition != $new_field_definition) {
326 $sql2 = self::modifyTableField($fieldname, $parameters);
328 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
338 * Create the index if the index don't exists in database
339 * or the definition differ from the current status.
340 * Don't create keys if table is new
342 if (!$is_new_table) {
343 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
344 if (isset($database[$name]["indexes"][$indexname])) {
345 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
347 $current_index_definition = "__NOT_SET__";
349 $new_index_definition = implode(",",$fieldnames);
350 if ($current_index_definition != $new_index_definition) {
351 $sql2 = self::createIndex($indexname, $fieldnames);
353 // Fetch the "group by" fields for unique indexes
354 if ($fieldnames[0] == "UNIQUE") {
355 $group_by = self::groupBy($indexname, $fieldnames);
359 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
367 if (isset($database[$name]["table_status"]["Comment"])) {
368 if ($database[$name]["table_status"]["Comment"] != $structure['comment']) {
369 $sql2 = "COMMENT = '".dbesc($structure['comment'])."'";
372 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
379 if (isset($database[$name]["table_status"]["Collation"])) {
380 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
381 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
384 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
395 // Now have a look at the field collations
396 // Compare the field structure field by field
397 foreach ($structure["fields"] AS $fieldname => $parameters) {
398 // Compare the field definition
399 $field_definition = $database[$name]["fields"][$fieldname];
401 // Define the default collation if not given
402 if (!isset($parameters['Collation']) && !is_null($field_definition['Collation'])) {
403 $parameters['Collation'] = 'utf8mb4_general_ci';
405 $parameters['Collation'] = null;
408 if ($field_definition['Collation'] != $parameters['Collation']) {
409 $sql2 = self::modifyTableField($fieldname, $parameters);
410 if (($sql3 == "") || (substr($sql3, -2, 2) == "; ")) {
411 $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
420 if (substr($sql3, -2, 2) != "; ") {
425 if ($is_unique && $ignore == '') {
426 foreach ($database[$name]["fields"] AS $fieldname => $parameters) {
427 $field_list .= 'ANY_VALUE(`' . $fieldname . '`),';
429 $field_list = rtrim($field_list, ',');
433 // Ensure index conversion to unique removes duplicates
434 if ($is_unique && ($temp_name != $name)) {
436 echo "SET session old_alter_table=1;\n";
438 echo "DROP TABLE IF EXISTS `".$temp_name."`;\n";
439 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
445 if ($is_unique && ($temp_name != $name)) {
447 echo "SET session old_alter_table=0;\n";
449 echo "INSERT INTO `".$temp_name."` SELECT ".dba::any_value_fallback($field_list)." FROM `".$name."`".$group_by.";\n";
450 echo "DROP TABLE `".$name."`;\n";
451 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
457 Config::set('system', 'maintenance_reason', sprintf(t('%s: updating %s table.'), DBM::date().' '.date('e'), $name));
459 // Ensure index conversion to unique removes duplicates
460 if ($is_unique && ($temp_name != $name)) {
462 dba::e("SET session old_alter_table=1;");
464 dba::e("DROP TABLE IF EXISTS `".$temp_name."`;");
465 if (!DBM::is_result($r)) {
466 $errors .= self::printUpdateError($sql3);
470 $r = dba::e("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
471 if (!DBM::is_result($r)) {
472 $errors .= self::printUpdateError($sql3);
479 if (!DBM::is_result($r)) {
480 $errors .= self::printUpdateError($sql3);
482 if ($is_unique && ($temp_name != $name)) {
484 dba::e("SET session old_alter_table=0;");
486 $r = dba::e("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
487 if (!DBM::is_result($r)) {
488 $errors .= self::printUpdateError($sql3);
491 $r = dba::e("DROP TABLE `".$name."`;");
492 if (!DBM::is_result($r)) {
493 $errors .= self::printUpdateError($sql3);
496 $r = dba::e("RENAME TABLE `".$temp_name."` TO `".$name."`;");
497 if (!DBM::is_result($r)) {
498 $errors .= self::printUpdateError($sql3);
508 Config::set('system', 'maintenance', 0);
509 Config::set('system', 'maintenance_reason', '');
513 Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
515 Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
521 private static function FieldCommand($parameters, $create = true) {
522 $fieldstruct = $parameters["type"];
524 if (!is_null($parameters["Collation"])) {
525 $fieldstruct .= " COLLATE ".$parameters["Collation"];
528 if ($parameters["not null"]) {
529 $fieldstruct .= " NOT NULL";
532 if (isset($parameters["default"])) {
533 if (strpos(strtolower($parameters["type"]),"int")!==false) {
534 $fieldstruct .= " DEFAULT ".$parameters["default"];
536 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
539 if ($parameters["extra"] != "") {
540 $fieldstruct .= " ".$parameters["extra"];
543 if (!is_null($parameters["comment"])) {
544 $fieldstruct .= " COMMENT '".dbesc($parameters["comment"])."'";
547 /*if (($parameters["primary"] != "") && $create)
548 $fieldstruct .= " PRIMARY KEY";*/
550 return($fieldstruct);
553 private static function createTable($name, $fields, $verbose, $action, $indexes=null) {
558 foreach ($fields AS $fieldname => $field) {
559 $sql_rows[] = "`".dbesc($fieldname)."` ".self::FieldCommand($field);
560 if (x($field,'primary') && $field['primary']!='') {
561 $primary_keys[] = $fieldname;
565 if (!is_null($indexes)) {
566 foreach ($indexes AS $indexname => $fieldnames) {
567 $sql_index = self::createIndex($indexname, $fieldnames, "");
568 if (!is_null($sql_index)) {
569 $sql_rows[] = $sql_index;
574 $sql = implode(",\n\t", $sql_rows);
576 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
588 private static function addTableField($fieldname, $parameters) {
589 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), self::FieldCommand($parameters));
593 private static function modifyTableField($fieldname, $parameters) {
594 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), self::FieldCommand($parameters, false));
598 private static function dropIndex($indexname) {
599 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
603 private static function createIndex($indexname, $fieldnames, $method = "ADD") {
604 $method = strtoupper(trim($method));
605 if ($method!="" && $method!="ADD") {
606 throw new \Exception("Invalid parameter 'method' in self::createIndex(): '$method'");
609 if ($fieldnames[0] == "UNIQUE") {
610 array_shift($fieldnames);
611 $method .= ' UNIQUE';
615 foreach ($fieldnames AS $fieldname) {
620 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
621 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
623 $names .= "`".dbesc($fieldname)."`";
627 if ($indexname == "PRIMARY") {
628 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
632 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
636 private static function groupBy($indexname, $fieldnames) {
637 if ($fieldnames[0] != "UNIQUE") {
641 array_shift($fieldnames);
644 foreach ($fieldnames AS $fieldname) {
649 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
650 $names .= "`".dbesc($matches[1])."`";
652 $names .= "`".dbesc($fieldname)."`";
656 $sql = sprintf(" GROUP BY %s", $names);
660 public static function definition() {
663 $database["addon"] = [
664 "comment" => "registered addons",
666 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
667 "name" => ["type" => "varchar(190)", "not null" => "1", "default" => "", "comment" => ""],
668 "version" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
669 "installed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
670 "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
671 "timestamp" => ["type" => "bigint", "not null" => "1", "default" => "0", "comment" => ""],
672 "plugin_admin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
676 "name" => ["UNIQUE", "name"],
679 $database["attach"] = [
680 "comment" => "file attachments",
682 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
683 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
684 "hash" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
685 "filename" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
686 "filetype" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
687 "filesize" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
688 "data" => ["type" => "longblob", "not null" => "1", "comment" => ""],
689 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
690 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
691 "allow_cid" => ["type" => "mediumtext", "comment" => ""],
692 "allow_gid" => ["type" => "mediumtext", "comment" => ""],
693 "deny_cid" => ["type" => "mediumtext", "comment" => ""],
694 "deny_gid" => ["type" => "mediumtext", "comment" => ""],
700 $database["auth_codes"] = [
701 "comment" => "OAuth usage",
703 "id" => ["type" => "varchar(40)", "not null" => "1", "primary" => "1", "comment" => ""],
704 "client_id" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => ["clients" => "client_id"], "comment" => ""],
705 "redirect_uri" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
706 "expires" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
707 "scope" => ["type" => "varchar(250)", "not null" => "1", "default" => "", "comment" => ""],
713 $database["cache"] = [
714 "comment" => "Used to store different data that doesn't to be stored for a long time",
716 "k" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => ""],
717 "v" => ["type" => "mediumtext", "comment" => ""],
718 "expire_mode" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
719 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
723 "expire_mode_updated" => ["expire_mode", "updated"],
726 $database["challenge"] = [
729 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
730 "challenge" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
731 "dfrn-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
732 "expire" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
733 "type" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
734 "last_update" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
740 $database["clients"] = [
741 "comment" => "OAuth usage",
743 "client_id" => ["type" => "varchar(20)", "not null" => "1", "primary" => "1", "comment" => ""],
744 "pw" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => ""],
745 "redirect_uri" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
746 "name" => ["type" => "text", "comment" => ""],
747 "icon" => ["type" => "text", "comment" => ""],
748 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
751 "PRIMARY" => ["client_id"],
754 $database["config"] = [
755 "comment" => "main configuration storage",
757 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
758 "cat" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""],
759 "k" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""],
760 "v" => ["type" => "mediumtext", "comment" => ""],
764 "cat_k" => ["UNIQUE", "cat", "k"],
767 $database["contact"] = [
768 "comment" => "contact table",
770 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
771 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
772 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
773 "self" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
774 "remote_self" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
775 "rel" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
776 "duplex" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
777 "network" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
778 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
779 "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
780 "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
781 "about" => ["type" => "text", "comment" => ""],
782 "keywords" => ["type" => "text", "comment" => ""],
783 "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
784 "xmpp" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
785 "attag" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
786 "avatar" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
787 "photo" => ["type" => "text", "comment" => ""],
788 "thumb" => ["type" => "text", "comment" => ""],
789 "micro" => ["type" => "text", "comment" => ""],
790 "site-pubkey" => ["type" => "text", "comment" => ""],
791 "issued-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
792 "dfrn-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
793 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
794 "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
795 "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
796 "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
797 "pubkey" => ["type" => "text", "comment" => ""],
798 "prvkey" => ["type" => "text", "comment" => ""],
799 "batch" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
800 "request" => ["type" => "text", "comment" => ""],
801 "notify" => ["type" => "text", "comment" => ""],
802 "poll" => ["type" => "text", "comment" => ""],
803 "confirm" => ["type" => "text", "comment" => ""],
804 "poco" => ["type" => "text", "comment" => ""],
805 "aes_allow" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
806 "ret-aes" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
807 "usehub" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
808 "subhub" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
809 "hub-verify" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
810 "last-update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
811 "success_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
812 "failure_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
813 "name-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
814 "uri-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
815 "avatar-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
816 "term-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
817 "last-item" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
818 "priority" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
819 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
820 "readonly" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
821 "writable" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
822 "forum" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
823 "prv" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
824 "contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
825 "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
826 "archive" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
827 "pending" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
828 "rating" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
829 "reason" => ["type" => "text", "comment" => ""],
830 "closeness" => ["type" => "tinyint", "not null" => "1", "default" => "99", "comment" => ""],
831 "info" => ["type" => "mediumtext", "comment" => ""],
832 "profile-id" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
833 "bdyear" => ["type" => "varchar(4)", "not null" => "1", "default" => "", "comment" => ""],
834 "bd" => ["type" => "date", "not null" => "1", "default" => "0001-01-01", "comment" => ""],
835 "notify_new_posts" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
836 "fetch_further_information" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
837 "ffi_keyword_blacklist" => ["type" => "text", "comment" => ""],
841 "uid_name" => ["uid", "name(190)"],
842 "self_uid" => ["self", "uid"],
843 "alias_uid" => ["alias(32)", "uid"],
844 "pending_uid" => ["pending", "uid"],
845 "blocked_uid" => ["blocked", "uid"],
846 "uid_rel_network_poll" => ["uid", "rel", "network(4)", "poll(64)", "archive"],
847 "uid_network_batch" => ["uid", "network(4)", "batch(64)"],
848 "addr_uid" => ["addr(32)", "uid"],
849 "nurl_uid" => ["nurl(32)", "uid"],
850 "nick_uid" => ["nick(32)", "uid"],
851 "dfrn-id" => ["dfrn-id(64)"],
852 "issued-id" => ["issued-id(64)"],
855 $database["conv"] = [
856 "comment" => "private messages",
858 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
859 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
860 "recips" => ["type" => "text", "comment" => ""],
861 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
862 "creator" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
863 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
864 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
865 "subject" => ["type" => "text", "comment" => ""],
872 $database["conversation"] = [
873 "comment" => "Raw data and structure information for messages",
875 "item-uri" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => ""],
876 "reply-to-uri" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""],
877 "conversation-uri" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""],
878 "conversation-href" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""],
879 "protocol" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
880 "source" => ["type" => "mediumtext", "comment" => ""],
881 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
884 "PRIMARY" => ["item-uri"],
885 "conversation-uri" => ["conversation-uri"],
886 "received" => ["received"],
889 $database["event"] = [
890 "comment" => "Events",
892 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
893 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
894 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
895 "cid" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
896 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
897 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
898 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
899 "start" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
900 "finish" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
901 "summary" => ["type" => "text", "comment" => ""],
902 "desc" => ["type" => "text", "comment" => ""],
903 "location" => ["type" => "text", "comment" => ""],
904 "type" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
905 "nofinish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
906 "adjust" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
907 "ignore" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
908 "allow_cid" => ["type" => "mediumtext", "comment" => ""],
909 "allow_gid" => ["type" => "mediumtext", "comment" => ""],
910 "deny_cid" => ["type" => "mediumtext", "comment" => ""],
911 "deny_gid" => ["type" => "mediumtext", "comment" => ""],
915 "uid_start" => ["uid", "start"],
918 $database["fcontact"] = [
919 "comment" => "Diaspora compatible contacts - used in the Diaspora implementation",
921 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
922 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
923 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
924 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
925 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
926 "request" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
927 "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
928 "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
929 "batch" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
930 "notify" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
931 "poll" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
932 "confirm" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
933 "priority" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
934 "network" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
935 "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
936 "pubkey" => ["type" => "text", "comment" => ""],
937 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
941 "addr" => ["addr(32)"],
942 "url" => ["UNIQUE", "url(190)"],
945 $database["fsuggest"] = [
946 "comment" => "friend suggestion stuff",
948 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
949 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
950 "cid" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
951 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
952 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
953 "request" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
954 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
955 "note" => ["type" => "text", "comment" => ""],
956 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
962 $database["gcign"] = [
963 "comment" => "contacts ignored by friend suggestions",
965 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
966 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
967 "gcid" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""],
975 $database["gcontact"] = [
976 "comment" => "global contacts",
978 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
979 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
980 "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
981 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
982 "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
983 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
984 "connect" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
985 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
986 "updated" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
987 "last_contact" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
988 "last_failure" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
989 "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
990 "about" => ["type" => "text", "comment" => ""],
991 "keywords" => ["type" => "text", "comment" => ""],
992 "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
993 "birthday" => ["type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01", "comment" => ""],
994 "community" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
995 "contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "-1", "comment" => ""],
996 "hide" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
997 "nsfw" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
998 "network" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
999 "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1000 "notify" => ["type" => "text", "comment" => ""],
1001 "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1002 "generation" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
1003 "server_url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1006 "PRIMARY" => ["id"],
1007 "nurl" => ["UNIQUE", "nurl(190)"],
1008 "name" => ["name(64)"],
1009 "nick" => ["nick(32)"],
1010 "addr" => ["addr(64)"],
1011 "hide_network_updated" => ["hide", "network(4)", "updated"],
1012 "updated" => ["updated"],
1015 $database["glink"] = [
1016 "comment" => "'friends of friends' linkages derived from poco",
1018 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1019 "cid" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1020 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1021 "gcid" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""],
1022 "zcid" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""],
1023 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1026 "PRIMARY" => ["id"],
1027 "cid_uid_gcid_zcid" => ["UNIQUE", "cid","uid","gcid","zcid"],
1031 $database["group"] = [
1032 "comment" => "privacy groups, group info",
1034 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1035 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1036 "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1037 "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1038 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1041 "PRIMARY" => ["id"],
1045 $database["group_member"] = [
1046 "comment" => "privacy groups, member info",
1048 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1049 "gid" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["group" => "id"], "comment" => ""],
1050 "contact-id" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1053 "PRIMARY" => ["id"],
1054 "contactid" => ["contact-id"],
1055 "gid_contactid" => ["UNIQUE", "gid", "contact-id"],
1058 $database["gserver"] = [
1059 "comment" => "Global servers",
1061 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1062 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1063 "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1064 "version" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1065 "site_name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1066 "info" => ["type" => "text", "comment" => ""],
1067 "register_policy" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
1068 "registered-users" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
1069 "poco" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1070 "noscrape" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1071 "network" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1072 "platform" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1073 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1074 "last_poco_query" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1075 "last_contact" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1076 "last_failure" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1079 "PRIMARY" => ["id"],
1080 "nurl" => ["UNIQUE", "nurl(190)"],
1083 $database["hook"] = [
1084 "comment" => "addon hook registry",
1086 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1087 "hook" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1088 "file" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1089 "function" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1090 "priority" => ["type" => "smallint", "not null" => "1", "default" => "0", "comment" => ""],
1093 "PRIMARY" => ["id"],
1094 "hook_file_function" => ["UNIQUE", "hook(50)","file(80)","function(60)"],
1097 $database["intro"] = [
1100 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1101 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1102 "fid" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["fcontact" => "id"], "comment" => ""],
1103 "contact-id" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1104 "knowyou" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1105 "duplex" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1106 "note" => ["type" => "text", "comment" => ""],
1107 "hash" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1108 "datetime" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1109 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
1110 "ignore" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1113 "PRIMARY" => ["id"],
1116 $database["item"] = [
1117 "comment" => "All posts",
1119 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => ["thread" => "iid"]],
1120 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1121 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1122 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1123 "contact-id" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1124 "gcontact-id" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""],
1125 "type" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1126 "wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1127 "gravity" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
1128 "parent" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1129 "parent-uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1130 "extid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1131 "thr-parent" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1132 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1133 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1134 "commented" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1135 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1136 "changed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1137 "owner-id" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1138 "owner-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1139 "owner-link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1140 "owner-avatar" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1141 "author-id" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1142 "author-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1143 "author-link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1144 "author-avatar" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1145 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1146 "body" => ["type" => "mediumtext", "comment" => ""],
1147 "app" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1148 "verb" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1149 "object-type" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1150 "object" => ["type" => "text", "comment" => ""],
1151 "target-type" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1152 "target" => ["type" => "text", "comment" => ""],
1153 "postopts" => ["type" => "text", "comment" => ""],
1154 "plink" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1155 "resource-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1156 "event-id" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["event" => "id"], "comment" => ""],
1157 "tag" => ["type" => "mediumtext", "comment" => ""],
1158 "attach" => ["type" => "mediumtext", "comment" => ""],
1159 "inform" => ["type" => "mediumtext", "comment" => ""],
1160 "file" => ["type" => "mediumtext", "comment" => ""],
1161 "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1162 "coord" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1163 "allow_cid" => ["type" => "mediumtext", "comment" => ""],
1164 "allow_gid" => ["type" => "mediumtext", "comment" => ""],
1165 "deny_cid" => ["type" => "mediumtext", "comment" => ""],
1166 "deny_gid" => ["type" => "mediumtext", "comment" => ""],
1167 "private" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1168 "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1169 "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1170 "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1171 "spam" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1172 "starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1173 "bookmark" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1174 "unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
1175 "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1176 "origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1177 "forum_mode" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
1178 "mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1179 "network" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1180 "rendered-hash" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1181 "rendered-html" => ["type" => "mediumtext", "comment" => ""],
1182 "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1185 "PRIMARY" => ["id"],
1186 "guid" => ["guid(191)"],
1187 "uri" => ["uri(191)"],
1188 "parent" => ["parent"],
1189 "parent-uri" => ["parent-uri(191)"],
1190 "extid" => ["extid(191)"],
1191 "uid_id" => ["uid","id"],
1192 "uid_contactid_id" => ["uid","contact-id","id"],
1193 "uid_created" => ["uid","created"],
1194 "uid_unseen_contactid" => ["uid","unseen","contact-id"],
1195 "uid_network_received" => ["uid","network(4)","received"],
1196 "uid_network_commented" => ["uid","network(4)","commented"],
1197 "uid_thrparent" => ["uid","thr-parent(190)"],
1198 "uid_parenturi" => ["uid","parent-uri(190)"],
1199 "uid_contactid_created" => ["uid","contact-id","created"],
1200 "authorid_created" => ["author-id","created"],
1201 "ownerid" => ["owner-id"],
1202 "uid_uri" => ["uid", "uri(190)"],
1203 "resource-id" => ["resource-id(191)"],
1204 "contactid_allowcid_allowpid_denycid_denygid" => ["contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"], //
1205 "uid_type_changed" => ["uid","type(190)","changed"],
1206 "contactid_verb" => ["contact-id","verb(190)"],
1207 "deleted_changed" => ["deleted","changed"],
1208 "uid_wall_changed" => ["uid","wall","changed"],
1209 "uid_eventid" => ["uid","event-id"],
1210 "uid_authorlink" => ["uid","author-link(190)"],
1211 "uid_ownerlink" => ["uid","owner-link(190)"],
1214 $database["locks"] = [
1217 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1218 "name" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => ""],
1219 "locked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1220 "pid" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
1223 "PRIMARY" => ["id"],
1226 $database["mail"] = [
1227 "comment" => "private messages",
1229 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1230 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1231 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1232 "from-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1233 "from-photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1234 "from-url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1235 "contact-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => ["contact" => "id"], "comment" => ""],
1236 "convid" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["conv" => "id"], "comment" => ""],
1237 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1238 "body" => ["type" => "mediumtext", "comment" => ""],
1239 "seen" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1240 "reply" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1241 "replied" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1242 "unknown" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1243 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1244 "parent-uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1245 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1248 "PRIMARY" => ["id"],
1249 "uid_seen" => ["uid", "seen"],
1250 "convid" => ["convid"],
1251 "uri" => ["uri(64)"],
1252 "parent-uri" => ["parent-uri(64)"],
1253 "contactid" => ["contact-id(32)"],
1256 $database["mailacct"] = [
1257 "comment" => "Mail account data for fetching mails",
1259 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1260 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1261 "server" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1262 "port" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1263 "ssltype" => ["type" => "varchar(16)", "not null" => "1", "default" => "", "comment" => ""],
1264 "mailbox" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1265 "user" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1266 "pass" => ["type" => "text", "comment" => ""],
1267 "reply_to" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1268 "action" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
1269 "movetofolder" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1270 "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1271 "last_check" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1274 "PRIMARY" => ["id"],
1277 $database["manage"] = [
1278 "comment" => "table of accounts that can manage each other",
1280 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1281 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1282 "mid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1285 "PRIMARY" => ["id"],
1286 "uid_mid" => ["UNIQUE", "uid","mid"],
1289 $database["notify"] = [
1290 "comment" => "notifications",
1292 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1293 "hash" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
1294 "type" => ["type" => "smallint", "not null" => "1", "default" => "0", "comment" => ""],
1295 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1296 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1297 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1298 "date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1299 "msg" => ["type" => "mediumtext", "comment" => ""],
1300 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1301 "link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1302 "iid" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1303 "parent" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1304 "seen" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1305 "verb" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1306 "otype" => ["type" => "varchar(16)", "not null" => "1", "default" => "", "comment" => ""],
1307 "name_cache" => ["type" => "tinytext", "comment" => ""],
1308 "msg_cache" => ["type" => "mediumtext", "comment" => ""]
1311 "PRIMARY" => ["id"],
1312 "hash_uid" => ["hash", "uid"],
1313 "seen_uid_date" => ["seen", "uid", "date"],
1314 "uid_date" => ["uid", "date"],
1315 "uid_type_link" => ["uid", "type", "link(190)"],
1318 $database["notify-threads"] = [
1321 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1322 "notify-id" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["notify" => "id"], "comment" => ""],
1323 "master-parent-item" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1324 "parent-item" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
1325 "receiver-uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1328 "PRIMARY" => ["id"],
1331 $database["oembed"] = [
1332 "comment" => "cache for OEmbed queries",
1334 "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => ""],
1335 "maxwidth" => ["type" => "mediumint", "not null" => "1", "primary" => "1", "comment" => ""],
1336 "content" => ["type" => "mediumtext", "comment" => ""],
1337 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1340 "PRIMARY" => ["url", "maxwidth"],
1341 "created" => ["created"],
1344 $database["parsed_url"] = [
1345 "comment" => "cache for 'parse_url' queries",
1347 "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => ""],
1348 "guessing" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => ""],
1349 "oembed" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => ""],
1350 "content" => ["type" => "mediumtext", "comment" => ""],
1351 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1354 "PRIMARY" => ["url", "guessing", "oembed"],
1355 "created" => ["created"],
1358 $database["participation"] = [
1359 "comment" => "Storage for participation messages from Diaspora",
1361 "iid" => ["type" => "int", "not null" => "1", "primary" => "1", "relation" => ["item" => "id"], "comment" => ""],
1362 "server" => ["type" => "varchar(60)", "not null" => "1", "primary" => "1", "comment" => ""],
1363 "cid" => ["type" => "int", "not null" => "1", "relation" => ["contact" => "id"], "comment" => ""],
1364 "fid" => ["type" => "int", "not null" => "1", "relation" => ["fcontact" => "id"], "comment" => ""],
1367 "PRIMARY" => ["iid", "server"]
1370 $database["pconfig"] = [
1371 "comment" => "personal (per user) configuration storage",
1373 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1374 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1375 "cat" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""],
1376 "k" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""],
1377 "v" => ["type" => "mediumtext", "comment" => ""],
1380 "PRIMARY" => ["id"],
1381 "uid_cat_k" => ["UNIQUE", "uid", "cat", "k"],
1384 $database["photo"] = [
1385 "comment" => "photo storage",
1387 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1388 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1389 "contact-id" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1390 "guid" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
1391 "resource-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1392 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1393 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1394 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1395 "desc" => ["type" => "text", "comment" => ""],
1396 "album" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1397 "filename" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1398 "type" => ["type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"],
1399 "height" => ["type" => "smallint", "not null" => "1", "default" => "0", "comment" => ""],
1400 "width" => ["type" => "smallint", "not null" => "1", "default" => "0", "comment" => ""],
1401 "datasize" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
1402 "data" => ["type" => "mediumblob", "not null" => "1", "comment" => ""],
1403 "scale" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
1404 "profile" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1405 "allow_cid" => ["type" => "mediumtext", "comment" => ""],
1406 "allow_gid" => ["type" => "mediumtext", "comment" => ""],
1407 "deny_cid" => ["type" => "mediumtext", "comment" => ""],
1408 "deny_gid" => ["type" => "mediumtext", "comment" => ""],
1411 "PRIMARY" => ["id"],
1412 "contactid" => ["contact-id"],
1413 "uid_contactid" => ["uid", "contact-id"],
1414 "uid_profile" => ["uid", "profile"],
1415 "uid_album_scale_created" => ["uid", "album(32)", "scale", "created"],
1416 "uid_album_resource-id_created" => ["uid", "album(32)", "resource-id(64)", "created"],
1417 "resource-id" => ["resource-id(64)"],
1420 $database["poll"] = [
1421 "comment" => "Currently unused table for storing poll results",
1423 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1424 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1425 "q0" => ["type" => "text", "comment" => ""],
1426 "q1" => ["type" => "text", "comment" => ""],
1427 "q2" => ["type" => "text", "comment" => ""],
1428 "q3" => ["type" => "text", "comment" => ""],
1429 "q4" => ["type" => "text", "comment" => ""],
1430 "q5" => ["type" => "text", "comment" => ""],
1431 "q6" => ["type" => "text", "comment" => ""],
1432 "q7" => ["type" => "text", "comment" => ""],
1433 "q8" => ["type" => "text", "comment" => ""],
1434 "q9" => ["type" => "text", "comment" => ""],
1437 "PRIMARY" => ["id"],
1441 $database["poll_result"] = [
1442 "comment" => "data for polls - currently unused",
1444 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1445 "poll_id" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["poll" => "id"]],
1446 "choice" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
1449 "PRIMARY" => ["id"],
1450 "poll_id" => ["poll_id"],
1453 $database["process"] = [
1454 "comment" => "Currently running system processes",
1456 "pid" => ["type" => "int", "not null" => "1", "primary" => "1", "comment" => ""],
1457 "command" => ["type" => "varbinary(32)", "not null" => "1", "default" => "", "comment" => ""],
1458 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1461 "PRIMARY" => ["pid"],
1462 "command" => ["command"],
1465 $database["profile"] = [
1466 "comment" => "user profiles data",
1468 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1469 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1470 "profile-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1471 "is-default" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1472 "hide-friends" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1473 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1474 "pdesc" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1475 "dob" => ["type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01", "comment" => ""],
1476 "address" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1477 "locality" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1478 "region" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1479 "postal-code" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1480 "country-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1481 "hometown" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1482 "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1483 "marital" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1484 "with" => ["type" => "text", "comment" => ""],
1485 "howlong" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1486 "sexual" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1487 "politic" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1488 "religion" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1489 "pub_keywords" => ["type" => "text", "comment" => ""],
1490 "prv_keywords" => ["type" => "text", "comment" => ""],
1491 "likes" => ["type" => "text", "comment" => ""],
1492 "dislikes" => ["type" => "text", "comment" => ""],
1493 "about" => ["type" => "text", "comment" => ""],
1494 "summary" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1495 "music" => ["type" => "text", "comment" => ""],
1496 "book" => ["type" => "text", "comment" => ""],
1497 "tv" => ["type" => "text", "comment" => ""],
1498 "film" => ["type" => "text", "comment" => ""],
1499 "interest" => ["type" => "text", "comment" => ""],
1500 "romance" => ["type" => "text", "comment" => ""],
1501 "work" => ["type" => "text", "comment" => ""],
1502 "education" => ["type" => "text", "comment" => ""],
1503 "contact" => ["type" => "text", "comment" => ""],
1504 "homepage" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1505 "xmpp" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1506 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1507 "thumb" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1508 "publish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1509 "net-publish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1512 "PRIMARY" => ["id"],
1513 "uid_is-default" => ["uid", "is-default"],
1516 $database["profile_check"] = [
1517 "comment" => "DFRN remote auth use",
1519 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1520 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1521 "cid" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1522 "dfrn_id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1523 "sec" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1524 "expire" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
1527 "PRIMARY" => ["id"],
1530 $database["push_subscriber"] = [
1531 "comment" => "Used for OStatus: Contains feed subscribers",
1533 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1534 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1535 "callback_url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1536 "topic" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1537 "nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1538 "push" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
1539 "last_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1540 "secret" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1543 "PRIMARY" => ["id"],
1546 $database["queue"] = [
1547 "comment" => "Queue for messages that couldn't be delivered",
1549 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1550 "cid" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1551 "network" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1552 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1553 "last" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1554 "content" => ["type" => "mediumtext", "comment" => ""],
1555 "batch" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1558 "PRIMARY" => ["id"],
1560 "created" => ["created"],
1562 "network" => ["network"],
1563 "batch" => ["batch"],
1566 $database["register"] = [
1567 "comment" => "registrations requiring admin approval",
1569 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1570 "hash" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1571 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1572 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1573 "password" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1574 "language" => ["type" => "varchar(16)", "not null" => "1", "default" => "", "comment" => ""],
1575 "note" => ["type" => "text", "comment" => ""],
1578 "PRIMARY" => ["id"],
1581 $database["search"] = [
1584 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1585 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1586 "term" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1589 "PRIMARY" => ["id"],
1593 $database["session"] = [
1594 "comment" => "web session storage",
1596 "id" => ["type" => "bigint", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1597 "sid" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""],
1598 "data" => ["type" => "text", "comment" => ""],
1599 "expire" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
1602 "PRIMARY" => ["id"],
1603 "sid" => ["sid(64)"],
1604 "expire" => ["expire"],
1607 $database["sign"] = [
1608 "comment" => "Diaspora signatures",
1610 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1611 "iid" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1612 "signed_text" => ["type" => "mediumtext", "comment" => ""],
1613 "signature" => ["type" => "text", "comment" => ""],
1614 "signer" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1617 "PRIMARY" => ["id"],
1618 "iid" => ["UNIQUE", "iid"],
1621 $database["term"] = [
1622 "comment" => "item taxonomy (categories, tags, etc.) table",
1624 "tid" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1625 "oid" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1626 "otype" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
1627 "type" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
1628 "term" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1629 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1630 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1631 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1632 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1633 "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1634 "aid" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
1635 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1638 "PRIMARY" => ["tid"],
1639 "oid_otype_type_term" => ["oid","otype","type","term(32)"],
1640 "uid_otype_type_term_global_created" => ["uid","otype","type","term(32)","global","created"],
1641 "uid_otype_type_url" => ["uid","otype","type","url(64)"],
1642 "guid" => ["guid(64)"],
1645 $database["thread"] = [
1646 "comment" => "Thread related data",
1648 "iid" => ["type" => "int", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["item" => "id"], "comment" => ""],
1649 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1650 "contact-id" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1651 "gcontact-id" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""],
1652 "owner-id" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1653 "author-id" => ["type" => "int", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1654 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1655 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1656 "commented" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1657 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1658 "changed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1659 "wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1660 "private" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1661 "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1662 "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1663 "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1664 "spam" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1665 "starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1666 "ignored" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1667 "bookmark" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1668 "unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
1669 "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1670 "origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1671 "forum_mode" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
1672 "mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1673 "network" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1676 "PRIMARY" => ["iid"],
1677 "uid_network_commented" => ["uid","network","commented"],
1678 "uid_network_created" => ["uid","network","created"],
1679 "uid_contactid_commented" => ["uid","contact-id","commented"],
1680 "uid_contactid_created" => ["uid","contact-id","created"],
1681 "contactid" => ["contact-id"],
1682 "ownerid" => ["owner-id"],
1683 "authorid" => ["author-id"],
1684 "uid_created" => ["uid","created"],
1685 "uid_commented" => ["uid","commented"],
1686 "uid_wall_created" => ["uid","wall","created"],
1687 "private_wall_commented" => ["private","wall","commented"],
1690 $database["tokens"] = [
1691 "comment" => "OAuth usage",
1693 "id" => ["type" => "varchar(40)", "not null" => "1", "primary" => "1", "comment" => ""],
1694 "secret" => ["type" => "text", "comment" => ""],
1695 "client_id" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => ["clients" => "client_id"]],
1696 "expires" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
1697 "scope" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
1698 "uid" => ["type" => "mediumint", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1701 "PRIMARY" => ["id"],
1704 $database["user"] = [
1705 "comment" => "The local users",
1707 "uid" => ["type" => "mediumint", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1708 "guid" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
1709 "username" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1710 "password" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1711 "nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1712 "email" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1713 "openid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1714 "timezone" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => ""],
1715 "language" => ["type" => "varchar(32)", "not null" => "1", "default" => "en", "comment" => ""],
1716 "register_date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1717 "login_date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1718 "default-location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1719 "allow_location" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1720 "theme" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1721 "pubkey" => ["type" => "text", "comment" => ""],
1722 "prvkey" => ["type" => "text", "comment" => ""],
1723 "spubkey" => ["type" => "text", "comment" => ""],
1724 "sprvkey" => ["type" => "text", "comment" => ""],
1725 "verified" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1726 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1727 "blockwall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1728 "hidewall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1729 "blocktags" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1730 "unkmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1731 "cntunkmail" => ["type" => "int", "not null" => "1", "default" => "10", "comment" => ""],
1732 "notify-flags" => ["type" => "smallint unsigned", "not null" => "1", "default" => "65535", "comment" => ""],
1733 "page-flags" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
1734 "account-type" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
1735 "prvnets" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1736 "pwdreset" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1737 "maxreq" => ["type" => "int", "not null" => "1", "default" => "10", "comment" => ""],
1738 "expire" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
1739 "account_removed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1740 "account_expired" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1741 "account_expires_on" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1742 "expire_notification_sent" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1743 "def_gid" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
1744 "allow_cid" => ["type" => "mediumtext", "comment" => ""],
1745 "allow_gid" => ["type" => "mediumtext", "comment" => ""],
1746 "deny_cid" => ["type" => "mediumtext", "comment" => ""],
1747 "deny_gid" => ["type" => "mediumtext", "comment" => ""],
1748 "openidserver" => ["type" => "text", "comment" => ""],
1751 "PRIMARY" => ["uid"],
1752 "nickname" => ["nickname(32)"],
1755 $database["userd"] = [
1756 "comment" => "Deleted usernames",
1758 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1759 "username" => ["type" => "varchar(255)", "not null" => "1", "comment" => ""],
1762 "PRIMARY" => ["id"],
1763 "username" => ["username(32)"],
1766 $database["workerqueue"] = [
1767 "comment" => "Background tasks queue entries",
1769 "id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "Auto incremented worker task id"],
1770 "parameter" => ["type" => "text", "comment" => "Task command"],
1771 "priority" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Task priority"],
1772 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Creation date"],
1773 "pid" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => "Process id of the worker"],
1774 "executed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Execution date"],
1775 "done" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Marked when the task was done, will be deleted later"],
1778 "PRIMARY" => ["id"],
1780 "parameter" => ["parameter(64)"],
1781 "priority_created" => ["priority", "created"],
1782 "executed" => ["executed"],