X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fdbstructure.php;h=deb6ddf5330639acab34f8fe11f1eb6ebb0a4d4c;hb=17b1d459687ec068dd5bd968196f8afc8660b14d;hp=f131abe64f13b489621c85114536ce3b3f6524cd;hpb=7c33c9cca16aa57f5a96c7f2dea8a181653fe0e8;p=friendica.git diff --git a/include/dbstructure.php b/include/dbstructure.php index f131abe64f..deb6ddf533 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -120,7 +120,7 @@ function print_structure($database) { } } -function update_structure($verbose, $action) { +function update_structure($verbose, $action, $tables=null, $definition=null) { global $a, $db; $errors = false; @@ -130,7 +130,8 @@ function update_structure($verbose, $action) { // Get the current structure $database = array(); - $tables = q("show tables"); + if (is_null($tables)) + $tables = q("show tables"); foreach ($tables AS $table) { $table = current($table); @@ -139,7 +140,8 @@ function update_structure($verbose, $action) { } // Get the definition - $definition = db_definition(); + if (is_null($definition)) + $definition = db_definition(); // Compare it foreach ($definition AS $name => $structure) { @@ -149,9 +151,9 @@ function update_structure($verbose, $action) { if(false === $r) $errors .= t('Errors encountered creating database tables.').$name.EOL; } else { - // Drop the index if it isn't present in the definition + // Drop the index if it isn't present in the definition and index name doesn't start with "local_" foreach ($database[$name]["indexes"] AS $indexname => $fieldnames) - if (!isset($structure["indexes"][$indexname])) { + if (!isset($structure["indexes"][$indexname]) && substr($indexname, 0, 6) != 'local_') { $sql2=db_drop_index($indexname); if ($sql3 == "") $sql3 = "ALTER TABLE `".$name."` ".$sql2; @@ -362,6 +364,7 @@ function db_definition() { "fields" => array( "k" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"), "v" => array("type" => "text", "not null" => "1"), + "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), ), "indexes" => array( @@ -449,10 +452,12 @@ function db_definition() { "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "last-update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "success_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), + "failure_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "name-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), + "last-item" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"), "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"), "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), @@ -622,21 +627,28 @@ function db_definition() { "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"), + "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"), + "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"), "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "about" => array("type" => "text", "not null" => "1"), "keywords" => array("type" => "text", "not null" => "1"), "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""), + "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"), + "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), ), "indexes" => array( "PRIMARY" => array("id"), "nurl" => array("nurl"), + "updated" => array("updated"), ) ); $database["glink"] = array( @@ -680,14 +692,42 @@ function db_definition() { "uid_gid_contactid" => array("uid","gid","contact-id"), ) ); + $database["gserver"] = array( + "fields" => array( + "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), + "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "info" => array("type" => "text", "not null" => "1"), + "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), + "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""), + "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), + "last_poco_query" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"), + "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"), + "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"), + ), + "indexes" => array( + "PRIMARY" => array("id"), + "nurl" => array("nurl"), + ) + ); $database["guid"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""), ), "indexes" => array( "PRIMARY" => array("id"), "guid" => array("guid"), + "plink" => array("plink"), + "uri" => array("uri"), ) ); $database["hook"] = array( @@ -922,6 +962,7 @@ function db_definition() { "msg" => array("type" => "mediumtext", "not null" => "1"), "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), @@ -1341,6 +1382,20 @@ function db_definition() { "username" => array("username"), ) ); + $database["workerqueue"] = array( + "fields" => array( + "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), + "parameter" => array("type" => "text", "not null" => "1"), + "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"), + "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), + "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), + "executed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), + ), + "indexes" => array( + "PRIMARY" => array("id"), + "created" => array("created"), + ) + ); return($database); }