]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-14548, modify the notification field in data module to NOT NULL and default...
authordongsheng <dongsheng>
Tue, 29 Apr 2008 06:42:18 +0000 (06:42 +0000)
committerdongsheng <dongsheng>
Tue, 29 Apr 2008 06:42:18 +0000 (06:42 +0000)
mod/data/db/install.xml
mod/data/db/upgrade.php
mod/data/version.php

index a059a2f886a4d83118caa51451aea2940903b85c..d4fd6ac5b378a16a3650e0f0a292b68e37dd7029 100644 (file)
@@ -35,7 +35,7 @@
         <FIELD NAME="defaultsort" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="assessed" NEXT="defaultsortdir"/>
         <FIELD NAME="defaultsortdir" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="defaultsort" NEXT="editany"/>
         <FIELD NAME="editany" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="defaultsortdir" NEXT="notification"/>
-        <FIELD NAME="notification" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="false" SEQUENCE="false" ENUM="false" COMMENT="Notify people when things change" PREVIOUS="editany"/>
+        <FIELD NAME="notification" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Notify people when things change" PREVIOUS="editany"/>
       </FIELDS>
       <KEYS>
         <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
       </SENTENCES>
     </STATEMENT>
   </STATEMENTS>
-</XMLDB>
\ No newline at end of file
+</XMLDB>
index f7f7a65d894622ba49ceaa3b1c58374b43b84686..a10e12dbd5702194336b98f02c8e8d4b3203da9d 100644 (file)
@@ -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');
index 04777774f3e0f6ab5fe334b450a2694daca4efb2..32d027c0be8e7660d44ed9bb8d42d6d9e55ad8b3 100644 (file)
@@ -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;