From 70e61f70718ccc0742df020e950dcdf1cb5f30ca Mon Sep 17 00:00:00 2001 From: "Andrew Davis (andyjdavis)" Date: Mon, 26 Sep 2011 15:57:40 +0800 Subject: [PATCH] MDL-29089 gradebook: added missing columns to the history tables --- lib/db/install.xml | 14 ++++++++----- lib/db/upgrade.php | 50 ++++++++++++++++++++++++++++++++++++++++++++++ version.php | 2 +- 3 files changed, 60 insertions(+), 6 deletions(-) mode change 100644 => 100755 lib/db/install.xml mode change 100644 => 100755 lib/db/upgrade.php diff --git a/lib/db/install.xml b/lib/db/install.xml old mode 100644 new mode 100755 index 0e5615bd227..c98f8880ed3 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1,5 +1,5 @@ - @@ -1820,7 +1820,8 @@ - + + @@ -1851,7 +1852,8 @@ - + + @@ -1895,7 +1897,9 @@ - + + + @@ -2782,4 +2786,4 @@ - + \ No newline at end of file diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php old mode 100644 new mode 100755 index 1b5b30bcf09..29759be43c1 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -6728,6 +6728,56 @@ FROM upgrade_main_savepoint(true, 2011091600.01); } + if ($oldversion < 2011092800.00) { + // 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); + } + + if ($oldversion < 2011092800.01) { + // 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); + } + + if ($oldversion < 2011092800.02) { + // 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); + } + return true; } diff --git a/version.php b/version.php index 78a00519490..a301da69b9f 100644 --- a/version.php +++ b/version.php @@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2011092100.00; // YYYYMMDD = weekly release date of this DEV branch +$version = 2011092800.02; // YYYYMMDD = weekly release date of this DEV branch // RR = release increments - 00 in DEV branches // .XX = incremental changes