]> git.mjollnir.org Git - moodle.git/commitdiff
Checking one table and one column that, uder some servers didn't get
authorstronk7 <stronk7>
Thu, 27 Apr 2006 22:56:25 +0000 (22:56 +0000)
committerstronk7 <stronk7>
Thu, 27 Apr 2006 22:56:25 +0000 (22:56 +0000)
correctly upgraded. Bug 5321. PG need testing!
(http://moodle.org/bugs/bug.php?op=show&bugid=5321)

mod/quiz/db/mysql.php
mod/quiz/db/postgres7.php
mod/quiz/version.php

index a88c2f7f42e54d14bb17786a2697638a285a0b27..ac46c56e0807793d83db52e8096c14315e4ce751 100644 (file)
@@ -1019,6 +1019,22 @@ function quiz_upgrade($oldversion) {
         table_column('question', 'version', 'version', 'varchar', 255);
     }
 
+    if ($oldversion < 2006042800) {
+        // Check we have some un-renamed tables (verified in some servers)
+        if ($tables = $db->MetaTables('TABLES')) {
+            if (in_array($CFG->prefix.'quiz_randommatch', $tables) &&
+                !in_array($CFG->prefix.'question_randomsamatch', $tables)) {
+                modify_database ("", "ALTER TABLE prefix_quiz_randommatch RENAME prefix_question_randomsamatch ");
+            }
+            // Check for one possible missing field in one table
+            if ($columns = $db->MetaColumnNames($CFG->prefix.'question_randomsamatch')) {
+                if (!in_array('shuffleanswers', $columns)) {
+                    table_column('question_randomsamatch', '', 'shuffleanswers', 'tinyint', '4', 'unsigned', '1', 'not null', 'choose');
+                }
+            }
+        }
+    }
+
     return true;
 }
 
index a0ea972f22664dd9aef273c1291a8c8a9a8cb871..5b3e37f1650cc8df767728f3aedf8d5c9f433f2c 100644 (file)
@@ -1188,6 +1188,24 @@ function quiz_upgrade($oldversion) {
         table_column('question', 'version', 'version', 'varchar', 255);
     }
 
+    if ($oldversion < 2006042800) {
+        // Check we have some un-renamed tables (verified in some servers)
+        if ($tables = $db->MetaTables('TABLES')) {
+            if (in_array($CFG->prefix.'quiz_randommatch', $tables) &&
+                !in_array($CFG->prefix.'question_randomsamatch', $tables)) {
+                modify_database ("", "ALTER TABLE prefix_quiz_randommatch RENAME prefix_question_randomsamatch ");
+                modify_database ("", "ALTER TABLE prefix_quiz_randommatch_id_seq RENAME prefix_question_randomsamatch_id_seq ");
+                execute_sql('ALTER TABLE '.$CFG->prefix.'question_randomsamatch ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'question_randomsamatch_id_seq\')',false);
+            }
+            // Check for one possible missing field in one table
+            if ($columns = $db->MetaColumnNames($CFG->prefix.'question_randomsamatch')) {
+                if (!in_array('shuffleanswers', $columns)) {
+                    table_column('question_randomsamatch', '', 'shuffleanswers', 'tinyint', '4', 'unsigned', '1', 'not null', 'choose');
+                }
+            }
+        }
+    }
+
     return true;
 }
 
index da7a2881e4aa378da13c4848aff69639be08c024..abdfb06f0a98610f045ba6f18dad9fc0d611e2bc 100644 (file)
@@ -5,7 +5,7 @@
 //  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2006041001;   // The (date) version of this module
+$module->version  = 2006042800;   // The (date) version of this module
 $module->requires = 2006022400;   // Requires this Moodle version
 $module->cron     = 0;            // How often should cron check this module (seconds)?