]> git.mxchange.org Git - friendica.git/commitdiff
Deactivated the alternative update script by now
authorMichael <heluecht@pirati.ca>
Mon, 16 Jan 2017 21:35:35 +0000 (21:35 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 16 Jan 2017 21:35:35 +0000 (21:35 +0000)
boot.php
include/dbstructure.php
update.php

index cd6db384a2486a3ff78643b90486694713657ec3..e95cbc9d2250471ee40316d6d53c43f2cfcd5a21 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -38,7 +38,7 @@ define ( 'FRIENDICA_PLATFORM',     'Friendica');
 define ( 'FRIENDICA_CODENAME',     'Asparagus');
 define ( 'FRIENDICA_VERSION',      '3.5.1-dev' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.23'    );
-define ( 'DB_UPDATE_VERSION',      1212      );
+define ( 'DB_UPDATE_VERSION',      1213      );
 
 /**
  * @brief Constant with a HTML line break.
index 9a84cfbc8d441dc6ce3d75f79f232aa27ef301d1..c1dc1ba877163d89ae588eba17cf826a818d4ec7 100644 (file)
@@ -208,9 +208,10 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
                                if ($current_index_definition != $new_index_definition) {
                                        if ($fieldnames[0] == "UNIQUE") {
                                                $is_unique = true;
-                                               if ($ignore == "") {
-                                                       $temp_name = "temp-".$name;
-                                               }
+                                               // Deactivated. See below for the reason
+                                               //if ($ignore == "") {
+                                               //      $temp_name = "temp-".$name;
+                                               //}
                                        }
                                }
                        }
@@ -292,44 +293,44 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
                        if ($verbose) {
                                // Ensure index conversion to unique removes duplicates
                                if ($is_unique) {
-                                       if ($ignore != "") {
+                                       // By now the alternative is commented out.
+                                       // This is a preparation for the time when we found a good SQL routine.
+                                       //if ($ignore != "") {
                                                echo "SET session old_alter_table=1;\n";
-                                       } else {
-                                               echo "DROP TABLE IF EXISTS `".$temp_name."`;\n";
-                                               echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
-                                       }
+                                       //} else {
+                                       //      echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
+                                       //}
                                }
 
                                echo $sql3."\n";
 
                                if ($is_unique) {
-                                       if ($ignore != "") {
+                                       // By now the alternative is commented out.
+                                       // This is a preparation for the time when we found a good SQL routine.
+                                       //if ($ignore != "") {
                                                echo "SET session old_alter_table=0;\n";
-                                       } else {
-                                               echo "INSERT IGNORE INTO `".$temp_name."` SELECT * FROM `".$name."`;\n";
-                                               echo "DROP TABLE `".$name."`;\n";
-                                               echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
-                                       }
+                                       //} else {
+                                       //      echo "INSERT IGNORE INTO `".$temp_name."` SELECT * FROM `".$name."`;\n";
+                                       //      echo "DROP TABLE `".$name."`;\n";
+                                       //      echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
+                                       //}
                                }
                        }
 
                        if ($action) {
                                // Ensure index conversion to unique removes duplicates
                                if ($is_unique) {
-                                       if ($ignore != "") {
+                                       // By now the alternative is commented out.
+                                       // This is a preparation for the time when we found a good SQL routine.
+                                       //if ($ignore != "") {
                                                $db->q("SET session old_alter_table=1;");
-                                       } else {
-                                               $r = $db->q("DROP TABLE IF EXISTS `".$temp_name."`;");
-                                               if (!dbm::is_result($r)) {
-                                                       $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
-                                                       return $errors;
-                                               }
-                                               $r = $db->q("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
-                                               if (!dbm::is_result($r)) {
-                                                       $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
-                                                       return $errors;
-                                               }
-                                       }
+                                       //} else {
+                                       //      $r = $db->q("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
+                                       //      if (!dbm::is_result($r)) {
+                                       //              $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
+                                       //              return $errors;
+                                       //      }
+                                       //}
                                }
 
                                $r = @$db->q($sql3);
@@ -337,25 +338,28 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
                                        $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
 
                                if ($is_unique) {
-                                       if ($ignore != "") {
+                                       // By now the alternative is commented out.
+                                       // This is a preparation for the time when we found a good SQL routine.
+                                       //if ($ignore != "") {
                                                $db->q("SET session old_alter_table=0;");
-                                       } else {
-                                               $r = $db->q("INSERT IGNORE INTO `".$temp_name."` SELECT * FROM `".$name."`;");
-                                               if (!dbm::is_result($r)) {
-                                                       $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
-                                                       return $errors;
-                                               }
-                                               $r = $db->q("DROP TABLE `".$name."`;");
-                                               if (!dbm::is_result($r)) {
-                                                       $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
-                                                       return $errors;
-                                               }
-                                               $r = $db->q("RENAME TABLE `".$temp_name."` TO `".$name."`;");
-                                               if (!dbm::is_result($r)) {
-                                                       $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
-                                                       return $errors;
-                                               }
-                                       }
+                                       //} else {
+                                       //      We have to check if "INSERT IGNORE" will work on newer MySQL versions
+                                       //      $r = $db->q("INSERT IGNORE INTO `".$temp_name."` SELECT * FROM `".$name."`;");
+                                       //      if (!dbm::is_result($r)) {
+                                       //              $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
+                                       //              return $errors;
+                                       //      }
+                                       //      $r = $db->q("DROP TABLE `".$name."`;");
+                                       //      if (!dbm::is_result($r)) {
+                                       //              $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
+                                       //              return $errors;
+                                       //      }
+                                       //      $r = $db->q("RENAME TABLE `".$temp_name."` TO `".$name."`;");
+                                       //      if (!dbm::is_result($r)) {
+                                       //              $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
+                                       //              return $errors;
+                                       //      }
+                                       //}
                                }
                        }
                }
@@ -1260,7 +1264,7 @@ function db_definition($charset) {
                                        ),
                        "indexes" => array(
                                        "PRIMARY" => array("id"),
-                                       "poll_id" => array("poll_id"),
+                                       "poll_id" => array("UNIQUE", "poll_id"),
                                        "choice" => array("choice"),
                                        )
                        );
index 058536d82195421998d75b4069f0515af15917ec..25d6cb9cbffb11212729c291cf433d82b0ffb62d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-define('UPDATE_VERSION' , 1212);
+define('UPDATE_VERSION' , 1213);
 
 /**
  *