source: branches/2.5/expressoCalendar/setup/tables_update.inc.php @ 7938

Revision 7938, 11.5 KB checked in by douglas, 11 years ago (diff)

Ticket #3363 - Manter preferencia do checkbox de visualizacao das agendas no ExpressoCalendar?

Line 
1<?php
2        /**************************************************************************\
3        * ExpressoLivre - Setup                                                     *
4        * http://www.expressolivre.org                                              *
5        * --------------------------------------------                             *
6        * This program is free software; you can redistribute it and/or modify it  *
7        * under the terms of the GNU General Public License as published by the    *
8        * Free Software Foundation; either version 2 of the License, or (at your   *
9        * option) any later version.                                               *
10        \**************************************************************************/
11
12        $test[] = '1.000';
13        function expressoCalendar_upgrade1_000() {
14
15                $oProc = $GLOBALS['phpgw_setup']->oProc;
16
17                $oProc->query("ALTER TABLE calendar_participant ADD COLUMN acl character varying(10) not null DEFAULT 'r' ");
18               
19                $oProc->query("ALTER TABLE calendar_participant ADD COLUMN receive_notification smallint not null DEFAULT 1 ");
20                $oProc->query('ALTER TABLE calendar_participant RENAME COLUMN delegated_to TO delegated_from ');
21               
22                $oProc->query("UPDATE calendar_participant SET acl = 'rowi' where is_organizer = 1 ");
23
24                $oProc->query('ALTER TABLE calendar_object  ALTER COLUMN range_start TYPE bigint USING (date_part(\'epoch\',(cast(range_start as timestamp)))::bigint) * 1000');
25                $oProc->query('ALTER TABLE calendar_object  ALTER COLUMN range_end TYPE bigint USING (date_part(\'epoch\',(cast(range_end as timestamp)))::bigint) * 1000');
26
27                $oProc->query('ALTER TABLE calendar_alarm ALTER COLUMN range_end TYPE bigint USING (date_part(\'epoch\',(cast(range_end as timestamp)))::bigint) * 1000');
28                $oProc->query('ALTER TABLE calendar_alarm ALTER COLUMN range_start TYPE bigint USING (date_part(\'epoch\',(cast(range_start as timestamp)))::bigint) * 1000');
29
30                $oProc->query("ALTER TABLE attachment ADD COLUMN owner integer");
31
32                $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.001';
33        return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
34        }
35
36        $test[] = '1.001';
37        function expressoCalendar_upgrade1_001() {
38
39                $oProc = $GLOBALS['phpgw_setup']->oProc;
40
41                $oProc->query("ALTER TABLE calendar_repeat ADD COLUMN dtstart bigint");
42                $oProc->query('ALTER TABLE calendar_repeat ALTER COLUMN until DROP NOT NULL');
43
44                $oProc->CreateTable('calendar_repeat_occurrence', array(
45                                'fd' => array(
46                                    'id' => array( 'type' => 'auto', 'nullable' => False),
47                                    'occurrence' => array(  'type' => 'bigint','precision' => '16', 'nullable' => False),
48                                    'repeat_id' => array(  'type' => 'int', 'precision' => '8', 'nullable' => False)
49                                ),
50
51                                'pk' => array('id'),
52                                'fk' => array('repeat_id'),
53                                'ix' => array(),
54                                'uc' => array()
55                                )
56                );
57
58                $oProc->CreateTable('calendar_repeat_ranges', array(
59                        'fd' => array(
60                            'id' => array( 'type' => 'auto', 'nullable' => False),
61                            'range_start' => array(  'type' => 'bigint','precision' => '16', 'nullable' => False),
62                            'range_end' => array(  'type' => 'bigint', 'precision' => '16', 'nullable' => False),
63                            'user_info_id' => array(  'type' => 'bigint', 'precision' => '16', 'nullable' => False)
64                        ),
65                        'pk' => array('id'),
66                        'fk' => array(),
67                        'ix' => array(),
68                        'uc' => array()
69                            )
70                );
71
72                $oProc->query("ALTER TABLE calendar_participant ADD COLUMN receive_notification smallint not null DEFAULT 1 ");
73
74                $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.002';
75        return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
76        };
77
78        $test[] = '1.002';
79        function expressoCalendar_upgrade1_002() {
80
81        $oProc = $GLOBALS['phpgw_setup']->oProc;
82
83        $oProc->query("ALTER TABLE calendar_repeat_occurrence ADD COLUMN exception smallint DEFAULT 0");
84
85        $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.003';
86        return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
87        };
88       
89        $test[] = '1.003';
90        function expressoCalendar_upgrade1_003() {
91        $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.004';
92        return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
93        };
94
95        $test[] = '1.004';
96        function expressoCalendar_upgrade1_004() {
97        $oProc = $GLOBALS['phpgw_setup']->oProc;
98        $oProc->query("ALTER TABLE calendar_repeat_occurrence  ALTER COLUMN exception SET default 0");
99
100        $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.005';
101        return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
102        };
103       
104        $test[] = '1.005';
105        function expressoCalendar_upgrade1_005() {
106        $oProc = $GLOBALS['phpgw_setup']->oProc;
107        $oProc->query("ALTER TABLE calendar_alarm ADD COLUMN alarm_offset bigint;");
108            $oProc->query("UPDATE calendar_alarm SET alarm_offset = obj.range_start - calendar_alarm.range_start FROM calendar_object as obj WHERE obj.id = object_id;");
109            $oProc->query("ALTER TABLE calendar_alarm DROP COLUMN range_start;");
110            $oProc->query("ALTER TABLE calendar_alarm DROP COLUMN range_end;");
111        $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.006';
112        return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
113        };
114       
115       
116        $test[] = '1.006';
117        function expressoCalendar_upgrade1_006() {
118            $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.007';
119            return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
120        };
121       
122        $test[] = '1.007';
123        function expressoCalendar_upgrade1_007() {
124            $oProc = $GLOBALS['phpgw_setup']->oProc;
125
126            $oProc->query("ALTER TABLE calendar_object ADD COLUMN priority smallint DEFAULT 0;");
127            $oProc->query("ALTER TABLE calendar_object ADD COLUMN percentage smallint DEFAULT 0;");
128            $oProc->query("ALTER TABLE calendar_object ADD COLUMN status smallint DEFAULT 0;");
129
130            $oProc->query("ALTER TABLE calendar_object ADD COLUMN due bigint DEFAULT 0;");
131
132            $oProc->query("ALTER TABLE calendar ADD COLUMN type smallint DEFAULT 0;");
133            $oProc->query("ALTER TABLE calendar_signature ADD COLUMN type smallint DEFAULT 0;");
134
135            $oProc->query("INSERT INTO calendar_object_type(id, name) VALUES ('2', 'TODO');");
136
137            $oProc->query("CREATE TABLE calendar_task_to_activity_object(id serial not null, calendar_object_activity_id integer not null, calendar_object_task_id integer not null, owner integer not null);");
138
139            $oProc->CreateTable('calendar_historic', array(
140                'fd' => array(
141                    'id' => array( 'type' => 'auto', 'nullable' => False),
142                    'object_id' => array('type' => 'int', 'precision' => '8','nullable' => True),
143                    'user_uidnumber' => array( 'type' => 'int', 'precision' => '8', 'nullable' => False),
144                    'dtstamp' => array( 'type' => 'bigint', 'precision' => '16', 'nullable' => False),
145                    'attribute' => array('type' => 'varchar','precision' => '50','nullable' => True),
146                    'before_value' => array( 'type' => 'varchar', 'precision' => '255', 'nullable' => True),             
147                    'after_value' => array( 'type' => 'varchar', 'precision' => '255', 'nullable' => True)           
148                ),
149                'pk' => array('id'),
150                'fk' => array(),
151                'ix' => array(),
152                'uc' => array()
153                )
154            );
155
156            $oProc->CreateTable('calendar_task_to_activity_object', array(
157                'fd' => array(
158                    'id' => array( 'type' => 'auto', 'nullable' => False),
159                    'calendar_object_activity_id' => array(  'type' => 'int', 'precision' => '8', 'nullable' => False),
160                    'calendar_object_task_id' => array(  'type' => 'int', 'precision' => '8', 'nullable' => False),
161                    'owner' => array(  'type' => 'int', 'precision' => '8', 'nullable' => False),
162                ),
163                'pk' => array('id'),
164                'fk' => array(),
165                'ix' => array(),
166                'uc' => array()
167                )
168            );
169
170            $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.008';
171            return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
172        };
173
174    $test[] = '1.008';
175    function expressoCalendar_upgrade1_008() {
176        $oProc = $GLOBALS['phpgw_setup']->oProc;
177
178        $oProc->query("ALTER TABLE calendar_permission ADD COLUMN owner bigint;");
179        $oProc->query("UPDATE calendar_permission SET owner = sig.user_uidnumber FROM calendar_signature as sig WHERE (sig.calendar_id = object_id AND sig.is_owner = '1');");
180
181        $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.009';
182        return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
183    };
184
185    $test[] = '1.009';
186    function expressoCalendar_upgrade1_009() {
187        $oProc = $GLOBALS['phpgw_setup']->oProc;
188
189        $oProc->query("ALTER TABLE attachment ALTER COLUMN type TYPE character varying(255);");
190        $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.010';
191        return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
192    };
193
194
195    $test[] = '1.010';
196    function expressoCalendar_upgrade1_010() {
197        $oProc = $GLOBALS['phpgw_setup']->oProc;
198
199
200            $oProc->CreateTable('calendar_timezones', array(
201                'fd' => array(
202                    'id' => array( 'type' => 'auto', 'nullable' => False),
203                    'timezone' => array(  'type' => 'varchar','precision' => '150', 'nullable' => False),
204
205                    'standard_frequency' => array(  'type' => 'varchar','precision' => '20', 'nullable' => False),
206                    'standard_dtstart' => array(  'type' => 'varchar','precision' => '20', 'nullable' => True),
207                    'standard_byday' => array(  'type' => 'varchar','precision' => '50', 'nullable' => True),
208                    'standard_bymonth' => array(  'type' => 'varchar','precision' => '50', 'nullable' => True),
209                    'standard_from' => array(  'type' => 'varchar','precision' => '10', 'nullable' => True),
210                    'standard_to' => array(  'type' => 'varchar','precision' => '10', 'nullable' => True),
211
212                    'daylight_frequency' => array(  'type' => 'varchar','precision' => '20', 'nullable' => False),
213                    'daylight_dtstart' => array(  'type' => 'varchar','precision' => '20', 'nullable' => True),
214                    'daylight_byday' => array(  'type' => 'varchar','precision' => '50', 'nullable' => True),
215                    'daylight_bymonth' => array(  'type' => 'varchar','precision' => '50', 'nullable' => True),
216                    'daylight_from' => array(  'type' => 'varchar','precision' => '10', 'nullable' => True),
217                    'daylight_to' => array(  'type' => 'varchar','precision' => '10', 'nullable' => True),
218
219                    'dtstamp' => array( 'type' => 'bigint', 'precision' => '16', 'precision' => '16', 'nullable' => False)
220                ),
221                'pk' => array('id'),
222                'fk' => array(),
223                'ix' => array(),
224                'uc' => array()
225            )
226        );
227
228        $oProc->query("INSERT INTO calendar_timezones(timezone, standard_frequency, standard_dtstart, standard_byday,
229        standard_bymonth, standard_from, standard_to, daylight_frequency, daylight_dtstart, daylight_byday,
230        daylight_bymonth, daylight_from, daylight_to, dtstamp) VALUES ('America/Sao_Paulo', 'YEARLY', '23:59',
231        '4SA', '2', '-0200','-0300', 'YEARLY', '23:59', '3SA', '10', '-0300','-0200', '". time() ."');");
232
233        $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.011';
234        return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
235    };
236 
237    $test[] = '1.011';
238    function expressoCalendar_upgrade1_011() {
239        $oProc = $GLOBALS['phpgw_setup']->oProc;
240 
241        $oProc->query("ALTER TABLE calendar_signature ADD COLUMN hidden integer");
242 
243        $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.012';
244        return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
245    };
246       
247?>
Note: See TracBrowser for help on using the repository browser.