Merge branch '2013.03' into 2013.10
[tine20] / tine20 / Tinebase / Setup / Update / Release8.php
1 <?php
2 /**
3  * Tine 2.0
4  *
5  * @package     Tinebase
6  * @subpackage  Setup
7  * @license     http://www.gnu.org/licenses/agpl.html AGPL3
8  * @copyright   Copyright (c) 2013 Metaways Infosystems GmbH (http://www.metaways.de)
9  * @author      Philipp Schüle <p.schuele@metaways.de>
10  */
11 class Tinebase_Setup_Update_Release8 extends Setup_Update_Abstract
12 {
13     /**
14      * update to 8.1
15      * 
16      * @see 0009152: saving of record fails because of too many relations
17      */
18     public function update_0()
19     {
20         $valueFields = array('old_value', 'new_value');
21         foreach ($valueFields as $field) {
22             
23             // check schema, only change if type == text
24             $typeMapping = $this->_backend->getTypeMapping('text');
25             $schema = Tinebase_Db_Table::getTableDescriptionFromCache(SQL_TABLE_PREFIX . 'timemachine_modlog', $this->_backend->getDb());
26             
27             if ($schema[$field]['DATA_TYPE'] === $typeMapping['defaultType']) {
28                 if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
29                     . ' Old column type (' . $schema[$field]['DATA_TYPE'] . ') is going to be altered to clob');
30                 
31                 $declaration = new Setup_Backend_Schema_Field_Xml('
32                     <field>
33                         <name>' . $field . '</name>
34                         <type>clob</type>
35                     </field>
36                 ');
37             
38                 $this->_backend->alterCol('timemachine_modlog', $declaration);
39             }
40         }
41         $this->setTableVersion('timemachine_modlog', '3');
42         $this->setApplicationVersion('Tinebase', '8.1');
43     }
44
45     /**
46      * update to 8.2
47      * 
48      * @see 0009644: remove user registration
49      */
50     public function update_1()
51     {
52         if ($this->_backend->tableExists('registrations')) {
53             $this->dropTable('registrations');
54         }
55         
56         if ($this->_backend->tableExists('registration_invitation')) {
57             $this->dropTable('registration_invitation');
58         }
59         
60         $this->setApplicationVersion('Tinebase', '8.2');
61     }
62 }