]> git.mjollnir.org Git - moodle.git/commitdiff
Add context.path and context.depth fields for accesslib optimisation
authormartinlanghoff <martinlanghoff>
Thu, 9 Aug 2007 06:14:21 +0000 (06:14 +0000)
committermartinlanghoff <martinlanghoff>
Thu, 9 Aug 2007 06:14:21 +0000 (06:14 +0000)
lib/db/install.xml
lib/db/upgrade.php
version.php

index 749125740100be8032a4833fa3685fe68b4f2ca0..e20750b92fd8439fed622a723f8680f6d7b654f7 100644 (file)
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="contextlevel"/>
         <FIELD NAME="contextlevel" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="instanceid"/>
-        <FIELD NAME="instanceid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="contextlevel"/>
+        <FIELD NAME="instanceid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="contextlevel" NEXT="path"/>
+        <FIELD NAME="path" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="instanceid" NEXT="depth"/>
+        <FIELD NAME="depth" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="path"/>
       </FIELDS>
       <KEYS>
         <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for context"/>
       </KEYS>
       <INDEXES>
         <INDEX NAME="contextlevel-instanceid" UNIQUE="true" FIELDS="contextlevel, instanceid" NEXT="instanceid"/>
-        <INDEX NAME="instanceid" UNIQUE="false" FIELDS="instanceid" PREVIOUS="contextlevel-instanceid"/>
+        <INDEX NAME="instanceid" UNIQUE="false" FIELDS="instanceid" PREVIOUS="contextlevel-instanceid" NEXT="path"/>
+        <INDEX NAME="path" UNIQUE="false" FIELDS="path" PREVIOUS="instanceid"/>
+
       </INDEXES>
     </TABLE>
     <TABLE NAME="context_rel" COMMENT="context relations, c2 is a parent (or higher) of c1" PREVIOUS="context" NEXT="capabilities">
       </SENTENCES>
     </STATEMENT>
   </STATEMENTS>
-</XMLDB>
\ No newline at end of file
+</XMLDB>
index eff9fa55a259b3b56150a94040ebb2e6c9e573d3..adf1441f5a807289965b79a7ed69805b0af109d0 100644 (file)
@@ -1634,6 +1634,24 @@ function xmldb_main_upgrade($oldversion=0) {
         $result = $result && change_field_precision($table, $field);
     }
 
+    if ($result && $oldversion < 2007080900) {
+    /// Add context.path & index
+        $table = new XMLDBTable('context');
+        $field = new XMLDBField('path');
+        $field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, '', 'instanceid');
+        $result = $result && add_field($table, $field);
+        $table = new XMLDBTable('context');
+        $index = new XMLDBIndex('path');
+        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('path'));
+        $result = $result && add_index($table, $index);
+
+    /// Add context.depth
+        $table = new XMLDBTable('context');
+        $field = new XMLDBField('depth');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'path');
+        $result = $result && add_field($table, $field);
+    }
+
 /*
     /// drop old gradebook tables
     if ($result && $oldversion < 2007072209) {
index 8295a41df79ce0617db9f0c10095b4ed2b3a04e4..8dc1e648f6898041865f173af6464597bdb791ac 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 = 2007080800;  // YYYYMMDD = date
+    $version = 2007080900;  // YYYYMMDD = date
                             //       XY = increments within a single day
 
     $release = '1.9 dev';   // Human-friendly version name