From: toyomoyo Date: Wed, 1 Aug 2007 03:17:00 +0000 (+0000) Subject: enforcing unique constraint on (courseid, shortname) pair on outcomes X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=1f496dedfebfc50c7358173ca15812bfe04ea8ce;p=moodle.git enforcing unique constraint on (courseid, shortname) pair on outcomes --- diff --git a/lib/db/install.xml b/lib/db/install.xml index 1ed0ce1b59..aa743914b7 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1290,7 +1290,8 @@ - + + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index e47a55ea19..ad696fb93b 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -1553,7 +1553,18 @@ function xmldb_main_upgrade($oldversion=0) { } } + + // adding unique contraint on (courseid,shortname) of an outcome + if ($result && $oldversion < 2007080100) { + + /// Define key courseid-shortname (unique) to be added to grade_outcomes + $table = new XMLDBTable('grade_outcomes'); + $key = new XMLDBKey('courseid-shortname'); + $key->setAttributes(XMLDB_KEY_UNIQUE, array('courseid', 'shortname')); + /// Launch add key courseid-shortname + $result = $result && add_key($table, $key); + } /* /// drop old gradebook tables diff --git a/version.php b/version.php index cfd1c685fc..4639b699d6 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 = 2007073105; // YYYYMMDD = date + $version = 2007080100; // YYYYMMDD = date // XY = increments within a single day $release = '1.9 dev'; // Human-friendly version name