Tinebase_Setup10 - handle outdated table structure of uninstalled apps
authorPaul Mehrer <p.mehrer@metaways.de>
Fri, 11 Aug 2017 14:47:05 +0000 (16:47 +0200)
committerPaul Mehrer <p.mehrer@metaways.de>
Fri, 11 Aug 2017 14:49:03 +0000 (16:49 +0200)
Change-Id: Ieb64b620dc8ca604e6f316c13e5822b45638c5f1
Reviewed-on: http://gerrit.tine20.com/customers/5458
Reviewed-by: Paul Mehrer <p.mehrer@metaways.de>
Tested-by: Paul Mehrer <p.mehrer@metaways.de>
tine20/Tinebase/Setup/Update/Release10.php

index 986f102..54f379c 100644 (file)
@@ -1545,7 +1545,8 @@ class Tinebase_Setup_Update_Release10 extends Setup_Update_Abstract
                     </reference>
                 </index>'));
 
-        if ($this->_backend->tableExists('timeaccount')) {
+        if (Tinebase_Application::getInstance()->isInstalled('Timetracker') &&
+                $this->_backend->tableExists('timeaccount')) {
             $this->_backend->addForeignKey('timeaccount', new Setup_Backend_Schema_Index_Xml('<index>
                     <name>timeaccount::container_id--container::id</name>
                     <field>
@@ -1559,7 +1560,8 @@ class Tinebase_Setup_Update_Release10 extends Setup_Update_Abstract
                 </index>'));
         }
 
-        if ($this->_backend->tableExists('sales_contracts')) {
+        if (Tinebase_Application::getInstance()->isInstalled('Sales') &&
+                $this->_backend->tableExists('sales_contracts')) {
             $this->_backend->addForeignKey('sales_contracts', new Setup_Backend_Schema_Index_Xml('<index>
                     <name>sales_contracts::container_id--container::id</name>
                     <field>
@@ -1573,7 +1575,8 @@ class Tinebase_Setup_Update_Release10 extends Setup_Update_Abstract
                 </index>'));
         }
 
-        if ($this->_backend->tableExists('metacrm_lead')) {
+        if (Tinebase_Application::getInstance()->isInstalled('Crm') &&
+                $this->_backend->tableExists('metacrm_lead')) {
             $this->_backend->addForeignKey('metacrm_lead', new Setup_Backend_Schema_Index_Xml('<index>
                     <name>metacrm_lead::container_id--container::id</name>
                     <field>
@@ -1587,46 +1590,48 @@ class Tinebase_Setup_Update_Release10 extends Setup_Update_Abstract
                 </index>'));
         }
 
-        if ($this->_backend->tableExists('cal_resources')) {
-            $this->_backend->addForeignKey('cal_resources', new Setup_Backend_Schema_Index_Xml('<index>
-                    <name>cal_resources::container_id--container::id</name>
-                    <field>
-                        <name>container_id</name>
-                    </field>
-                    <foreign>true</foreign>
-                    <reference>
-                        <table>container</table>
-                        <field>id</field>
-                    </reference>
-                </index>'));
-        }
+        if (Tinebase_Application::getInstance()->isInstalled('Calendar')) {
+            if ($this->_backend->tableExists('cal_resources')) {
+                $this->_backend->addForeignKey('cal_resources', new Setup_Backend_Schema_Index_Xml('<index>
+                        <name>cal_resources::container_id--container::id</name>
+                        <field>
+                            <name>container_id</name>
+                        </field>
+                        <foreign>true</foreign>
+                        <reference>
+                            <table>container</table>
+                            <field>id</field>
+                        </reference>
+                    </index>'));
+            }
 
-        if ($this->_backend->tableExists('cal_events')) {
-            $this->_backend->addForeignKey('cal_events', new Setup_Backend_Schema_Index_Xml('<index>
-                    <name>cal_events::container_id--container::id</name>
-                    <field>
-                        <name>container_id</name>
-                    </field>
-                    <foreign>true</foreign>
-                    <reference>
-                        <table>container</table>
-                        <field>id</field>
-                    </reference>
-                </index>'));
-        }
+            if ($this->_backend->tableExists('cal_events')) {
+                $this->_backend->addForeignKey('cal_events', new Setup_Backend_Schema_Index_Xml('<index>
+                        <name>cal_events::container_id--container::id</name>
+                        <field>
+                            <name>container_id</name>
+                        </field>
+                        <foreign>true</foreign>
+                        <reference>
+                            <table>container</table>
+                            <field>id</field>
+                        </reference>
+                    </index>'));
+            }
 
-        if ($this->_backend->tableExists('cal_attendee')) {
-            $this->_backend->addForeignKey('cal_attendee', new Setup_Backend_Schema_Index_Xml('<index>
-                    <name>cal_attendee::displaycontainer_id--container::id</name>
-                    <field>
-                        <name>displaycontainer_id</name>
-                    </field>
-                    <foreign>true</foreign>
-                    <reference>
-                        <table>container</table>
-                        <field>id</field>
-                    </reference>
-                </index>'));
+            if ($this->_backend->tableExists('cal_attendee')) {
+                $this->_backend->addForeignKey('cal_attendee', new Setup_Backend_Schema_Index_Xml('<index>
+                        <name>cal_attendee::displaycontainer_id--container::id</name>
+                        <field>
+                            <name>displaycontainer_id</name>
+                        </field>
+                        <foreign>true</foreign>
+                        <reference>
+                            <table>container</table>
+                            <field>id</field>
+                        </reference>
+                    </index>'));
+            }
         }
 
         if ($this->_backend->tableExists('addressbook')) {