]> git.mjollnir.org Git - moodle.git/commitdiff
adding a new key
authortoyomoyo <toyomoyo>
Wed, 25 Jul 2007 03:14:17 +0000 (03:14 +0000)
committertoyomoyo <toyomoyo>
Wed, 25 Jul 2007 03:14:17 +0000 (03:14 +0000)
lib/db/install.xml
lib/db/upgrade.php
version.php

index 3994ef6c78781109d048da86a9bffa2856bbf1c7..666996414c5a70bf475e6bf489562d9e8d3d8d65 100644 (file)
@@ -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"
 >
       <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">
index a8cb91eac9d2fa1765f1780da1cb2f870332f02a..3498ba3c3d1a735fcb7ab464880d6b5e6e510000 100644 (file)
@@ -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) {
index 9ae7854dd7c36b43e062ae49ce0a69168f509c9c..9eeb55d033c85f05847fb926f0ad8a7cc30a5700 100644 (file)
@@ -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