From: Francois Marier <francois@catalyst.net.nz>
Date: Tue, 23 Oct 2007 01:52:51 +0000 (+1300)
Subject: DB schema: upgrade dst_time and std_time fields in mdl_timezone to varchar(6)
X-Git-Url: http://gitprivate/gw?p=moodle-r2.git;a=commitdiff_plain;h=f9bc9024b5fd2c94a68409cc57f9ca6d0f05f953;hp=cbcf962b5f6cf3d8172bfa0696ded7f93f1072bb

DB schema: upgrade dst_time and std_time fields in mdl_timezone to varchar(6)
These fields are currently varchar(5) and that's too small to upgrade using
the latest Olson data (which contains the new daylight saving rules).
---

diff --git a/lib/db/install.xml b/lib/db/install.xml
index 742721d..2179f44 100644
--- a/lib/db/install.xml
+++ b/lib/db/install.xml
@@ -506,12 +506,12 @@
         <FIELD NAME="dst_startday" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="dst_month" NEXT="dst_weekday"/>
         <FIELD NAME="dst_weekday" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="dst_startday" NEXT="dst_skipweeks"/>
         <FIELD NAME="dst_skipweeks" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="dst_weekday" NEXT="dst_time"/>
-        <FIELD NAME="dst_time" TYPE="char" LENGTH="5" NOTNULL="true" DEFAULT="00:00" SEQUENCE="false" ENUM="false" PREVIOUS="dst_skipweeks" NEXT="std_month"/>
+        <FIELD NAME="dst_time" TYPE="char" LENGTH="6" NOTNULL="true" DEFAULT="00:00" SEQUENCE="false" ENUM="false" PREVIOUS="dst_skipweeks" NEXT="std_month"/>
         <FIELD NAME="std_month" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="dst_time" NEXT="std_startday"/>
         <FIELD NAME="std_startday" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="std_month" NEXT="std_weekday"/>
         <FIELD NAME="std_weekday" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="std_startday" NEXT="std_skipweeks"/>
         <FIELD NAME="std_skipweeks" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="std_weekday" NEXT="std_time"/>
-        <FIELD NAME="std_time" TYPE="char" LENGTH="5" NOTNULL="true" DEFAULT="00:00" SEQUENCE="false" ENUM="false" PREVIOUS="std_skipweeks"/>
+        <FIELD NAME="std_time" TYPE="char" LENGTH="6" NOTNULL="true" DEFAULT="00:00" SEQUENCE="false" ENUM="false" PREVIOUS="std_skipweeks"/>
       </FIELDS>
       <KEYS>
         <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for timezone"/>
diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php
index 885b4c1..693b81e 100644
--- a/lib/db/upgrade.php
+++ b/lib/db/upgrade.php
@@ -742,6 +742,12 @@ function xmldb_main_upgrade($oldversion=0) {
         }
     }
 
+    if ($result && $oldversion < 2007021533) {
+        // Increase the time fields to make Olson imports work
+        $result = $result and table_column('timezone', 'dst_time', 'dst_time', 'varchar', 6, '', '00:00');
+        $result = $result and table_column('timezone', 'std_time', 'std_time', 'varchar', 6, '', '00:00');
+    }
+
     return $result;
 
 }
diff --git a/version.php b/version.php
index 26df5e9..82dc68e 100644
--- a/version.php
+++ b/version.php
@@ -6,7 +6,7 @@
 // This is compared against the values stored in the database to determine
 // whether upgrades should be performed (see lib/db/*.php)
 
-   $version = 2007021532;   // YYYYMMDD   = date of the 1.8 branch (don't change)
+   $version = 2007021533;   // YYYYMMDD   = date of the 1.8 branch (don't change)
                             //         X  = release number 1.8.[0,1,2,3...]
                             //          Y = micro-increments between releases
 
