database MDL-24470 rerun database upgrade of the notification column (NOT NULL and...
authorjerome mouneyrac <jerome@moodle.com>
Fri, 1 Oct 2010 09:39:01 +0000 (09:39 +0000)
committerjerome mouneyrac <jerome@moodle.com>
Fri, 1 Oct 2010 09:39:01 +0000 (09:39 +0000)
mod/data/db/upgrade.php
mod/data/version.php

index 438b199..03f3123 100644 (file)
@@ -297,6 +297,22 @@ function xmldb_data_upgrade($oldversion) {
         upgrade_mod_savepoint(true, 2010042800, 'data');
     }
 
+    //rerun the upgrade see MDL-24470
+    if ($oldversion < 2010100101) {
+        // Upgrade all the data->notification currently being
+        // NULL to 0
+        $sql = "UPDATE {data} SET notification=0 WHERE notification IS NULL";
+        $DB->execute($sql);
+
+        $table = new xmldb_table('data');
+        $field = new xmldb_field('notification', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'editany');
+        // First step, Set NOT NULL
+        $dbman->change_field_notnull($table, $field);
+        // Second step, Set default to 0
+        $dbman->change_field_default($table, $field);
+        upgrade_mod_savepoint(true, 2010100101, 'data');
+    }
+
     return true;
 }
 
index 7807f5a..b57666a 100644 (file)
@@ -5,7 +5,7 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2010080300;
+$module->version  = 2010100101;
 $module->requires = 2010080300;  // Requires this Moodle version
 $module->cron     = 60;