From 9fc57f4c22f18e4c2cdf8de29ce0689cc6d25351 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sun, 21 Jan 2007 19:56:05 +0000 Subject: [PATCH] Some old PG sites have user->firstname and user->lastname defined to be 30cc. Repair them. MDL-7110 --- lib/db/upgrade.php | 35 +++++++++++++++++++++++++++++++++++ version.php | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index f5c15e9bc3..05b3478fd3 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -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; } diff --git a/version.php b/version.php index 3b25a5986b..9a57a34724 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 = 2007011200; // YYYYMMDD = date + $version = 2007012100; // YYYYMMDD = date // XY = increments within a single day $release = '1.8 dev'; // Human-friendly version name -- 2.39.5