]> git.mxchange.org Git - friendica.git/blobdiff - include/dbstructure.php
Merge pull request #2853 from annando/1610-bugfix-config
[friendica.git] / include / dbstructure.php
index d3b148b2a8bfbf6b4e3dc83dbe4c7cc5e4e73bd2..fdf09d90def8abd034d0801540fa02ca2ed744b4 100644 (file)
@@ -166,7 +166,8 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
                @$db->q($sql_config);
 
        // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
-       if (version_compare($db->server_info(), '5.7.4') >= 0) {
+       if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
+               !(strpos($db->server_info(), 'MariaDB') !== false)) {
                $ignore = '';
        }else {
                $ignore = ' IGNORE';
@@ -196,7 +197,7 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
                                if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
                                        $sql2=db_drop_index($indexname);
                                        if ($sql3 == "")
-                                               $sql3 = "ALTER TABLE `".$name."` ".$sql2;
+                                               $sql3 = "ALTER".$ignore." TABLE `".$name."` ".$sql2;
                                        else
                                                $sql3 .= ", ".$sql2;
                                }
@@ -708,6 +709,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" => ""),
@@ -1517,6 +1519,22 @@ function dbstructure_run(&$argv, &$argc) {
                                return;
                        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":