From 39c763645edd201cadc9b64117a5aa96d6acaf43 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Mon, 13 Sep 2010 13:01:34 +0000 Subject: [PATCH] blocks upgrade MDL-22693 Forgot to change the precision of the block_instances.pagetypepattern column to 64 chars. Do it now. You have to drop and re-create the associated index, otherwise this will not work, at least on Postgres. --- lib/db/upgrade.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ version.php | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index bf671db191e..f37587d633e 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -5082,6 +5082,50 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL"); upgrade_main_savepoint(true, 2010082502); } + if ($oldversion < 2010091300) { + // Need to drop the index before we can alter the column precision in the next step. + + // Define index parentcontextid-showinsubcontexts-pagetypepattern-subpagepattern (not unique) to be dropped form block_instances + $table = new xmldb_table('block_instances'); + $index = new xmldb_index('parentcontextid-showinsubcontexts-pagetypepattern-subpagepattern', XMLDB_INDEX_NOTUNIQUE, array('parentcontextid', 'showinsubcontexts', 'pagetypepattern', 'subpagepattern')); + + // Conditionally launch drop index parentcontextid-showinsubcontexts-pagetypepattern-subpagepattern + if ($dbman->index_exists($table, $index)) { + $dbman->drop_index($table, $index); + } + + // Main savepoint reached + upgrade_main_savepoint(true, 2010091300); + } + + if ($oldversion < 2010091301) { + + // Changing precision of field pagetypepattern on table block_instances to (64) + $table = new xmldb_table('block_instances'); + $field = new xmldb_field('pagetypepattern', XMLDB_TYPE_CHAR, '64', null, XMLDB_NOTNULL, null, null, 'showinsubcontexts'); + + // Launch change of precision for field pagetypepattern + $dbman->change_field_precision($table, $field); + + // Main savepoint reached + upgrade_main_savepoint(true, 2010091301); + } + + if ($oldversion < 2010091302) { + // Now add the index back. + + // Define index parentcontextid-showinsubcontexts-pagetypepattern-subpagepattern (not unique) to be added to block_instances + $table = new xmldb_table('block_instances'); + $index = new xmldb_index('parentcontextid-showinsubcontexts-pagetypepattern-subpagepattern', XMLDB_INDEX_NOTUNIQUE, array('parentcontextid', 'showinsubcontexts', 'pagetypepattern', 'subpagepattern')); + + // Conditionally launch add index parentcontextid-showinsubcontexts-pagetypepattern-subpagepattern + if (!$dbman->index_exists($table, $index)) { + $dbman->add_index($table, $index); + } + + // Main savepoint reached + upgrade_main_savepoint(true, 2010091302); + } return true; } diff --git a/version.php b/version.php index 63b524b9d97..3d5df631d78 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2010091200; // YYYYMMDD = date of the last version bump +$version = 2010091302; // YYYYMMDD = date of the last version bump // XX = daily increments $release = '2.0 Preview 4+ (Build: 20100913)'; // Human-friendly version name -- 2.11.4.GIT