MDL-26811 upgrade Fixed up default handling causing exception on upgrade of used...
authorSam Hemelryk <sam@moodle.com>
Fri, 26 Aug 2011 02:58:55 +0000 (14:58 +1200)
committerSam Hemelryk <sam@moodle.com>
Tue, 30 Aug 2011 23:34:21 +0000 (11:34 +1200)
lib/db/upgrade.php

index 742faa8..8d415c7 100644 (file)
@@ -1230,8 +1230,14 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
         $field = new xmldb_field('backuptype', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null, 'info');
     /// Conditionally Launch add field backuptype and set all old records as 'scheduledbackup' records.
         if (!$dbman->field_exists($table, $field)) {
+            // Set the default we want applied to any existing records
+            $field->setDefault('scheduledbackup');
+            // Add the field to the database
             $dbman->add_field($table, $field);
-            $DB->execute("UPDATE {backup_log} SET backuptype='scheduledbackup'");
+            // Remove the default
+            $field->setDefault(null);
+            // Update the database to remove the default
+            $dbman->change_field_default($table, $field);
         }
 
     /// Main savepoint reached