Merge branch 'MDL-29089_grade_history_missing_columns2' of git://github.com/andyjdavi...
authorAparup Banerjee <aparup@moodle.com>
Tue, 4 Oct 2011 18:44:28 +0000 (02:44 +0800)
committerAparup Banerjee <aparup@moodle.com>
Tue, 4 Oct 2011 18:46:38 +0000 (02:46 +0800)
1  2 
lib/db/upgrade.php
version.php

index 1b5b30b,29759be..f274442
mode 100644,100755..100755
          upgrade_main_savepoint(true, 2011091600.01);
      }
  
 -    if ($oldversion < 2011092800.00) {
++    if ($oldversion < 2011092800.01) {
+         // Check for potential missing columns in the grade_items_history
+         $table = new xmldb_table('grade_items_history');
+         $field = new xmldb_field('display', XMLDB_TYPE_INTEGER, '10', XMLDB_TYPE_INTEGER, XMLDB_NOTNULL, null, 0, 'sortorder');
+         if (!$dbman->field_exists($table, $field)) {
+             $dbman->add_field($table, $field);
+         }
+         $field = new xmldb_field('decimals', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, 'display');
+         if (!$dbman->field_exists($table, $field)) {
+             $dbman->add_field($table, $field);
+         } else {
+             //check that the grade_items_history.decimals allows nulls
+             //Somehow some Moodle databases have this column marked as "not null"
+             $columns = $DB->get_columns('grade_items_history');
+             if (array_key_exists('display', $columns) && !empty($columns['display']->not_null)) {
+                 $dbman->change_field_notnull($table, $field);
+             }
+         }
+         // Main savepoint reached
 -        upgrade_main_savepoint(true, 2011092800.00);
++        upgrade_main_savepoint(true, 2011092800.01);
+     }
 -    if ($oldversion < 2011092800.01) {
++    if ($oldversion < 2011092800.02) {
+         // Check for potential missing columns in the grade_categories_history
+         $table = new xmldb_table('grade_categories_history');
+         $field = new xmldb_field('hidden', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0, 'timemodified');
+         if (!$dbman->field_exists($table, $field)) {
+             $dbman->add_field($table, $field);
+         }
+         // Main savepoint reached
 -        upgrade_main_savepoint(true, 2011092800.01);
++        upgrade_main_savepoint(true, 2011092800.02);
+     }
 -    if ($oldversion < 2011092800.02) {
++    if ($oldversion < 2011092800.03) {
+         // Check for potential missing columns in the grade_outcomes_history
+         $table = new xmldb_table('grade_outcomes_history');
+         $field = new xmldb_field('descriptionformat', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0, 'description');
+         if (!$dbman->field_exists($table, $field)) {
+             $dbman->add_field($table, $field);
+         }
+         // Main savepoint reached
 -        upgrade_main_savepoint(true, 2011092800.02);
++        upgrade_main_savepoint(true, 2011092800.03);
+     }
      return true;
  }
  
diff --cc version.php
@@@ -31,7 -31,7 +31,7 @@@ defined('MOODLE_INTERNAL') || die()
  
  
  
- $version  = 2011092800.00;              // YYYYMMDD      = weekly release date of this DEV branch
 -$version  = 2011092800.02;              // YYYYMMDD      = weekly release date of this DEV branch
++$version  = 2011092800.03;              // YYYYMMDD      = weekly release date of this DEV branch
                                          //         RR    = release increments - 00 in DEV branches
                                          //           .XX = incremental changes