From 32ef914951efb3a507284e4a2e32a3fcb5465f9c Mon Sep 17 00:00:00 2001 From: moodler <moodler> Date: Thu, 2 Aug 2007 14:20:37 +0000 Subject: [PATCH] Recreate index as unique --- lib/db/install.xml | 4 ++-- lib/db/upgrade.php | 18 ++++++++++++++++++ version.php | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/db/install.xml b/lib/db/install.xml index aa743914b7..7491257401 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="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" > @@ -1641,7 +1641,7 @@ <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> diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index c1cdc59388..02047847e5 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -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) { diff --git a/version.php b/version.php index 8959b2defb..7fc6b4980c 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 = 2007080200; // YYYYMMDD = date + $version = 2007080201; // YYYYMMDD = date // XY = increments within a single day $release = '1.9 dev'; // Human-friendly version name -- 2.39.5