]> git.mxchange.org Git - friendica.git/blobdiff - include/dbstructure.php
Merge remote-tracking branch 'upstream/develop' into 1610-performance-nodeinfo
[friendica.git] / include / dbstructure.php
index 21545153b89f2013f5be7b8472b910fd9fe04497..32d5986fe97f27398f51b0af1e0a0bd446c2e2ca 100644 (file)
@@ -126,6 +126,9 @@ function print_structure($database, $charset) {
 function update_structure($verbose, $action, $tables=null, $definition=null) {
        global $a, $db;
 
+       if ($action)
+               set_config('system', 'maintenance', 1);
+
        if (isset($a->config["system"]["db_charset"]))
                $charset = $a->config["system"]["db_charset"];
        else
@@ -241,6 +244,9 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
                }
        }
 
+       if ($action)
+               set_config('system', 'maintenance', 0);
+
        return $errors;
 }
 
@@ -336,7 +342,6 @@ function db_create_index($indexname, $fieldnames, $method="ADD") {
        }
 
        if ($indexname == "PRIMARY") {
-               //return sprintf("%s PRIMARY KEY(`%s`)", $method, implode("`,`", $fieldnames));
                return sprintf("%s PRIMARY KEY(%s)", $method, $names);
        }
 
@@ -681,6 +686,7 @@ function db_definition($charset) {
                                        "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
                                        "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
                                        "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
+                                       "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
                                        "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
                                        "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
                                        "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
@@ -1487,6 +1493,22 @@ function dbstructure_run(&$argv, &$argc) {
                switch ($argv[1]) {
                        case "update":
                                update_structure(true, true);
+
+                               $build = get_config('system','build');
+                               if (!x($build)) {
+                                       set_config('system','build',DB_UPDATE_VERSION);
+                                       $build = DB_UPDATE_VERSION;
+                               }
+
+                               $stored = intval($build);
+                               $current = intval(DB_UPDATE_VERSION);
+
+                               // run any left update_nnnn functions in update.php
+                               for($x = $stored; $x < $current; $x ++) {
+                                       $r = run_update_function($x);
+                                       if (!$r) break;
+                               }
+
                                set_config('system','build',DB_UPDATE_VERSION);
                                return;
                        case "dumpsql":