From a1f27717db70a22b659e583bce748602be6fce35 Mon Sep 17 00:00:00 2001 From: nicolasconnault Date: Fri, 7 Mar 2008 13:23:38 +0000 Subject: [PATCH] MDL-11888 Added unique constraint. --- lib/db/install.xml | 4 ++-- lib/db/upgrade.php | 25 +++++++++++++++++++++++++ version.php | 4 ++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/lib/db/install.xml b/lib/db/install.xml index 69b53b2f7f..ab9b8c55b4 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1,5 +1,5 @@ - @@ -1617,7 +1617,7 @@ - + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 40d5fa16cf..0ceac471e9 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -2950,6 +2950,31 @@ function xmldb_main_upgrade($oldversion=0) { set_field('grade_items', 'needsupdate', 1, 'needsupdate', 0); } + if ($result && $oldversion < 2008030700) { + + /// Define index contextid-lowerboundary (not unique) to be dropped form grade_letters + $table = new XMLDBTable('grade_letters'); + $index = new XMLDBIndex('contextid-lowerboundary'); + $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('contextid', 'lowerboundary')); + + /// Launch drop index contextid-lowerboundary + $result = $result && drop_index($table, $index); + + /// Main savepoint reached + upgrade_main_savepoint($result, 2008030700); + + /// Define index contextid-lowerboundary-letter (unique) to be added to grade_letters + $table = new XMLDBTable('grade_letters'); + $index = new XMLDBIndex('contextid-lowerboundary-letter'); + $index->setAttributes(XMLDB_INDEX_UNIQUE, array('contextid', 'lowerboundary', 'letter')); + + /// Launch add index contextid-lowerboundary-letter + $result = $result && add_index($table, $index); + + /// Main savepoint reached + upgrade_main_savepoint($result, 2008030700); + } + return $result; } diff --git a/version.php b/version.php index 4ec03ecbf3..6b67499ee5 100644 --- a/version.php +++ b/version.php @@ -6,9 +6,9 @@ // This is compared against the values stored in the database to determine // whether upgrades should be performed (see lib/db/*.php) - $version = 2008030500; // YYYYMMDD = date of the last version bump + $version = 2008030700; // YYYYMMDD = date of the last version bump // XX = daily increments - $release = '2.0 dev (Build: 20080305)'; // Human-friendly version name + $release = '2.0 dev (Build: 20080307)'; // Human-friendly version name ?> -- 2.39.5