From: toyomoyo <toyomoyo> Date: Wed, 25 Jul 2007 03:14:17 +0000 (+0000) Subject: adding a new key X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=e99c48d85685624e59b7bc19ea8b93baa0338b5b;p=moodle.git adding a new key --- diff --git a/lib/db/install.xml b/lib/db/install.xml index 3994ef6c78..666996414c 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<XMLDB PATH="lib/db" VERSION="20070723" COMMENT="XMLDB file for core Moodle tables" +<XMLDB PATH="lib/db" VERSION="20070725" COMMENT="XMLDB file for core Moodle tables" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd" > @@ -1301,7 +1301,8 @@ <KEYS> <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me" NEXT="courseid"/> <KEY NAME="courseid" TYPE="foreign" FIELDS="courseid" REFTABLE="course" REFFIELDS="id" PREVIOUS="primary" NEXT="outcomeid"/> - <KEY NAME="outcomeid" TYPE="foreign" FIELDS="outcomeid" REFTABLE="grade_outcomes" REFFIELDS="id" PREVIOUS="courseid"/> + <KEY NAME="outcomeid" TYPE="foreign" FIELDS="outcomeid" REFTABLE="grade_outcomes" REFFIELDS="id" PREVIOUS="courseid" NEXT="courseid-outcomeid"/> + <KEY NAME="courseid-outcomeid" TYPE="unique" FIELDS="courseid, outcomeid" PREVIOUS="outcomeid"/> </KEYS> </TABLE> <TABLE NAME="grade_categories" COMMENT="This table keeps information about categories, used for grouping items." PREVIOUS="grade_outcomes_courses" NEXT="grade_items"> diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index a8cb91eac9..3498ba3c3d 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -1451,7 +1451,16 @@ function xmldb_main_upgrade($oldversion=0) { $result = $result && change_field_default($table, $field); } + if ($result && $oldversion < 2007072500) { + /// Define key courseid-outcomeid (unique) to be added to grade_outcomes_courses + $table = new XMLDBTable('grade_outcomes_courses'); + $key = new XMLDBKey('courseid-outcomeid'); + $key->setAttributes(XMLDB_KEY_UNIQUE, array('courseid', 'outcomeid')); + + /// Launch add key courseid-outcomeid + $result = $result && add_key($table, $key); + } /* /// drop old gradebook tables if ($result && $oldversion < 2007072209) { diff --git a/version.php b/version.php index 9ae7854dd7..9eeb55d033 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 = 2007072402; // YYYYMMDD = date + $version = 2007072500; // YYYYMMDD = date // XY = increments within a single day $release = '1.9 dev'; // Human-friendly version name