0013232: Change of contact image does not log useful information in timemachine
[tine20] / tine20 / Timetracker / Setup / Update / Release10.php
1 <?php
2 /**
3  * Tine 2.0
4  *
5  * @package     Timetracker
6  * @subpackage  Setup
7  * @license     http://www.gnu.org/licenses/agpl.html AGPL3
8  * @copyright   Copyright (c) 2017 Metaways Infosystems GmbH (http://www.metaways.de)
9  * @author      Michael Spahn <m.spahn@metaways.de>
10  */
11 class Timetracker_Setup_Update_Release10 extends Setup_Update_Abstract
12 {
13     /**
14      * update to 10.1
15      *
16      * Add fulltext index to field description of timesheet
17      */
18     public function update_0()
19     {
20         if ($this->getTableVersion('timetracker_timesheet') < 6) {
21             $declaration = new Setup_Backend_Schema_Index_Xml('
22                 <index>
23                     <name>description</name>
24                     <fulltext>true</fulltext>
25                     <field>
26                         <name>description</name>
27                     </field>
28                 </index>
29             ');
30
31             try {
32                 $this->_backend->addIndex('timetracker_timesheet', $declaration);
33             } catch (Exception $e) {
34                 Tinebase_Exception::log($e);
35             }
36
37             $this->setTableVersion('timetracker_timesheet', '6');
38         }
39         $this->setApplicationVersion('Timetracker', '10.1');
40     }
41
42     /**
43      * update to 10.2
44      *
45      * Add fulltext index to field description of timeaccount
46      */
47     public function update_1()
48     {
49         if ($this->getTableVersion('timetracker_timesheet') < 11) {
50             $declaration = new Setup_Backend_Schema_Index_Xml('
51                 <index>
52                     <name>description</name>
53                     <fulltext>true</fulltext>
54                     <field>
55                         <name>description</name>
56                     </field>
57                 </index>
58             ');
59
60             try {
61                 $this->_backend->addIndex('timetracker_timeaccount', $declaration);
62             } catch (Exception $e) {
63                 Tinebase_Exception::log($e);
64             }
65             $this->setTableVersion('timetracker_timeaccount', '11');
66         }
67         $this->setApplicationVersion('Timetracker', '10.2');
68     }
69
70     /**
71      * update to 10.3
72      *
73      * @return void
74      */
75     public function update_2()
76     {
77         if (! $this->_backend->tableExists('timetracker_timeaccount_fav')) {
78             $declaration = new Setup_Backend_Schema_Table_Xml('<table>
79                 <name>timetracker_timeaccount_fav</name>
80                 <version>1</version>
81                 <declaration>
82                     <field>
83                         <name>id</name>
84                         <type>text</type>
85                         <length>40</length>
86                         <notnull>true</notnull>
87                     </field>
88                     <field>
89                         <name>account_id</name>
90                         <type>text</type>
91                         <length>40</length>
92                         <notnull>true</notnull>
93                     </field>
94                     <field>
95                         <name>timeaccount_id</name>
96                         <type>text</type>
97                         <length>40</length>
98                         <notnull>false</notnull>
99                     </field>
100                     <field>
101                         <name>created_by</name>
102                         <type>text</type>
103                         <length>40</length>
104                     </field>
105                     <field>
106                         <name>creation_time</name>
107                         <type>datetime</type>
108                     </field>
109                     <field>
110                         <name>last_modified_by</name>
111                         <type>text</type>
112                         <length>40</length>
113                     </field>
114                     <field>
115                         <name>last_modified_time</name>
116                         <type>datetime</type>
117                     </field>
118                     <field>
119                         <name>is_deleted</name>
120                         <type>boolean</type>
121                         <default>false</default>
122                     </field>
123                     <field>
124                         <name>deleted_by</name>
125                         <type>text</type>
126                         <length>40</length>
127                     </field>
128                     <field>
129                         <name>deleted_time</name>
130                         <type>datetime</type>
131                     </field>
132                     <index>
133                         <name>id</name>
134                         <primary>true</primary>
135                         <field>
136                             <name>id</name>
137                         </field>
138                     </index>
139                     <index>
140                         <name>timesheet_favorites--timesheet_id::id</name>
141                         <field>
142                             <name>timeaccount_id</name>
143                         </field>
144                         <foreign>true</foreign>
145                         <reference>
146                             <table>timetracker_timeaccount</table>
147                             <field>id</field>
148                         </reference>
149                     </index>
150                     <index>
151                         <name>timesheet_favorites--account_id::id</name>
152                         <field>
153                             <name>account_id</name>
154                         </field>
155                         <foreign>true</foreign>
156                         <reference>
157                             <table>accounts</table>
158                             <field>id</field>
159                             <ondelete>CASCADE</ondelete>
160                         </reference>
161                     </index>
162                 </declaration>
163             </table>');
164
165             $this->_backend->createTable($declaration, 'Timetracker', 'timetracker_timeaccount_fav');
166             $this->setTableVersion('timetracker_timeaccount_fav', 1);
167         }
168         $this->setApplicationVersion('Timetracker', '10.3');
169     }
170
171     /**
172      * 0012470: Don't shorten description in export
173      */
174     public function update_3()
175     {
176         Setup_Controller::getInstance()->createImportExportDefinitions(Tinebase_Application::getInstance()->getApplicationByName('Timetracker'));
177         $this->setApplicationVersion('Timetracker', '10.4');
178     }
179
180     /**
181      * update to 10.5
182      *
183      * Add fulltext index to field description of timesheet
184      * - re-run update 0 + 1 because 2017.02 added update 2 + 3
185      */
186     public function update_4()
187     {
188         $this->update_0();
189         $this->update_1();
190         $this->setApplicationVersion('Timetracker', '10.5');
191     }
192 }