X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FDatabase%2FDBStructure.php;h=bfecdba20ef5f5d4cc7369ede2ef7e7a1a472a25;hb=daa1177e3a1e42b4c95e0a8759f1610942b952c7;hp=847449b75419c8ab3fe6aad072c8ebb1c32d8e30;hpb=c598bf7d8f5075526fadcfd329f6dd448533dfad;p=friendica.git diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 847449b754..bfecdba20e 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -4,10 +4,10 @@ */ namespace Friendica\Database; +use Exception; +use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; -use Friendica\Database\DBM; -use dba; require_once 'boot.php'; require_once 'include/dba.php'; @@ -54,7 +54,7 @@ class DBStructure $a = get_app(); //send the administrators an e-mail - $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'"; + $admin_mail_list = "'".implode("','", array_map('dbesc', explode(",", str_replace(" ", "", Config::get('config', 'admin_email')))))."'"; $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)", $admin_mail_list ); @@ -174,7 +174,7 @@ class DBStructure echo "--\n"; echo "-- TABLE $name\n"; echo "--\n"; - self::createTable($name, $structure['fields'], true, false, $structure["indexes"]); + self::createTable($name, $structure, true, false); echo "\n"; } @@ -251,7 +251,7 @@ class DBStructure $is_unique = false; $temp_name = $name; if (!isset($database[$name])) { - $r = self::createTable($name, $structure["fields"], $verbose, $action, $structure['indexes']); + $r = self::createTable($name, $structure, $verbose, $action); if (!DBM::is_result($r)) { $errors .= self::printUpdateError($name); } @@ -322,8 +322,8 @@ class DBStructure $parameters['comment'] = ""; } - $current_field_definition = implode(",", $field_definition); - $new_field_definition = implode(",", $parameters); + $current_field_definition = dba::clean_query(implode(",", $field_definition)); + $new_field_definition = dba::clean_query(implode(",", $parameters)); if ($current_field_definition != $new_field_definition) { $sql2 = self::modifyTableField($fieldname, $parameters); if ($sql3 == "") { @@ -378,6 +378,18 @@ class DBStructure } } + if (isset($database[$name]["table_status"]["Engine"]) && isset($structure['engine'])) { + if ($database[$name]["table_status"]["Engine"] != $structure['engine']) { + $sql2 = "ENGINE = '".dbesc($structure['engine'])."'"; + + if ($sql3 == "") { + $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2; + } else { + $sql3 .= ", ".$sql2; + } + } + } + if (isset($database[$name]["table_status"]["Collation"])) { if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') { $sql2 = "DEFAULT COLLATE utf8mb4_general_ci"; @@ -398,10 +410,10 @@ class DBStructure // Compare the field structure field by field foreach ($structure["fields"] AS $fieldname => $parameters) { // Compare the field definition - $field_definition = $database[$name]["fields"][$fieldname]; + $field_definition = defaults($database[$name]["fields"], $fieldname, ['Collation' => '']); // Define the default collation if not given - if (!isset($parameters['Collation']) && !is_null($field_definition['Collation'])) { + if (!isset($parameters['Collation']) && !empty($field_definition['Collation'])) { $parameters['Collation'] = 'utf8mb4_general_ci'; } else { $parameters['Collation'] = null; @@ -525,11 +537,11 @@ class DBStructure private static function FieldCommand($parameters, $create = true) { $fieldstruct = $parameters["type"]; - if (!is_null($parameters["Collation"])) { + if (isset($parameters["Collation"])) { $fieldstruct .= " COLLATE ".$parameters["Collation"]; } - if ($parameters["not null"]) { + if (isset($parameters["not null"])) { $fieldstruct .= " NOT NULL"; } @@ -540,11 +552,11 @@ class DBStructure $fieldstruct .= " DEFAULT '".$parameters["default"]."'"; } } - if ($parameters["extra"] != "") { + if (isset($parameters["extra"])) { $fieldstruct .= " ".$parameters["extra"]; } - if (!is_null($parameters["comment"])) { + if (isset($parameters["comment"])) { $fieldstruct .= " COMMENT '".dbesc($parameters["comment"])."'"; } @@ -554,20 +566,22 @@ class DBStructure return($fieldstruct); } - private static function createTable($name, $fields, $verbose, $action, $indexes=null) { + private static function createTable($name, $structure, $verbose, $action) { $r = true; + $engine = ""; + $comment = ""; $sql_rows = []; $primary_keys = []; - foreach ($fields AS $fieldname => $field) { + foreach ($structure["fields"] AS $fieldname => $field) { $sql_rows[] = "`".dbesc($fieldname)."` ".self::FieldCommand($field); if (x($field,'primary') && $field['primary']!='') { $primary_keys[] = $fieldname; } } - if (!is_null($indexes)) { - foreach ($indexes AS $indexname => $fieldnames) { + if (!empty($structure["indexes"])) { + foreach ($structure["indexes"] AS $indexname => $fieldnames) { $sql_index = self::createIndex($indexname, $fieldnames, ""); if (!is_null($sql_index)) { $sql_rows[] = $sql_index; @@ -575,9 +589,18 @@ class DBStructure } } + if (isset($structure["engine"])) { + $engine = " ENGINE=" . $structure["engine"]; + } + + if (isset($structure["comment"])) { + $comment = " COMMENT='" . dbesc($structure["comment"]) . "'"; + } + $sql = implode(",\n\t", $sql_rows); - $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci"; + $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql. + "\n)" . $engine . " DEFAULT COLLATE utf8mb4_general_ci" . $comment; if ($verbose) { echo $sql.";\n"; } @@ -607,7 +630,7 @@ class DBStructure private static function createIndex($indexname, $fieldnames, $method = "ADD") { $method = strtoupper(trim($method)); if ($method!="" && $method!="ADD") { - throw new \Exception("Invalid parameter 'method' in self::createIndex(): '$method'"); + throw new Exception("Invalid parameter 'method' in self::createIndex(): '$method'"); } if ($fieldnames[0] == "UNIQUE") { @@ -668,12 +691,12 @@ class DBStructure "comment" => "registered addons", "fields" => [ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], - "name" => ["type" => "varchar(50)", "not null" => "1", "default" => "", "comment" => ""], - "version" => ["type" => "varchar(50)", "not null" => "1", "default" => "", "comment" => ""], - "installed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "timestamp" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""], - "plugin_admin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], + "name" => ["type" => "varchar(50)", "not null" => "1", "default" => "", "comment" => "addon base (file)name"], + "version" => ["type" => "varchar(50)", "not null" => "1", "default" => "", "comment" => "currently unused"], + "installed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "currently always 1"], + "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "currently unused"], + "timestamp" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "file timestamp to check for reloads"], + "plugin_admin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 = has admin config, 0 = has no admin config"], ], "indexes" => [ "PRIMARY" => ["id"], @@ -683,19 +706,19 @@ class DBStructure $database["attach"] = [ "comment" => "file attachments", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], - "hash" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""], - "filename" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "filetype" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""], - "filesize" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""], - "data" => ["type" => "longblob", "not null" => "1", "comment" => ""], - "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], - "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], - "allow_cid" => ["type" => "mediumtext", "comment" => ""], - "allow_gid" => ["type" => "mediumtext", "comment" => ""], - "deny_cid" => ["type" => "mediumtext", "comment" => ""], - "deny_gid" => ["type" => "mediumtext", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "generated index"], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"], + "hash" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "hash"], + "filename" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "filename of original"], + "filetype" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "mimetype"], + "filesize" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "size in bytes"], + "data" => ["type" => "longblob", "not null" => "1", "comment" => "file data"], + "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation time"], + "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "last edit time"], + "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>"], + "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"], + "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"], + "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"], ], "indexes" => [ "PRIMARY" => ["id"], @@ -730,7 +753,7 @@ class DBStructure $database["challenge"] = [ "comment" => "", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "challenge" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "dfrn-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""], @@ -771,26 +794,26 @@ class DBStructure $database["contact"] = [ "comment" => "contact table", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"], "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], - "self" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], + "self" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 if the contact is the user him/her self"], "remote_self" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "rel" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""], + "rel" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "The kind of the relation between the user and the contact"], "duplex" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""], - "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], + "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Network protocol of the contact"], + "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this contact is known by"], + "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Nick- and user name of the contact"], "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "about" => ["type" => "text", "comment" => ""], - "keywords" => ["type" => "text", "comment" => ""], + "keywords" => ["type" => "text", "comment" => "public keywords (interests) of the contact"], "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""], "xmpp" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "attag" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "avatar" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "photo" => ["type" => "varchar(255)", "default" => "", "comment" => ""], - "thumb" => ["type" => "varchar(255)", "default" => "", "comment" => ""], - "micro" => ["type" => "varchar(255)", "default" => "", "comment" => ""], + "photo" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo of the contact"], + "thumb" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo (thumb size)"], + "micro" => ["type" => "varchar(255)", "default" => "", "comment" => "Link to the profile photo (micro size)"], "site-pubkey" => ["type" => "text", "comment" => ""], "issued-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "dfrn-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], @@ -798,8 +821,8 @@ class DBStructure "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "pubkey" => ["type" => "text", "comment" => ""], - "prvkey" => ["type" => "text", "comment" => ""], + "pubkey" => ["type" => "text", "comment" => "RSA public key 4096 bit"], + "prvkey" => ["type" => "text", "comment" => "RSA private key 4096 bit"], "batch" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "request" => ["type" => "varchar(255)", "comment" => ""], "notify" => ["type" => "varchar(255)", "comment" => ""], @@ -811,20 +834,20 @@ class DBStructure "usehub" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "subhub" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "hub-verify" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "last-update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], - "success_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], - "failure_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], + "last-update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of the last try to update the contact info"], + "success_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of the last successful contact update"], + "failure_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of the last failed update"], "name-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], "uri-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], "avatar-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], "term-date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], - "last-item" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], + "last-item" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "date of the last post"], "priority" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""], "blocked" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""], - "readonly" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], + "readonly" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "posts of the contact are readonly"], "writable" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "forum" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "prv" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], + "forum" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "contact is a forum"], + "prv" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "contact is a private group"], "contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""], "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "archive" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], @@ -859,14 +882,14 @@ class DBStructure $database["conv"] = [ "comment" => "private messages", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], - "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "recips" => ["type" => "text", "comment" => ""], - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], - "creator" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], - "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], - "subject" => ["type" => "text", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], + "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this conversation"], + "recips" => ["type" => "text", "comment" => "sender_handle;recipient_handle"], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"], + "creator" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "handle of creator"], + "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation timestamp"], + "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "edited timestamp"], + "subject" => ["type" => "text", "comment" => "subject of initial message"], ], "indexes" => [ "PRIMARY" => ["id"], @@ -876,13 +899,13 @@ class DBStructure $database["conversation"] = [ "comment" => "Raw data and structure information for messages", "fields" => [ - "item-uri" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => ""], - "reply-to-uri" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""], - "conversation-uri" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""], - "conversation-href" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""], - "protocol" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""], - "source" => ["type" => "mediumtext", "comment" => ""], - "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], + "item-uri" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "URI of the item"], + "reply-to-uri" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => "URI to which this item is a reply"], + "conversation-uri" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => "GNU Social conversation URI"], + "conversation-href" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => "GNU Social conversation link"], + "protocol" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "The protocol of the item"], + "source" => ["type" => "mediumtext", "comment" => "Original source"], + "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Receiving date"], ], "indexes" => [ "PRIMARY" => ["item-uri"], @@ -893,26 +916,26 @@ class DBStructure $database["event"] = [ "comment" => "Events", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], - "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"], + "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact_id (ID of the contact in contact table)"], "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], - "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], - "start" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], - "finish" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], - "summary" => ["type" => "text", "comment" => ""], - "desc" => ["type" => "text", "comment" => ""], - "location" => ["type" => "text", "comment" => ""], - "type" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => ""], - "nofinish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "adjust" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""], - "ignore" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "allow_cid" => ["type" => "mediumtext", "comment" => ""], - "allow_gid" => ["type" => "mediumtext", "comment" => ""], - "deny_cid" => ["type" => "mediumtext", "comment" => ""], - "deny_gid" => ["type" => "mediumtext", "comment" => ""], + "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation time"], + "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "last edit time"], + "start" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "event start time"], + "finish" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "event end time"], + "summary" => ["type" => "text", "comment" => "short description or title of the event"], + "desc" => ["type" => "text", "comment" => "event description"], + "location" => ["type" => "text", "comment" => "event location"], + "type" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => "event or birthday"], + "nofinish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if event does have no end this is 1"], + "adjust" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => "adjust to timezone of the recipient (0 or 1)"], + "ignore" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "0 or 1"], + "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>'"], + "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"], + "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"], + "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"], ], "indexes" => [ "PRIMARY" => ["id"], @@ -922,8 +945,8 @@ class DBStructure $database["fcontact"] = [ "comment" => "Diaspora compatible contacts - used in the Diaspora implementation", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], - "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], + "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "unique id"], "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], @@ -966,9 +989,9 @@ class DBStructure $database["gcign"] = [ "comment" => "contacts ignored by friend suggestions", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], - "gcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Local User id"], + "gcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => "gcontact.id of ignored contact"], ], "indexes" => [ "PRIMARY" => ["id"], @@ -979,12 +1002,12 @@ class DBStructure $database["gcontact"] = [ "comment" => "global contacts", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], - "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], + "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this contact is known by"], + "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Nick- and user name of the contact"], + "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Link to the contacts profile page"], "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], + "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Link to the profile photo"], "connect" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], "updated" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""], @@ -992,19 +1015,19 @@ class DBStructure "last_failure" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""], "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "about" => ["type" => "text", "comment" => ""], - "keywords" => ["type" => "text", "comment" => ""], + "keywords" => ["type" => "text", "comment" => "puplic keywords (interests)"], "gender" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""], "birthday" => ["type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01", "comment" => ""], - "community" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], + "community" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 if contact is forum account"], "contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "-1", "comment" => ""], - "hide" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "nsfw" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""], + "hide" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 = should be hidden from search"], + "nsfw" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 = contact posts nsfw content"], + "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "social network protocol"], "addr" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "notify" => ["type" => "varchar(255)", "comment" => ""], "alias" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "generation" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""], - "server_url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], + "server_url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "baseurl of the contacts server"], ], "indexes" => [ "PRIMARY" => ["id"], @@ -1019,7 +1042,7 @@ class DBStructure $database["glink"] = [ "comment" => "'friends of friends' linkages derived from poco", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""], "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], "gcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gcontact" => "id"], "comment" => ""], @@ -1035,11 +1058,11 @@ class DBStructure $database["group"] = [ "comment" => "privacy groups, group info", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], - "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"], + "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 indicates the member list is not private"], + "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 indicates the group has been deleted"], + "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "human readable name of group"], ], "indexes" => [ "PRIMARY" => ["id"], @@ -1049,9 +1072,9 @@ class DBStructure $database["group_member"] = [ "comment" => "privacy groups, member info", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], - "gid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["group" => "id"], "comment" => ""], - "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], + "gid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["group" => "id"], "comment" => "groups.id of the associated group"], + "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id of the member assigned to the associated group"], ], "indexes" => [ "PRIMARY" => ["id"], @@ -1062,14 +1085,14 @@ class DBStructure $database["gserver"] = [ "comment" => "Global servers", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "nurl" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "version" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "site_name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "info" => ["type" => "text", "comment" => ""], "register_policy" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""], - "registered-users" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""], + "registered-users" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "Number of registered users"], "poco" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "noscrape" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""], @@ -1100,11 +1123,11 @@ class DBStructure $database["hook"] = [ "comment" => "addon hook registry", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], - "hook" => ["type" => "varbinary(100)", "not null" => "1", "default" => "", "comment" => ""], - "file" => ["type" => "varbinary(200)", "not null" => "1", "default" => "", "comment" => ""], - "function" => ["type" => "varbinary(200)", "not null" => "1", "default" => "", "comment" => ""], - "priority" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], + "hook" => ["type" => "varbinary(100)", "not null" => "1", "default" => "", "comment" => "name of hook"], + "file" => ["type" => "varbinary(200)", "not null" => "1", "default" => "", "comment" => "relative filename of hook handler"], + "function" => ["type" => "varbinary(200)", "not null" => "1", "default" => "", "comment" => "function name of hook handler"], + "priority" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => "not yet implemented - can be used to sort conflicts in hook handling by calling handlers in priority order"], ], "indexes" => [ "PRIMARY" => ["id"], @@ -1114,7 +1137,7 @@ class DBStructure $database["intro"] = [ "comment" => "", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], "fid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["fcontact" => "id"], "comment" => ""], "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""], @@ -1131,72 +1154,81 @@ class DBStructure ] ]; $database["item"] = [ - "comment" => "All posts", + "comment" => "Structure for all posts", "fields" => [ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => ["thread" => "iid"]], - "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], + "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this item"], "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], - "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""], - "type" => ["type" => "varchar(20)", "not null" => "1", "default" => "", "comment" => ""], - "wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], + "uri-hash" => ["type" => "varchar(80)", "not null" => "1", "default" => "", "comment" => "RIPEMD-128 hash from uri"], + "parent" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => "item.id of the parent to this item if it is a reply of some form; otherwise this must be set to the id of this item"], + "parent-uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "uri of the parent to this item"], + "thr-parent" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "If the parent of this item is not the top-level item in the conversation, the uri of the immediate parent; otherwise set to parent-uri"], + "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Creation timestamp."], + "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last edit (default is created)"], + "commented" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last comment/reply to this item"], + "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime"], + "changed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date that something in the conversation changed, indicating clients should fetch the conversation again"], "gravity" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""], - "parent" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""], - "parent-uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], + "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Network from where the item comes from"], + "owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Link to the contact table with uid=0 of the owner of this item"], + "author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Link to the contact table with uid=0 of the author of this item"], + "icid" => ["type" => "int unsigned", "relation" => ["item-content" => "id"], "comment" => "Id of the item-content table entry that contains the whole item content"], + "iaid" => ["type" => "int unsigned", "relation" => ["item-activity" => "id"], "comment" => "Id of the item-activity table entry that contains the activity data"], "extid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "thr-parent" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], - "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], - "commented" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], - "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], - "changed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], - "owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""], - "owner-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "owner-link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "owner-avatar" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""], - "author-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "author-link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "author-avatar" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "content-warning" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "body" => ["type" => "mediumtext", "comment" => ""], - "app" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "verb" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => ""], - "object-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => ""], - "object" => ["type" => "text", "comment" => ""], - "target-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => ""], - "target" => ["type" => "text", "comment" => ""], - "postopts" => ["type" => "text", "comment" => ""], - "plink" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "resource-id" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""], - "event-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["event" => "id"], "comment" => ""], - "tag" => ["type" => "mediumtext", "comment" => ""], - "attach" => ["type" => "mediumtext", "comment" => ""], - "inform" => ["type" => "mediumtext", "comment" => ""], - "file" => ["type" => "mediumtext", "comment" => ""], - "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "coord" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "allow_cid" => ["type" => "mediumtext", "comment" => ""], - "allow_gid" => ["type" => "mediumtext", "comment" => ""], - "deny_cid" => ["type" => "mediumtext", "comment" => ""], - "deny_gid" => ["type" => "mediumtext", "comment" => ""], - "private" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], + "post-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Post type (personal note, bookmark, ...)"], + "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], + "private" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "distribution is restricted"], "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "spam" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "bookmark" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""], - "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], + "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], + "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been deleted"], + // User specific fields. Eventually they will move to user-item + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner id which owns this copy of the item"], + "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id"], + "wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "This item was posted to the wall of uid"], + "origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item originated at this site"], + "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], + "starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been favourited"], + "unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => "item has not been seen"], + "mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "The owner of this item was mentioned in it"], "forum_mode" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""], - "mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""], - "rendered-hash" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""], - "rendered-html" => ["type" => "mediumtext", "comment" => ""], - "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], + "psid" => ["type" => "int unsigned", "relation" => ["permissionset" => "id"], "comment" => "ID of the permission set of this post"], + // These fields will be replaced by the "psid" from above + "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>'"], + "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"], + "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"], + "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"], + // It is to be decided whether these fields belong to the user or the structure + "resource-id" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => "Used to link other tables to items, it identifies the linked resource (e.g. photo) and if set must also set resource_type"], + "event-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["event" => "id"], "comment" => "Used to link to the event.id"], + // Could possibly be replaced by the "attach" table? + "attach" => ["type" => "mediumtext", "comment" => "JSON structure representing attachments to this item"], + // Deprecated fields. Will be removed in upcoming versions + "postopts" => ["type" => "text", "comment" => "Deprecated"], + "inform" => ["type" => "mediumtext", "comment" => "Deprecated"], + "type" => ["type" => "varchar(20)", "comment" => "Deprecated"], + "bookmark" => ["type" => "boolean", "comment" => "Deprecated"], + "file" => ["type" => "mediumtext", "comment" => "Deprecated"], + "location" => ["type" => "varchar(255)", "comment" => "Deprecated"], + "coord" => ["type" => "varchar(255)", "comment" => "Deprecated"], + "tag" => ["type" => "mediumtext", "comment" => "Deprecated"], + "plink" => ["type" => "varchar(255)", "comment" => "Deprecated"], + "title" => ["type" => "varchar(255)", "comment" => "Deprecated"], + "content-warning" => ["type" => "varchar(255)", "comment" => "Deprecated"], + "body" => ["type" => "mediumtext", "comment" => "Deprecated"], + "app" => ["type" => "varchar(255)", "comment" => "Deprecated"], + "verb" => ["type" => "varchar(100)", "comment" => "Deprecated"], + "object-type" => ["type" => "varchar(100)", "comment" => "Deprecated"], + "object" => ["type" => "text", "comment" => "Deprecated"], + "target-type" => ["type" => "varchar(100)", "comment" => "Deprecated"], + "target" => ["type" => "text", "comment" => "Deprecated"], + "author-name" => ["type" => "varchar(255)", "comment" => "Deprecated"], + "author-link" => ["type" => "varchar(255)", "comment" => "Deprecated"], + "author-avatar" => ["type" => "varchar(255)", "comment" => "Deprecated"], + "owner-name" => ["type" => "varchar(255)", "comment" => "Deprecated"], + "owner-link" => ["type" => "varchar(255)", "comment" => "Deprecated"], + "owner-avatar" => ["type" => "varchar(255)", "comment" => "Deprecated"], + "rendered-hash" => ["type" => "varchar(32)", "comment" => "Deprecated"], + "rendered-html" => ["type" => "mediumtext", "comment" => "Deprecated"], ], "indexes" => [ "PRIMARY" => ["id"], @@ -1219,48 +1251,101 @@ class DBStructure "ownerid" => ["owner-id"], "uid_uri" => ["uid", "uri(190)"], "resource-id" => ["resource-id"], - "contactid_allowcid_allowpid_denycid_denygid" => ["contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"], // - "uid_type_changed" => ["uid","type","changed"], - "contactid_verb" => ["contact-id","verb"], "deleted_changed" => ["deleted","changed"], "uid_wall_changed" => ["uid","wall","changed"], "uid_eventid" => ["uid","event-id"], - "uid_authorlink" => ["uid","author-link(190)"], - "uid_ownerlink" => ["uid","owner-link(190)"], + "icid" => ["icid"], + "iaid" => ["iaid"], + "psid" => ["psid"], + ] + ]; + $database["item-activity"] = [ + "comment" => "Activities for items", + "fields" => [ + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => ["thread" => "iid"]], + "uri" => ["type" => "varchar(255)", "comment" => ""], + "uri-hash" => ["type" => "varchar(80)", "not null" => "1", "default" => "", "comment" => "RIPEMD-128 hash from uri"], + "activity" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""], + ], + "indexes" => [ + "PRIMARY" => ["id"], + "uri-hash" => ["UNIQUE", "uri-hash"], + "uri" => ["uri(191)"], + ] + ]; + $database["item-content"] = [ + "comment" => "Content for all posts", + "fields" => [ + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => ["thread" => "iid"]], + "uri" => ["type" => "varchar(255)", "comment" => ""], + "uri-plink-hash" => ["type" => "varchar(80)", "not null" => "1", "default" => "", "comment" => "RIPEMD-128 hash from uri"], + "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "item title"], + "content-warning" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], + "body" => ["type" => "mediumtext", "comment" => "item body content"], + "location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "text location where this item originated"], + "coord" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "longitude/latitude pair representing location where this item originated"], + "language" => ["type" => "text", "comment" => "Language information about this post"], + "app" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "application which generated this item"], + "rendered-hash" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""], + "rendered-html" => ["type" => "mediumtext", "comment" => "item.body converted to html"], + "object-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams object type"], + "object" => ["type" => "text", "comment" => "JSON encoded object structure unless it is an implied object (normal post)"], + "target-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams target type if applicable (URI)"], + "target" => ["type" => "text", "comment" => "JSON encoded target structure if used"], + "plink" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "permalink or URL to a displayable copy of the message at its source"], + "verb" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams verb"], + ], + "indexes" => [ + "PRIMARY" => ["id"], + "uri-plink-hash" => ["UNIQUE", "uri-plink-hash"], + "uri" => ["uri(191)"], + ] + ]; + $database["item-delivery-data"] = [ + "comment" => "Delivery data for items", + "fields" => [ + "iid" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "relation" => ["item" => "id"], "comment" => "Item id"], + "postopts" => ["type" => "text", "comment" => "External post connectors add their network name to this comma-separated string to identify that they should be delivered to these networks during delivery"], + "inform" => ["type" => "mediumtext", "comment" => "Additional receivers of the linked item"], + ], + "indexes" => [ + "PRIMARY" => ["iid"], ] ]; $database["locks"] = [ "comment" => "", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "name" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => ""], "locked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "pid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""], - ], + "pid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "Process ID"], + "expires" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of cache expiration"], + ], "indexes" => [ "PRIMARY" => ["id"], + "name_expires" => ["name", "expires"] ] ]; $database["mail"] = [ "comment" => "private messages", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], - "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "from-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "from-photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "from-url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "contact-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => ["contact" => "id"], "comment" => ""], - "convid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["conv" => "id"], "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"], + "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this private message"], + "from-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "name of the sender"], + "from-photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "contact photo link of the sender"], + "from-url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "profile linke of the sender"], + "contact-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => ["contact" => "id"], "comment" => "contact.id"], + "convid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["conv" => "id"], "comment" => "conv.id"], "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "body" => ["type" => "mediumtext", "comment" => ""], - "seen" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], + "seen" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if message visited it is 1"], "reply" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "replied" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "unknown" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], + "unknown" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if sender not in the contact table this is 1"], "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "parent-uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], + "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation time of the private message"], ], "indexes" => [ "PRIMARY" => ["id"], @@ -1274,7 +1359,7 @@ class DBStructure $database["mailacct"] = [ "comment" => "Mail account data for fetching mails", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], "server" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "port" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""], @@ -1295,7 +1380,7 @@ class DBStructure $database["manage"] = [ "comment" => "table of accounts that can manage each other", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], "mid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], ], @@ -1307,7 +1392,7 @@ class DBStructure $database["notify"] = [ "comment" => "notifications", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "hash" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""], "type" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""], "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], @@ -1315,15 +1400,15 @@ class DBStructure "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], "msg" => ["type" => "mediumtext", "comment" => ""], - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"], "link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""], + "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => "item.id"], "parent" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""], "seen" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "verb" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => ""], "otype" => ["type" => "varchar(10)", "not null" => "1", "default" => "", "comment" => ""], - "name_cache" => ["type" => "tinytext", "comment" => ""], - "msg_cache" => ["type" => "mediumtext", "comment" => ""] + "name_cache" => ["type" => "tinytext", "comment" => "Cached bbcode parsing of name"], + "msg_cache" => ["type" => "mediumtext", "comment" => "Cached bbcode parsing of msg"] ], "indexes" => [ "PRIMARY" => ["id"], @@ -1336,7 +1421,7 @@ class DBStructure $database["notify-threads"] = [ "comment" => "", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "notify-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["notify" => "id"], "comment" => ""], "master-parent-item" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""], "parent-item" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""], @@ -1349,24 +1434,38 @@ class DBStructure $database["oembed"] = [ "comment" => "cache for OEmbed queries", "fields" => [ - "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => ""], - "maxwidth" => ["type" => "mediumint unsigned", "not null" => "1", "primary" => "1", "comment" => ""], - "content" => ["type" => "mediumtext", "comment" => ""], - "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], + "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "page url"], + "maxwidth" => ["type" => "mediumint unsigned", "not null" => "1", "primary" => "1", "comment" => "Maximum width passed to Oembed"], + "content" => ["type" => "mediumtext", "comment" => "OEmbed data of the page"], + "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of creation"], ], "indexes" => [ "PRIMARY" => ["url", "maxwidth"], "created" => ["created"], ] ]; + $database["openwebauth-token"] = [ + "comment" => "Store OpenWebAuth token to verify contacts", + "fields" => [ + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], + "type" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => "Verify type"], + "token" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A generated token"], + "meta" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], + "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of creation"], + ], + "indexes" => [ + "PRIMARY" => ["id"], + ] + ]; $database["parsed_url"] = [ "comment" => "cache for 'parse_url' queries", "fields" => [ - "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => ""], - "guessing" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => ""], - "oembed" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => ""], - "content" => ["type" => "mediumtext", "comment" => ""], - "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], + "url" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "page url"], + "guessing" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => "is the 'guessing' mode active?"], + "oembed" => ["type" => "boolean", "not null" => "1", "default" => "0", "primary" => "1", "comment" => "is the data the result of oembed?"], + "content" => ["type" => "mediumtext", "comment" => "page data"], + "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of creation"], ], "indexes" => [ "PRIMARY" => ["url", "guessing", "oembed"], @@ -1399,19 +1498,34 @@ class DBStructure "uid_cat_k" => ["UNIQUE", "uid", "cat", "k"], ] ]; + $database["permissionset"] = [ + "comment" => "", + "fields" => [ + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner id of this permission set"], + "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>'"], + "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"], + "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"], + "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"], + ], + "indexes" => [ + "PRIMARY" => ["id"], + "uid_allow_cid_allow_gid_deny_cid_deny_gid" => ["allow_cid(50)", "allow_gid(30)", "deny_cid(50)", "deny_gid(30)"], + ] + ]; $database["photo"] = [ "comment" => "photo storage", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], - "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""], - "guid" => ["type" => "char(16)", "not null" => "1", "default" => "", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"], + "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id"], + "guid" => ["type" => "char(16)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this photo"], "resource-id" => ["type" => "char(32)", "not null" => "1", "default" => "", "comment" => ""], - "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], - "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], + "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "creation date"], + "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "last edited date"], "title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "desc" => ["type" => "text", "comment" => ""], - "album" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], + "album" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "The name of the album to which the photo belongs"], "filename" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "type" => ["type" => "varchar(30)", "not null" => "1", "default" => "image/jpeg"], "height" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""], @@ -1420,10 +1534,10 @@ class DBStructure "data" => ["type" => "mediumblob", "not null" => "1", "comment" => ""], "scale" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""], "profile" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "allow_cid" => ["type" => "mediumtext", "comment" => ""], - "allow_gid" => ["type" => "mediumtext", "comment" => ""], - "deny_cid" => ["type" => "mediumtext", "comment" => ""], - "deny_gid" => ["type" => "mediumtext", "comment" => ""], + "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>'"], + "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"], + "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"], + "deny_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied groups"], ], "indexes" => [ "PRIMARY" => ["id"], @@ -1459,7 +1573,7 @@ class DBStructure $database["poll_result"] = [ "comment" => "data for polls - currently unused", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "poll_id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["poll" => "id"]], "choice" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""], ], @@ -1483,14 +1597,14 @@ class DBStructure $database["profile"] = [ "comment" => "user profiles data", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], - "profile-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "is-default" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "hide-friends" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"], + "profile-name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name of the profile"], + "is-default" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Mark this profile as default profile"], + "hide-friends" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Hide friend list from viewers of this profile"], "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "pdesc" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "dob" => ["type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00", "comment" => ""], + "pdesc" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Title or description"], + "dob" => ["type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00", "comment" => "Day of birth"], "address" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "locality" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "region" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], @@ -1523,8 +1637,8 @@ class DBStructure "xmpp" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "thumb" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "publish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "net-publish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], + "publish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "publish default profile in local directory"], + "net-publish" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "publish profile in global directory"], ], "indexes" => [ "PRIMARY" => ["id"], @@ -1534,9 +1648,9 @@ class DBStructure $database["profile_check"] = [ "comment" => "DFRN remote auth use", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], - "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""], + "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id"], "dfrn_id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "sec" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""], @@ -1548,7 +1662,7 @@ class DBStructure $database["push_subscriber"] = [ "comment" => "Used for OStatus: Contains feed subscribers", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], "callback_url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "topic" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], @@ -1567,7 +1681,7 @@ class DBStructure $database["queue"] = [ "comment" => "Queue for messages that couldn't be delivered", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Message receiver"], "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Receiver's network"], "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Unique GUID of the message"], @@ -1587,7 +1701,7 @@ class DBStructure $database["register"] = [ "comment" => "registrations requiring admin approval", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "hash" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], @@ -1602,7 +1716,7 @@ class DBStructure $database["search"] = [ "comment" => "", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], "term" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], ], @@ -1614,7 +1728,7 @@ class DBStructure $database["session"] = [ "comment" => "web session storage", "fields" => [ - "id" => ["type" => "bigint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], + "id" => ["type" => "bigint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "sid" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""], "data" => ["type" => "text", "comment" => ""], "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""], @@ -1628,8 +1742,8 @@ class DBStructure $database["sign"] = [ "comment" => "Diaspora signatures", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], - "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], + "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["item" => "id"], "comment" => "item.id"], "signed_text" => ["type" => "mediumtext", "comment" => ""], "signature" => ["type" => "text", "comment" => ""], "signer" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], @@ -1652,7 +1766,6 @@ class DBStructure "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], "received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "aid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""], "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], ], "indexes" => [ @@ -1666,11 +1779,11 @@ class DBStructure $database["thread"] = [ "comment" => "Thread related data", "fields" => [ - "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["item" => "id"], "comment" => ""], + "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["item" => "id"], "comment" => "sequential ID"], "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""], - "owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""], - "author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""], + "owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Item owner"], + "author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Item author"], "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], "edited" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], "commented" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], @@ -1681,16 +1794,16 @@ class DBStructure "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "spam" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "ignored" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "bookmark" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], + "post-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Post type (personal note, bookmark, ...)"], "unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""], "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "forum_mode" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""], "mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""], + "bookmark" => ["type" => "boolean", "comment" => ""], ], "indexes" => [ "PRIMARY" => ["iid"], @@ -1724,50 +1837,50 @@ class DBStructure $database["user"] = [ "comment" => "The local users", "fields" => [ - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "parent-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "The parent user that has full control about this user"], - "guid" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""], - "username" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "password" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], + "guid" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this user"], + "username" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this user is known by"], + "password" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "encrypted password"], "legacy_password" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Is the password hash double-hashed?"], - "nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "email" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], + "nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "nick- and user name"], + "email" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "the users email address"], "openid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "timezone" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => ""], - "language" => ["type" => "varchar(32)", "not null" => "1", "default" => "en", "comment" => ""], - "register_date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], - "login_date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], - "default-location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "allow_location" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "theme" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "pubkey" => ["type" => "text", "comment" => ""], - "prvkey" => ["type" => "text", "comment" => ""], + "timezone" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => "PHP-legal timezone"], + "language" => ["type" => "varchar(32)", "not null" => "1", "default" => "en", "comment" => "default language"], + "register_date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "timestamp of registration"], + "login_date" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "timestamp of last login"], + "default-location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Default for item.location"], + "allow_location" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 allows to display the location"], + "theme" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "user theme preference"], + "pubkey" => ["type" => "text", "comment" => "RSA public key 4096 bit"], + "prvkey" => ["type" => "text", "comment" => "RSA private key 4096 bit"], "spubkey" => ["type" => "text", "comment" => ""], "sprvkey" => ["type" => "text", "comment" => ""], - "verified" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "blocked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "blockwall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "hidewall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "blocktags" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "unkmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], + "verified" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "user is verified through email"], + "blocked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 for user is blocked"], + "blockwall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Prohibit contacts to post to the profile page of the user"], + "hidewall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Hide profile details from unkown viewers"], + "blocktags" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Prohibit contacts to tag the post of this user"], + "unkmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Permit unknown people to send private mails to this user"], "cntunkmail" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""], - "notify-flags" => ["type" => "smallint unsigned", "not null" => "1", "default" => "65535", "comment" => ""], - "page-flags" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""], + "notify-flags" => ["type" => "smallint unsigned", "not null" => "1", "default" => "65535", "comment" => "email notification options"], + "page-flags" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "page/profile type"], "account-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""], "prvnets" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "pwdreset" => ["type" => "varchar(255)", "comment" => "Password reset request token"], "pwdreset_time" => ["type" => "datetime", "comment" => "Timestamp of the last password reset request"], "maxreq" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""], "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""], - "account_removed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], + "account_removed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if 1 the account is removed"], "account_expired" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "account_expires_on" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], - "expire_notification_sent" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""], + "account_expires_on" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "timestamp when account expires and will be deleted"], + "expire_notification_sent" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "timestamp of last warning of account expiration"], "def_gid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""], - "allow_cid" => ["type" => "mediumtext", "comment" => ""], - "allow_gid" => ["type" => "mediumtext", "comment" => ""], - "deny_cid" => ["type" => "mediumtext", "comment" => ""], - "deny_gid" => ["type" => "mediumtext", "comment" => ""], + "allow_cid" => ["type" => "mediumtext", "comment" => "default permission for this user"], + "allow_gid" => ["type" => "mediumtext", "comment" => "default permission for this user"], + "deny_cid" => ["type" => "mediumtext", "comment" => "default permission for this user"], + "deny_gid" => ["type" => "mediumtext", "comment" => "default permission for this user"], "openidserver" => ["type" => "text", "comment" => ""], ], "indexes" => [ @@ -1778,7 +1891,7 @@ class DBStructure $database["userd"] = [ "comment" => "Deleted usernames", "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "username" => ["type" => "varchar(255)", "not null" => "1", "comment" => ""], ], "indexes" => [ @@ -1797,6 +1910,18 @@ class DBStructure "PRIMARY" => ["uid", "iid"], ] ]; + $database["worker-ipc"] = [ + "comment" => "Inter process communication between the frontend and the worker", + "fields" => [ + "key" => ["type" => "int", "not null" => "1", "primary" => "1", "comment" => ""], + "jobs" => ["type" => "boolean", "comment" => "Flag for outstanding jobs"], + ], + "indexes" => [ + "PRIMARY" => ["key"], + ], + "engine" => "MEMORY", + ]; + $database["workerqueue"] = [ "comment" => "Background tasks queue entries", "fields" => [ @@ -1806,7 +1931,7 @@ class DBStructure "created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Creation date"], "pid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "Process id of the worker"], "executed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Execution date"], - "done" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Marked when the task was done, will be deleted later"], + "done" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Marked 1 when the task was done - will be deleted later"], ], "indexes" => [ "PRIMARY" => ["id"], @@ -1817,7 +1942,7 @@ class DBStructure ] ]; - \Friendica\Core\Addon::callHooks('dbstructure_definition', $database); + Addon::callHooks('dbstructure_definition', $database); return $database; }