]> git.mjollnir.org Git - moodle.git/commitdiff
Some old PG sites have user->firstname and user->lastname
authorstronk7 <stronk7>
Sun, 21 Jan 2007 19:56:05 +0000 (19:56 +0000)
committerstronk7 <stronk7>
Sun, 21 Jan 2007 19:56:05 +0000 (19:56 +0000)
defined to be 30cc. Repair them. MDL-7110

lib/db/upgrade.php
version.php

index f5c15e9bc3bd2f362b7d51aa7456cbd055589ebb..05b3478fd3ccc811a9fa8217f58bb99395e55549 100644 (file)
@@ -524,6 +524,41 @@ function xmldb_main_upgrade($oldversion=0) {
         }
     }
 
+    if ($result && $oldversion < 2007012100) {
+    /// Some old PG servers have user->firstname & user->lastname with 30cc. They must be 100cc.
+    /// Fixing that conditionally. MDL-7110
+        if ($CFG->dbfamily == 'postgres') {
+        /// Get Metadata from user table
+            $cols = array_change_key_case($db->MetaColumns($CFG->prefix . 'user'), CASE_LOWER);
+
+        /// Process user->firstname if needed
+            if ($col = $cols['firstname']) {
+                if ($col->max_length < 100) {
+                /// Changing precision of field firstname on table user to (100)
+                    $table = new XMLDBTable('user');
+                    $field = new XMLDBField('firstname');
+                    $field->setAttributes(XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, null, null, 'idnumber');
+
+                /// Launch change of precision for field firstname
+                    $result = $result && change_field_precision($table, $field);
+                }
+            }
+
+        /// Process user->lastname if needed
+            if ($col = $cols['lastname']) {
+                if ($col->max_length < 100) {
+                /// Changing precision of field lastname on table user to (100)
+                    $table = new XMLDBTable('user');
+                    $field = new XMLDBField('lastname');
+                    $field->setAttributes(XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, null, null, 'firstname');
+
+                /// Launch change of precision for field lastname
+                    $result = $result && change_field_precision($table, $field);
+                }
+            }
+        }
+    }
+
     return $result;
 
 }
index 3b25a5986beb187160885f1286a6cd9754200386..9a57a34724069f96b74031b3ed42a67ebf4e96c2 100644 (file)
@@ -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 = 2007011200;  // YYYYMMDD = date
+   $version = 2007012100;  // YYYYMMDD = date
                            //       XY = increments within a single day
 
    $release = '1.8 dev';    // Human-friendly version name