From: dongsheng Date: Tue, 29 Apr 2008 06:42:18 +0000 (+0000) Subject: "MDL-14548, modify the notification field in data module to NOT NULL and default... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f4306412476760df3af8c7c567e1b5d50f07d57a;p=moodle.git "MDL-14548, modify the notification field in data module to NOT NULL and default value 0, see tracker" --- diff --git a/mod/data/db/install.xml b/mod/data/db/install.xml index a059a2f886..d4fd6ac5b3 100644 --- a/mod/data/db/install.xml +++ b/mod/data/db/install.xml @@ -35,7 +35,7 @@ - + @@ -144,4 +144,4 @@ - \ No newline at end of file + diff --git a/mod/data/db/upgrade.php b/mod/data/db/upgrade.php index f7f7a65d89..a10e12dbd5 100644 --- a/mod/data/db/upgrade.php +++ b/mod/data/db/upgrade.php @@ -96,8 +96,21 @@ function xmldb_data_upgrade($oldversion=0) { $result = $result && add_index($table, $index); } } + if ($result && $oldversion < 2007101512) { + // Upgrade all the data->notification currently being + // NULL to 0 + $sql = "UPDATE {$CFG->prefix}data SET notification=0 WHERE notification IS NULL"; + $result = execute_sql($sql); + $table = new XMLDBTable('data'); + $field = new XMLDBField('notification'); + // First step, Set NOT NULL + $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'editany'); + $result = $result && change_field_notnull($table, $field); + // Second step, Set default to 0 + $result = $result && change_field_default($table, $field); + } - if ($result && $oldversion < 2007101512) { + if ($result && $oldversion < 2007101513) { /// Launch add field asearchtemplate again if does not exists yet - reported on several sites $table = new XMLDBTable('data'); diff --git a/mod/data/version.php b/mod/data/version.php index 04777774f3..32d027c0be 100644 --- a/mod/data/version.php +++ b/mod/data/version.php @@ -5,7 +5,7 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2007101512; +$module->version = 2007101513; $module->requires = 2007101509; // Requires this Moodle version $module->cron = 60;