From 1f8bacd20fdbbc41c1e01b16bb79802d8bf473a8 Mon Sep 17 00:00:00 2001 From: Eloy Lafuente Date: Wed, 28 Apr 2010 21:42:50 +0000 Subject: [PATCH] MDL-22145 backup - allowing longer backup types in DB --- lib/db/install.xml | 2 +- lib/db/upgrade.php | 31 +++++++++++++++++++++++++++++++ version.php | 2 +- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/lib/db/install.xml b/lib/db/install.xml index ba8dc1339ef..5fa817da151 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -2461,7 +2461,7 @@ - + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 6c87f0e5a1c..fc75267e78b 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -3665,6 +3665,37 @@ AND EXISTS (SELECT 'x' upgrade_main_savepoint($result, 2010042801); } + if ($result && $oldversion < 2010042802) { // Change backup_controllers->type to varchar10 (recreate dep. index) + + /// Define index typeitem_ix (not unique) to be dropped form backup_controllers + $table = new xmldb_table('backup_controllers'); + $index = new xmldb_index('typeitem_ix', XMLDB_INDEX_NOTUNIQUE, array('type', 'itemid')); + + /// Conditionally launch drop index typeitem_ix + if ($dbman->index_exists($table, $index)) { + $dbman->drop_index($table, $index); + } + + /// Changing precision of field type on table backup_controllers to (10) + $table = new xmldb_table('backup_controllers'); + $field = new xmldb_field('type', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, 'backupid'); + + /// Launch change of precision for field type + $dbman->change_field_precision($table, $field); + + /// Define index typeitem_ix (not unique) to be added to backup_controllers + $table = new xmldb_table('backup_controllers'); + $index = new xmldb_index('typeitem_ix', XMLDB_INDEX_NOTUNIQUE, array('type', 'itemid')); + + /// Conditionally launch add index typeitem_ix + if (!$dbman->index_exists($table, $index)) { + $dbman->add_index($table, $index); + } + + /// Main savepoint reached + upgrade_main_savepoint($result, 2010042802); + } + return $result; } diff --git a/version.php b/version.php index b21399c58f8..6c8b870c133 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 = 2010042801; // YYYYMMDD = date of the last version bump + $version = 2010042802; // YYYYMMDD = date of the last version bump // XX = daily increments $release = '2.0 dev (Build: 20100428)'; // Human-friendly version name