0011398: add own_id index to relations table
authorPaul Mehrer <p.mehrer@metaways.de>
Wed, 21 Oct 2015 15:40:53 +0000 (17:40 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 22 Oct 2015 08:40:57 +0000 (10:40 +0200)
added index to relations table to optimize
Tinebase_Relations::_validateConstraintsConfig

https://forge.tine20.org/view.php?id=11398

Change-Id: If4c73e683199920087187a67d3dbb0c88bd211af
Reviewed-on: http://gerrit.tine20.com/customers/2302
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/Setup/Update/Release8.php
tine20/Tinebase/Setup/setup.xml

index 2036ace..7f298aa 100644 (file)
@@ -499,4 +499,28 @@ class Tinebase_Setup_Update_Release8 extends Setup_Update_Abstract
         $this->setTableVersion('groups', '5');
         $this->setApplicationVersion('Tinebase', '8.10');
     }
         $this->setTableVersion('groups', '5');
         $this->setApplicationVersion('Tinebase', '8.10');
     }
+
+    /**
+     * update 10 -> adds index to relations
+     */
+    public function update_10()
+    {
+        $tableVersion = $this->getTableVersion('relations');
+
+        if ($tableVersion < 8) {
+            $declaration = new Setup_Backend_Schema_Index_Xml('
+                    <index>
+                        <name>own_id</name>
+                        <field>
+                            <name>own_id</name>
+                        </field>
+                    </index>
+                ');
+
+            $this->_backend->addIndex('relations', $declaration);
+            $this->setTableVersion('relations', '8');
+        }
+
+        $this->setApplicationVersion('Tinebase', '8.11');
+    }
 }
 }
index bc619f8..bb4c552 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <application>
     <name>Tinebase</name>
 <?xml version="1.0" encoding="utf-8"?>
 <application>
     <name>Tinebase</name>
-    <version>8.10</version>
+    <version>8.11</version>
     <tables>
         <table>
             <name>applications</name>
     <tables>
         <table>
             <name>applications</name>
 
         <table>
             <name>relations</name>
 
         <table>
             <name>relations</name>
-            <version>7</version>
+            <version>8</version>
             <declaration>
                 <field>
                     <name>id</name>
             <declaration>
                 <field>
                     <name>id</name>
                     </field>
                 </index>
                 <index>
                     </field>
                 </index>
                 <index>
+                    <name>own_id</name>
+                    <field>
+                        <name>own_id</name>
+                    </field>
+                </index>
+                <index>
                     <name>rel_id-own_model-own_backend-own_id</name>
                     <unique>true</unique>
                     <field>
                     <name>rel_id-own_model-own_backend-own_id</name>
                     <unique>true</unique>
                     <field>