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 array $tables An array of the database tables
203 * @param array $definition An array of the definition tables
204 * @return string Empty string if the update is successful, error messages otherwise
206 public static function update($verbose, $action, array $tables = null, array $definition = null) {
208 Config::set('system', 'maintenance', 1);
209 Config::set('system', 'maintenance_reason', L10n::t(': Database update', DBM::date().' '.date('e')));
214 logger('updating structure', LOGGER_DEBUG);
216 // Get the current structure
219 if (is_null($tables)) {
220 $tables = q("SHOW TABLES");
223 if (DBM::is_result($tables)) {
224 foreach ($tables AS $table) {
225 $table = current($table);
227 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
228 $database[$table] = self::tableStructure($table);
232 // Get the definition
233 if (is_null($definition)) {
234 $definition = self::definition();
237 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
238 if ((version_compare(dba::server_info(), '5.7.4') >= 0) &&
239 !(strpos(dba::server_info(), 'MariaDB') !== false)) {
246 foreach ($definition AS $name => $structure) {
247 $is_new_table = false;
252 if (!isset($database[$name])) {
253 $r = self::createTable($name, $structure["fields"], $verbose, $action, $structure['indexes']);
254 if (!DBM::is_result($r)) {
255 $errors .= self::printUpdateError($name);
257 $is_new_table = true;
259 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
260 if (isset($database[$name]["indexes"][$indexname])) {
261 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
263 $current_index_definition = "__NOT_SET__";
265 $new_index_definition = implode(",",$fieldnames);
266 if ($current_index_definition != $new_index_definition) {
267 if ($fieldnames[0] == "UNIQUE") {
270 $temp_name = "temp-".$name;
277 * Drop the index if it isn't present in the definition
278 * or the definition differ from current status
279 * and index name doesn't start with "local_"
281 foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
282 $current_index_definition = implode(",",$fieldnames);
283 if (isset($structure["indexes"][$indexname])) {
284 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
286 $new_index_definition = "__NOT_SET__";
288 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
289 $sql2=self::dropIndex($indexname);
291 $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
297 // Compare the field structure field by field
298 foreach ($structure["fields"] AS $fieldname => $parameters) {
299 if (!isset($database[$name]["fields"][$fieldname])) {
300 $sql2=self::addTableField($fieldname, $parameters);
302 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
307 // Compare the field definition
308 $field_definition = $database[$name]["fields"][$fieldname];
310 // Remove the relation data that is used for the referential integrity
311 unset($parameters['relation']);
313 // We change the collation after the indexes had been changed.
314 // This is done to avoid index length problems.
315 // So here we always ensure that there is no need to change it.
316 unset($parameters['Collation']);
317 unset($field_definition['Collation']);
319 // Only update the comment when it is defined
320 if (!isset($parameters['comment'])) {
321 $parameters['comment'] = "";
324 $current_field_definition = implode(",", $field_definition);
325 $new_field_definition = implode(",", $parameters);
326 if ($current_field_definition != $new_field_definition) {
327 $sql2 = self::modifyTableField($fieldname, $parameters);
329 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
339 * Create the index if the index don't exists in database
340 * or the definition differ from the current status.
341 * Don't create keys if table is new
343 if (!$is_new_table) {
344 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
345 if (isset($database[$name]["indexes"][$indexname])) {
346 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
348 $current_index_definition = "__NOT_SET__";
350 $new_index_definition = implode(",",$fieldnames);
351 if ($current_index_definition != $new_index_definition) {
352 $sql2 = self::createIndex($indexname, $fieldnames);
354 // Fetch the "group by" fields for unique indexes
355 if ($fieldnames[0] == "UNIQUE") {
356 $group_by = self::groupBy($indexname, $fieldnames);
360 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
368 if (isset($database[$name]["table_status"]["Comment"])) {
369 if ($database[$name]["table_status"]["Comment"] != $structure['comment']) {
370 $sql2 = "COMMENT = '".dbesc($structure['comment'])."'";
373 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
380 if (isset($database[$name]["table_status"]["Collation"])) {
381 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
382 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
385 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
396 // Now have a look at the field collations
397 // Compare the field structure field by field
398 foreach ($structure["fields"] AS $fieldname => $parameters) {
399 // Compare the field definition
400 $field_definition = $database[$name]["fields"][$fieldname];
402 // Define the default collation if not given
403 if (!isset($parameters['Collation']) && !is_null($field_definition['Collation'])) {
404 $parameters['Collation'] = 'utf8mb4_general_ci';
406 $parameters['Collation'] = null;
409 if ($field_definition['Collation'] != $parameters['Collation']) {
410 $sql2 = self::modifyTableField($fieldname, $parameters);
411 if (($sql3 == "") || (substr($sql3, -2, 2) == "; ")) {
412 $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
421 if (substr($sql3, -2, 2) != "; ") {
426 if ($is_unique && $ignore == '') {
427 foreach ($database[$name]["fields"] AS $fieldname => $parameters) {
428 $field_list .= 'ANY_VALUE(`' . $fieldname . '`),';
430 $field_list = rtrim($field_list, ',');
434 // Ensure index conversion to unique removes duplicates
435 if ($is_unique && ($temp_name != $name)) {
437 echo "SET session old_alter_table=1;\n";
439 echo "DROP TABLE IF EXISTS `".$temp_name."`;\n";
440 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
446 if ($is_unique && ($temp_name != $name)) {
448 echo "SET session old_alter_table=0;\n";
450 echo "INSERT INTO `".$temp_name."` SELECT ".dba::any_value_fallback($field_list)." FROM `".$name."`".$group_by.";\n";
451 echo "DROP TABLE `".$name."`;\n";
452 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
458 Config::set('system', 'maintenance_reason', L10n::t('%s: updating %s table.', DBM::date().' '.date('e'), $name));
460 // Ensure index conversion to unique removes duplicates
461 if ($is_unique && ($temp_name != $name)) {
463 dba::e("SET session old_alter_table=1;");
465 $r = dba::e("DROP TABLE IF EXISTS `".$temp_name."`;");
466 if (!DBM::is_result($r)) {
467 $errors .= self::printUpdateError($sql3);
471 $r = dba::e("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
472 if (!DBM::is_result($r)) {
473 $errors .= self::printUpdateError($sql3);
480 if (!DBM::is_result($r)) {
481 $errors .= self::printUpdateError($sql3);
483 if ($is_unique && ($temp_name != $name)) {
485 dba::e("SET session old_alter_table=0;");
487 $r = dba::e("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
488 if (!DBM::is_result($r)) {
489 $errors .= self::printUpdateError($sql3);
492 $r = dba::e("DROP TABLE `".$name."`;");
493 if (!DBM::is_result($r)) {
494 $errors .= self::printUpdateError($sql3);
497 $r = dba::e("RENAME TABLE `".$temp_name."` TO `".$name."`;");
498 if (!DBM::is_result($r)) {
499 $errors .= self::printUpdateError($sql3);
509 Config::set('system', 'maintenance', 0);
510 Config::set('system', 'maintenance_reason', '');
514 Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
516 Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
522 private static function FieldCommand($parameters, $create = true) {
523 $fieldstruct = $parameters["type"];
525 if (!is_null($parameters["Collation"])) {
526 $fieldstruct .= " COLLATE ".$parameters["Collation"];
529 if ($parameters["not null"]) {
530 $fieldstruct .= " NOT NULL";
533 if (isset($parameters["default"])) {
534 if (strpos(strtolower($parameters["type"]),"int")!==false) {
535 $fieldstruct .= " DEFAULT ".$parameters["default"];
537 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
540 if ($parameters["extra"] != "") {
541 $fieldstruct .= " ".$parameters["extra"];
544 if (!is_null($parameters["comment"])) {
545 $fieldstruct .= " COMMENT '".dbesc($parameters["comment"])."'";
548 /*if (($parameters["primary"] != "") && $create)
549 $fieldstruct .= " PRIMARY KEY";*/
551 return($fieldstruct);
554 private static function createTable($name, $fields, $verbose, $action, $indexes=null) {
559 foreach ($fields AS $fieldname => $field) {
560 $sql_rows[] = "`".dbesc($fieldname)."` ".self::FieldCommand($field);
561 if (x($field,'primary') && $field['primary']!='') {
562 $primary_keys[] = $fieldname;
566 if (!is_null($indexes)) {
567 foreach ($indexes AS $indexname => $fieldnames) {
568 $sql_index = self::createIndex($indexname, $fieldnames, "");
569 if (!is_null($sql_index)) {
570 $sql_rows[] = $sql_index;
575 $sql = implode(",\n\t", $sql_rows);
577 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
589 private static function addTableField($fieldname, $parameters) {
590 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), self::FieldCommand($parameters));
594 private static function modifyTableField($fieldname, $parameters) {
595 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), self::FieldCommand($parameters, false));
599 private static function dropIndex($indexname) {
600 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
604 private static function createIndex($indexname, $fieldnames, $method = "ADD") {
605 $method = strtoupper(trim($method));
606 if ($method!="" && $method!="ADD") {
607 throw new \Exception("Invalid parameter 'method' in self::createIndex(): '$method'");
610 if ($fieldnames[0] == "UNIQUE") {
611 array_shift($fieldnames);
612 $method .= ' UNIQUE';
616 foreach ($fieldnames AS $fieldname) {
621 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
622 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
624 $names .= "`".dbesc($fieldname)."`";
628 if ($indexname == "PRIMARY") {
629 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
633 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
637 private static function groupBy($indexname, $fieldnames) {
638 if ($fieldnames[0] != "UNIQUE") {
642 array_shift($fieldnames);
645 foreach ($fieldnames AS $fieldname) {
650 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
651 $names .= "`".dbesc($matches[1])."`";
653 $names .= "`".dbesc($fieldname)."`";
657 $sql = sprintf(" GROUP BY %s", $names);
661 public static function definition() {
664 $database["addon"] = [
665 "comment" => "registered addons",
667 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
668 "name" => ["type" => "varchar(50)", "not null" => "1", "default" => "", "comment" => ""],
669 "version" => ["type" => "varchar(50)", "not null" => "1", "default" => "", "comment" => ""],
670 "installed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
671 "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
672 "timestamp" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
673 "plugin_admin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
677 "name" => ["UNIQUE", "name"],
680 $database["attach"] = [
681 "comment" => "file attachments",
683 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
684 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
685 "hash" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
686 "filename" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
687 "filetype" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
688 "filesize" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
689 "data" => ["type" => "longblob", "not null" => "1", "comment" => ""],
690 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
691 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
692 "allow_cid" => ["type" => "mediumtext", "comment" => ""],
693 "allow_gid" => ["type" => "mediumtext", "comment" => ""],
694 "deny_cid" => ["type" => "mediumtext", "comment" => ""],
695 "deny_gid" => ["type" => "mediumtext", "comment" => ""],
701 $database["auth_codes"] = [
702 "comment" => "OAuth usage",
704 "id" => ["type" => "varchar(40)", "not null" => "1", "primary" => "1", "comment" => ""],
705 "client_id" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => ["clients" => "client_id"], "comment" => ""],
706 "redirect_uri" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
707 "expires" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => ""],
708 "scope" => ["type" => "varchar(250)", "not null" => "1", "default" => "", "comment" => ""],
714 $database["cache"] = [
715 "comment" => "Stores temporary data",
717 "k" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "cache key"],
718 "v" => ["type" => "mediumtext", "comment" => "cached serialized value"],
719 "expires" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of cache expiration"],
720 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of cache insertion"],
724 "k_expires" => ["k", "expires"],
727 $database["challenge"] = [
730 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
731 "challenge" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
732 "dfrn-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
733 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
734 "type" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
735 "last_update" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
741 $database["clients"] = [
742 "comment" => "OAuth usage",
744 "client_id" => ["type" => "varchar(20)", "not null" => "1", "primary" => "1", "comment" => ""],
745 "pw" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => ""],
746 "redirect_uri" => ["type" => "varchar(200)", "not null" => "1", "default" => "", "comment" => ""],
747 "name" => ["type" => "text", "comment" => ""],
748 "icon" => ["type" => "text", "comment" => ""],
749 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
752 "PRIMARY" => ["client_id"],
755 $database["config"] = [
756 "comment" => "main configuration storage",
758 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
759 "cat" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""],
760 "k" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""],
761 "v" => ["type" => "mediumtext", "comment" => ""],
765 "cat_k" => ["UNIQUE", "cat", "k"],
768 $database["contact"] = [
769 "comment" => "contact table",
771 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
772 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
773 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
774 "self" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
775 "remote_self" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
776 "rel" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
777 "duplex" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
778 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
779 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
780 "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
781 "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
782 "about" => ["type" => "text", "comment" => ""],
783 "keywords" => ["type" => "text", "comment" => ""],
784 "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
785 "xmpp" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
786 "attag" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
787 "avatar" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
788 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
789 "thumb" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
790 "micro" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
791 "site-pubkey" => ["type" => "text", "comment" => ""],
792 "issued-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
793 "dfrn-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
794 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
795 "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
796 "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
797 "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
798 "pubkey" => ["type" => "text", "comment" => ""],
799 "prvkey" => ["type" => "text", "comment" => ""],
800 "batch" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
801 "request" => ["type" => "varchar(255)", "comment" => ""],
802 "notify" => ["type" => "varchar(255)", "comment" => ""],
803 "poll" => ["type" => "varchar(255)", "comment" => ""],
804 "confirm" => ["type" => "varchar(255)", "comment" => ""],
805 "poco" => ["type" => "varchar(255)", "comment" => ""],
806 "aes_allow" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
807 "ret-aes" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
808 "usehub" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
809 "subhub" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
810 "hub-verify" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
811 "last-update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
812 "success_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
813 "failure_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
814 "name-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
815 "uri-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
816 "avatar-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
817 "term-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
818 "last-item" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
819 "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
820 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
821 "readonly" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
822 "writable" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
823 "forum" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
824 "prv" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
825 "contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
826 "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
827 "archive" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
828 "pending" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
829 "rating" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
830 "reason" => ["type" => "text", "comment" => ""],
831 "closeness" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "99", "comment" => ""],
832 "info" => ["type" => "mediumtext", "comment" => ""],
833 "profile-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
834 "bdyear" => ["type" => "varchar(4)", "not null" => "1", "default" => "", "comment" => ""],
835 "bd" => ["type" => "date", "not null" => "1", "default" => "0001-01-01", "comment" => ""],
836 "notify_new_posts" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
837 "fetch_further_information" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
838 "ffi_keyword_blacklist" => ["type" => "text", "comment" => ""],
842 "uid_name" => ["uid", "name(190)"],
843 "self_uid" => ["self", "uid"],
844 "alias_uid" => ["alias(32)", "uid"],
845 "pending_uid" => ["pending", "uid"],
846 "blocked_uid" => ["blocked", "uid"],
847 "uid_rel_network_poll" => ["uid", "rel", "network", "poll(64)", "archive"],
848 "uid_network_batch" => ["uid", "network", "batch(64)"],
849 "addr_uid" => ["addr(32)", "uid"],
850 "nurl_uid" => ["nurl(32)", "uid"],
851 "nick_uid" => ["nick(32)", "uid"],
852 "dfrn-id" => ["dfrn-id(64)"],
853 "issued-id" => ["issued-id(64)"],
856 $database["conv"] = [
857 "comment" => "private messages",
859 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
860 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
861 "recips" => ["type" => "text", "comment" => ""],
862 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
863 "creator" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
864 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
865 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
866 "subject" => ["type" => "text", "comment" => ""],
873 $database["conversation"] = [
874 "comment" => "Raw data and structure information for messages",
876 "item-uri" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => ""],
877 "reply-to-uri" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""],
878 "conversation-uri" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""],
879 "conversation-href" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""],
880 "protocol" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
881 "source" => ["type" => "mediumtext", "comment" => ""],
882 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
885 "PRIMARY" => ["item-uri"],
886 "conversation-uri" => ["conversation-uri"],
887 "received" => ["received"],
890 $database["event"] = [
891 "comment" => "Events",
893 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
894 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
895 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
896 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
897 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
898 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
899 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
900 "start" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
901 "finish" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
902 "summary" => ["type" => "text", "comment" => ""],
903 "desc" => ["type" => "text", "comment" => ""],
904 "location" => ["type" => "text", "comment" => ""],
905 "type" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => ""],
906 "nofinish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
907 "adjust" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
908 "ignore" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
909 "allow_cid" => ["type" => "mediumtext", "comment" => ""],
910 "allow_gid" => ["type" => "mediumtext", "comment" => ""],
911 "deny_cid" => ["type" => "mediumtext", "comment" => ""],
912 "deny_gid" => ["type" => "mediumtext", "comment" => ""],
916 "uid_start" => ["uid", "start"],
919 $database["fcontact"] = [
920 "comment" => "Diaspora compatible contacts - used in the Diaspora implementation",
922 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
923 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
924 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
925 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
926 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
927 "request" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
928 "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
929 "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
930 "batch" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
931 "notify" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
932 "poll" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
933 "confirm" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
934 "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
935 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
936 "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
937 "pubkey" => ["type" => "text", "comment" => ""],
938 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
942 "addr" => ["addr(32)"],
943 "url" => ["UNIQUE", "url(190)"],
946 $database["fsuggest"] = [
947 "comment" => "friend suggestion stuff",
949 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
950 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
951 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
952 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
953 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
954 "request" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
955 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
956 "note" => ["type" => "text", "comment" => ""],
957 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
963 $database["gcign"] = [
964 "comment" => "contacts ignored by friend suggestions",
966 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
967 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
968 "gcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""],
976 $database["gcontact"] = [
977 "comment" => "global contacts",
979 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
980 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
981 "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
982 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
983 "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
984 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
985 "connect" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
986 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
987 "updated" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
988 "last_contact" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
989 "last_failure" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
990 "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
991 "about" => ["type" => "text", "comment" => ""],
992 "keywords" => ["type" => "text", "comment" => ""],
993 "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
994 "birthday" => ["type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01", "comment" => ""],
995 "community" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
996 "contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "-1", "comment" => ""],
997 "hide" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
998 "nsfw" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
999 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
1000 "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1001 "notify" => ["type" => "varchar(255)", "comment" => ""],
1002 "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1003 "generation" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1004 "server_url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1007 "PRIMARY" => ["id"],
1008 "nurl" => ["UNIQUE", "nurl(190)"],
1009 "name" => ["name(64)"],
1010 "nick" => ["nick(32)"],
1011 "addr" => ["addr(64)"],
1012 "hide_network_updated" => ["hide", "network", "updated"],
1013 "updated" => ["updated"],
1016 $database["glink"] = [
1017 "comment" => "'friends of friends' linkages derived from poco",
1019 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1020 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1021 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1022 "gcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""],
1023 "zcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""],
1024 "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1027 "PRIMARY" => ["id"],
1028 "cid_uid_gcid_zcid" => ["UNIQUE", "cid","uid","gcid","zcid"],
1032 $database["group"] = [
1033 "comment" => "privacy groups, group info",
1035 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1036 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1037 "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1038 "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1039 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1042 "PRIMARY" => ["id"],
1046 $database["group_member"] = [
1047 "comment" => "privacy groups, member info",
1049 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1050 "gid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["group" => "id"], "comment" => ""],
1051 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1054 "PRIMARY" => ["id"],
1055 "contactid" => ["contact-id"],
1056 "gid_contactid" => ["UNIQUE", "gid", "contact-id"],
1059 $database["gserver"] = [
1060 "comment" => "Global servers",
1062 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1063 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1064 "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1065 "version" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1066 "site_name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1067 "info" => ["type" => "text", "comment" => ""],
1068 "register_policy" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""],
1069 "registered-users" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1070 "poco" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1071 "noscrape" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1072 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
1073 "platform" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1074 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1075 "last_poco_query" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1076 "last_contact" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1077 "last_failure" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
1080 "PRIMARY" => ["id"],
1081 "nurl" => ["UNIQUE", "nurl(190)"],
1084 $database["hook"] = [
1085 "comment" => "addon hook registry",
1087 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1088 "hook" => ["type" => "varbinary(100)", "not null" => "1", "default" => "", "comment" => ""],
1089 "file" => ["type" => "varbinary(200)", "not null" => "1", "default" => "", "comment" => ""],
1090 "function" => ["type" => "varbinary(200)", "not null" => "1", "default" => "", "comment" => ""],
1091 "priority" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1094 "PRIMARY" => ["id"],
1095 "hook_file_function" => ["UNIQUE", "hook", "file", "function"],
1098 $database["intro"] = [
1101 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1102 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1103 "fid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["fcontact" => "id"], "comment" => ""],
1104 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1105 "knowyou" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1106 "duplex" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1107 "note" => ["type" => "text", "comment" => ""],
1108 "hash" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1109 "datetime" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1110 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""],
1111 "ignore" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1114 "PRIMARY" => ["id"],
1117 $database["item"] = [
1118 "comment" => "All posts",
1120 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => ["thread" => "iid"]],
1121 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1122 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1123 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1124 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1125 "type" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => ""],
1126 "wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1127 "gravity" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1128 "parent" => ["type" => "int unsigned", "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 unsigned", "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 unsigned", "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(100)", "not null" => "1", "default" => "", "comment" => ""],
1149 "object-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => ""],
1150 "object" => ["type" => "text", "comment" => ""],
1151 "target-type" => ["type" => "varchar(100)", "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(32)", "not null" => "1", "default" => "", "comment" => ""],
1156 "event-id" => ["type" => "int unsigned", "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 unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1178 "mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1179 "network" => ["type" => "char(4)", "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_commented" => ["uid","commented"],
1195 "uid_unseen_contactid" => ["uid","unseen","contact-id"],
1196 "uid_network_received" => ["uid","network","received"],
1197 "uid_network_commented" => ["uid","network","commented"],
1198 "uid_thrparent" => ["uid","thr-parent(190)"],
1199 "uid_parenturi" => ["uid","parent-uri(190)"],
1200 "uid_contactid_created" => ["uid","contact-id","created"],
1201 "authorid_created" => ["author-id","created"],
1202 "ownerid" => ["owner-id"],
1203 "uid_uri" => ["uid", "uri(190)"],
1204 "resource-id" => ["resource-id"],
1205 "contactid_allowcid_allowpid_denycid_denygid" => ["contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"], //
1206 "uid_type_changed" => ["uid","type","changed"],
1207 "contactid_verb" => ["contact-id","verb"],
1208 "deleted_changed" => ["deleted","changed"],
1209 "uid_wall_changed" => ["uid","wall","changed"],
1210 "uid_eventid" => ["uid","event-id"],
1211 "uid_authorlink" => ["uid","author-link(190)"],
1212 "uid_ownerlink" => ["uid","owner-link(190)"],
1215 $database["locks"] = [
1218 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1219 "name" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => ""],
1220 "locked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1221 "pid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1224 "PRIMARY" => ["id"],
1227 $database["mail"] = [
1228 "comment" => "private messages",
1230 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1231 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1232 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1233 "from-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1234 "from-photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1235 "from-url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1236 "contact-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => ["contact" => "id"], "comment" => ""],
1237 "convid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["conv" => "id"], "comment" => ""],
1238 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1239 "body" => ["type" => "mediumtext", "comment" => ""],
1240 "seen" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1241 "reply" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1242 "replied" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1243 "unknown" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1244 "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1245 "parent-uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1246 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1249 "PRIMARY" => ["id"],
1250 "uid_seen" => ["uid", "seen"],
1251 "convid" => ["convid"],
1252 "uri" => ["uri(64)"],
1253 "parent-uri" => ["parent-uri(64)"],
1254 "contactid" => ["contact-id(32)"],
1257 $database["mailacct"] = [
1258 "comment" => "Mail account data for fetching mails",
1260 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1261 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1262 "server" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1263 "port" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1264 "ssltype" => ["type" => "varchar(16)", "not null" => "1", "default" => "", "comment" => ""],
1265 "mailbox" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1266 "user" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1267 "pass" => ["type" => "text", "comment" => ""],
1268 "reply_to" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1269 "action" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1270 "movetofolder" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1271 "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1272 "last_check" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1275 "PRIMARY" => ["id"],
1278 $database["manage"] = [
1279 "comment" => "table of accounts that can manage each other",
1281 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1282 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1283 "mid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1286 "PRIMARY" => ["id"],
1287 "uid_mid" => ["UNIQUE", "uid","mid"],
1290 $database["notify"] = [
1291 "comment" => "notifications",
1293 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1294 "hash" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
1295 "type" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1296 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1297 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1298 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1299 "date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1300 "msg" => ["type" => "mediumtext", "comment" => ""],
1301 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1302 "link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1303 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1304 "parent" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1305 "seen" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1306 "verb" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => ""],
1307 "otype" => ["type" => "varchar(10)", "not null" => "1", "default" => "", "comment" => ""],
1308 "name_cache" => ["type" => "tinytext", "comment" => ""],
1309 "msg_cache" => ["type" => "mediumtext", "comment" => ""]
1312 "PRIMARY" => ["id"],
1313 "hash_uid" => ["hash", "uid"],
1314 "seen_uid_date" => ["seen", "uid", "date"],
1315 "uid_date" => ["uid", "date"],
1316 "uid_type_link" => ["uid", "type", "link(190)"],
1319 $database["notify-threads"] = [
1322 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1323 "notify-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["notify" => "id"], "comment" => ""],
1324 "master-parent-item" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1325 "parent-item" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1326 "receiver-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1329 "PRIMARY" => ["id"],
1332 $database["oembed"] = [
1333 "comment" => "cache for OEmbed queries",
1335 "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => ""],
1336 "maxwidth" => ["type" => "mediumint unsigned", "not null" => "1", "primary" => "1", "comment" => ""],
1337 "content" => ["type" => "mediumtext", "comment" => ""],
1338 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1341 "PRIMARY" => ["url", "maxwidth"],
1342 "created" => ["created"],
1345 $database["parsed_url"] = [
1346 "comment" => "cache for 'parse_url' queries",
1348 "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => ""],
1349 "guessing" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => ""],
1350 "oembed" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => ""],
1351 "content" => ["type" => "mediumtext", "comment" => ""],
1352 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1355 "PRIMARY" => ["url", "guessing", "oembed"],
1356 "created" => ["created"],
1359 $database["participation"] = [
1360 "comment" => "Storage for participation messages from Diaspora",
1362 "iid" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "relation" => ["item" => "id"], "comment" => ""],
1363 "server" => ["type" => "varchar(60)", "not null" => "1", "primary" => "1", "comment" => ""],
1364 "cid" => ["type" => "int unsigned", "not null" => "1", "relation" => ["contact" => "id"], "comment" => ""],
1365 "fid" => ["type" => "int unsigned", "not null" => "1", "relation" => ["fcontact" => "id"], "comment" => ""],
1368 "PRIMARY" => ["iid", "server"]
1371 $database["pconfig"] = [
1372 "comment" => "personal (per user) configuration storage",
1374 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1375 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1376 "cat" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""],
1377 "k" => ["type" => "varbinary(100)", "not null" => "1", "default" => "", "comment" => ""],
1378 "v" => ["type" => "mediumtext", "comment" => ""],
1381 "PRIMARY" => ["id"],
1382 "uid_cat_k" => ["UNIQUE", "uid", "cat", "k"],
1385 $database["photo"] = [
1386 "comment" => "photo storage",
1388 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1389 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1390 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1391 "guid" => ["type" => "char(16)", "not null" => "1", "default" => "", "comment" => ""],
1392 "resource-id" => ["type" => "char(32)", "not null" => "1", "default" => "", "comment" => ""],
1393 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1394 "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1395 "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1396 "desc" => ["type" => "text", "comment" => ""],
1397 "album" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1398 "filename" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1399 "type" => ["type" => "varchar(30)", "not null" => "1", "default" => "image/jpeg"],
1400 "height" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1401 "width" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1402 "datasize" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1403 "data" => ["type" => "mediumblob", "not null" => "1", "comment" => ""],
1404 "scale" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1405 "profile" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1406 "allow_cid" => ["type" => "mediumtext", "comment" => ""],
1407 "allow_gid" => ["type" => "mediumtext", "comment" => ""],
1408 "deny_cid" => ["type" => "mediumtext", "comment" => ""],
1409 "deny_gid" => ["type" => "mediumtext", "comment" => ""],
1412 "PRIMARY" => ["id"],
1413 "contactid" => ["contact-id"],
1414 "uid_contactid" => ["uid", "contact-id"],
1415 "uid_profile" => ["uid", "profile"],
1416 "uid_album_scale_created" => ["uid", "album(32)", "scale", "created"],
1417 "uid_album_resource-id_created" => ["uid", "album(32)", "resource-id", "created"],
1418 "resource-id" => ["resource-id"],
1421 $database["poll"] = [
1422 "comment" => "Currently unused table for storing poll results",
1424 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1425 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1426 "q0" => ["type" => "text", "comment" => ""],
1427 "q1" => ["type" => "text", "comment" => ""],
1428 "q2" => ["type" => "text", "comment" => ""],
1429 "q3" => ["type" => "text", "comment" => ""],
1430 "q4" => ["type" => "text", "comment" => ""],
1431 "q5" => ["type" => "text", "comment" => ""],
1432 "q6" => ["type" => "text", "comment" => ""],
1433 "q7" => ["type" => "text", "comment" => ""],
1434 "q8" => ["type" => "text", "comment" => ""],
1435 "q9" => ["type" => "text", "comment" => ""],
1438 "PRIMARY" => ["id"],
1442 $database["poll_result"] = [
1443 "comment" => "data for polls - currently unused",
1445 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1446 "poll_id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["poll" => "id"]],
1447 "choice" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1450 "PRIMARY" => ["id"],
1451 "poll_id" => ["poll_id"],
1454 $database["process"] = [
1455 "comment" => "Currently running system processes",
1457 "pid" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "comment" => ""],
1458 "command" => ["type" => "varbinary(32)", "not null" => "1", "default" => "", "comment" => ""],
1459 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1462 "PRIMARY" => ["pid"],
1463 "command" => ["command"],
1466 $database["profile"] = [
1467 "comment" => "user profiles data",
1469 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1470 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1471 "profile-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1472 "is-default" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1473 "hide-friends" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1474 "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1475 "pdesc" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1476 "dob" => ["type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00", "comment" => ""],
1477 "address" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1478 "locality" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1479 "region" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1480 "postal-code" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1481 "country-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1482 "hometown" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1483 "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
1484 "marital" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1485 "with" => ["type" => "text", "comment" => ""],
1486 "howlong" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1487 "sexual" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1488 "politic" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1489 "religion" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1490 "pub_keywords" => ["type" => "text", "comment" => ""],
1491 "prv_keywords" => ["type" => "text", "comment" => ""],
1492 "likes" => ["type" => "text", "comment" => ""],
1493 "dislikes" => ["type" => "text", "comment" => ""],
1494 "about" => ["type" => "text", "comment" => ""],
1495 "summary" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1496 "music" => ["type" => "text", "comment" => ""],
1497 "book" => ["type" => "text", "comment" => ""],
1498 "tv" => ["type" => "text", "comment" => ""],
1499 "film" => ["type" => "text", "comment" => ""],
1500 "interest" => ["type" => "text", "comment" => ""],
1501 "romance" => ["type" => "text", "comment" => ""],
1502 "work" => ["type" => "text", "comment" => ""],
1503 "education" => ["type" => "text", "comment" => ""],
1504 "contact" => ["type" => "text", "comment" => ""],
1505 "homepage" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1506 "xmpp" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1507 "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1508 "thumb" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1509 "publish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1510 "net-publish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1513 "PRIMARY" => ["id"],
1514 "uid_is-default" => ["uid", "is-default"],
1517 $database["profile_check"] = [
1518 "comment" => "DFRN remote auth use",
1520 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1521 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1522 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1523 "dfrn_id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1524 "sec" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1525 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1528 "PRIMARY" => ["id"],
1531 $database["push_subscriber"] = [
1532 "comment" => "Used for OStatus: Contains feed subscribers",
1534 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1535 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1536 "callback_url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1537 "topic" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1538 "nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1539 "push" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1540 "last_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1541 "secret" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1544 "PRIMARY" => ["id"],
1547 $database["queue"] = [
1548 "comment" => "Queue for messages that couldn't be delivered",
1550 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1551 "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Message receiver"],
1552 "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Receiver's network"],
1553 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Unique GUID of the message"],
1554 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date, when the message was created"],
1555 "last" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last trial"],
1556 "next" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Next retrial date"],
1557 "retrial" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Retrial counter"],
1558 "content" => ["type" => "mediumtext", "comment" => ""],
1559 "batch" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1562 "PRIMARY" => ["id"],
1567 $database["register"] = [
1568 "comment" => "registrations requiring admin approval",
1570 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1571 "hash" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1572 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1573 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1574 "password" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1575 "language" => ["type" => "varchar(16)", "not null" => "1", "default" => "", "comment" => ""],
1576 "note" => ["type" => "text", "comment" => ""],
1579 "PRIMARY" => ["id"],
1582 $database["search"] = [
1585 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1586 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1587 "term" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1590 "PRIMARY" => ["id"],
1594 $database["session"] = [
1595 "comment" => "web session storage",
1597 "id" => ["type" => "bigint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1598 "sid" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""],
1599 "data" => ["type" => "text", "comment" => ""],
1600 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1603 "PRIMARY" => ["id"],
1604 "sid" => ["sid(64)"],
1605 "expire" => ["expire"],
1608 $database["sign"] = [
1609 "comment" => "Diaspora signatures",
1611 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1612 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1613 "signed_text" => ["type" => "mediumtext", "comment" => ""],
1614 "signature" => ["type" => "text", "comment" => ""],
1615 "signer" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1618 "PRIMARY" => ["id"],
1619 "iid" => ["UNIQUE", "iid"],
1622 $database["term"] = [
1623 "comment" => "item taxonomy (categories, tags, etc.) table",
1625 "tid" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1626 "oid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""],
1627 "otype" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1628 "type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1629 "term" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1630 "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1631 "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1632 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1633 "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1634 "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1635 "aid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1636 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1639 "PRIMARY" => ["tid"],
1640 "oid_otype_type_term" => ["oid","otype","type","term(32)"],
1641 "uid_otype_type_term_global_created" => ["uid","otype","type","term(32)","global","created"],
1642 "uid_otype_type_url" => ["uid","otype","type","url(64)"],
1643 "guid" => ["guid(64)"],
1646 $database["thread"] = [
1647 "comment" => "Thread related data",
1649 "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["item" => "id"], "comment" => ""],
1650 "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
1651 "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1652 "owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""],
1653 "author-id" => ["type" => "int unsigned", "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 unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1672 "mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1673 "network" => ["type" => "char(4)", "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_origin_commented" => ["private","wall","origin","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 unsigned", "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 unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1708 "parent-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "The parent user that has full control about this user"],
1709 "guid" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
1710 "username" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1711 "password" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1712 "legacy_password" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Is the password hash double-hashed?"],
1713 "nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1714 "email" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1715 "openid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1716 "timezone" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => ""],
1717 "language" => ["type" => "varchar(32)", "not null" => "1", "default" => "en", "comment" => ""],
1718 "register_date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1719 "login_date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1720 "default-location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1721 "allow_location" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1722 "theme" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
1723 "pubkey" => ["type" => "text", "comment" => ""],
1724 "prvkey" => ["type" => "text", "comment" => ""],
1725 "spubkey" => ["type" => "text", "comment" => ""],
1726 "sprvkey" => ["type" => "text", "comment" => ""],
1727 "verified" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1728 "blocked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1729 "blockwall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1730 "hidewall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1731 "blocktags" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1732 "unkmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1733 "cntunkmail" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""],
1734 "notify-flags" => ["type" => "smallint unsigned", "not null" => "1", "default" => "65535", "comment" => ""],
1735 "page-flags" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1736 "account-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1737 "prvnets" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1738 "pwdreset" => ["type" => "varchar(255)", "comment" => "Password reset request token"],
1739 "pwdreset_time" => ["type" => "datetime", "comment" => "Timestamp of the last password reset request"],
1740 "maxreq" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""],
1741 "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1742 "account_removed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1743 "account_expired" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
1744 "account_expires_on" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1745 "expire_notification_sent" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
1746 "def_gid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
1747 "allow_cid" => ["type" => "mediumtext", "comment" => ""],
1748 "allow_gid" => ["type" => "mediumtext", "comment" => ""],
1749 "deny_cid" => ["type" => "mediumtext", "comment" => ""],
1750 "deny_gid" => ["type" => "mediumtext", "comment" => ""],
1751 "openidserver" => ["type" => "text", "comment" => ""],
1754 "PRIMARY" => ["uid"],
1755 "nickname" => ["nickname(32)"],
1758 $database["userd"] = [
1759 "comment" => "Deleted usernames",
1761 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
1762 "username" => ["type" => "varchar(255)", "not null" => "1", "comment" => ""],
1765 "PRIMARY" => ["id"],
1766 "username" => ["username(32)"],
1769 $database["workerqueue"] = [
1770 "comment" => "Background tasks queue entries",
1772 "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "Auto incremented worker task id"],
1773 "parameter" => ["type" => "mediumblob", "comment" => "Task command"],
1774 "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Task priority"],
1775 "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Creation date"],
1776 "pid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "Process id of the worker"],
1777 "executed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Execution date"],
1778 "done" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Marked when the task was done, will be deleted later"],
1781 "PRIMARY" => ["id"],
1783 "parameter" => ["parameter(64)"],
1784 "priority_created" => ["priority", "created"],
1785 "executed" => ["executed"],