]> git.mjollnir.org Git - moodle.git/commitdiff
Recreate index as unique
authormoodler <moodler>
Thu, 2 Aug 2007 14:20:37 +0000 (14:20 +0000)
committermoodler <moodler>
Thu, 2 Aug 2007 14:20:37 +0000 (14:20 +0000)
lib/db/install.xml
lib/db/upgrade.php
version.php

index aa743914b76a0d15da1b25b5d843feaf117cb654..749125740100be8032a4833fa3685fe68b4f2ca0 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="lib/db" VERSION="20070801" COMMENT="XMLDB file for core Moodle tables"
+<XMLDB PATH="lib/db" VERSION="20070802" COMMENT="XMLDB file for core Moodle tables"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
 >
         <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for tag_instance"/>
       </KEYS>
       <INDEXES>
-        <INDEX NAME="tagiditem" UNIQUE="false" FIELDS="tagid, itemtype, itemid"/>
+        <INDEX NAME="tagiditem" UNIQUE="true" FIELDS="tagid, itemtype, itemid"/>
       </INDEXES>
     </TABLE>
   </TABLES>
index c1cdc593882a2a9d9f428fe1991787046372ef03..02047847e5d2b8f4a8dafbab6142dddaa79018ff 100644 (file)
@@ -1578,6 +1578,24 @@ function xmldb_main_upgrade($oldversion=0) {
         build_context_rel();
     }
 
+    if ($result && $oldversion < 2007080201) {
+
+    /// Define index tagiditem (not unique) to be dropped form tag_instance
+        $table = new XMLDBTable('tag_instance');
+        $index = new XMLDBIndex('tagiditem');
+
+    /// Launch drop index tagiditem
+        drop_index($table, $index);
+
+   /// Define index tagiditem (unique) to be added to tag_instance
+        $index->setAttributes(XMLDB_INDEX_UNIQUE, array('tagid', 'itemtype', 'itemid'));
+
+    /// Launch add index tagiditem
+        $result = $result && add_index($table, $index);
+
+    }
+
+
 /*
     /// drop old gradebook tables
     if ($result && $oldversion < 2007072209) {
index 8959b2defb76a62a7103ea27f6f53858c521a0f6..7fc6b4980cc000d96065dbd603f21bf648ae3147 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 = 2007080200;  // YYYYMMDD = date
+    $version = 2007080201;  // YYYYMMDD = date
                             //       XY = increments within a single day
 
     $release = '1.9 dev';   // Human-friendly version name