forked from a-v-k/phpBugTracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upgrade.php
399 lines (368 loc) · 25.6 KB
/
upgrade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
<?php
// upgrade.php -- Upgrade from the previous version
// ------------------------------------------------------------------------
// Copyright (c) 2001 - 2004 The phpBugTracker Group
// ------------------------------------------------------------------------
// This file is part of phpBugTracker
//
// phpBugTracker is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// phpBugTracker is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with phpBugTracker; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// ------------------------------------------------------------------------
// $Id: upgrade.php,v 1.54 2008/09/29 04:12:32 brycen Exp $
define('NO_AUTH', 1);
define('THEME', 'default');
$upgrading = true;
include 'include.php';
$comment_text = "";
$log_text = "";
$num_errors = 0;
//// Handle a database error
//function handle_upgrade_error(&$obj) {
// global $log_text;
//
// $log_text .= "<div class=\"error\">";
// $log_text .= htmlentities($obj->message) . '<br>' . htmlentities($obj->userinfo);
// $log_text .= "</div>\n";
//}
function log_query($str) {
global $db, $log_text, $num_errors;
$log_text .= "SQL: " . $str . "<br>\n";
try {
$db->query($str);
} catch (Exception $exc) {
$num_errors = $num_errors + 1;
$log_text .= "<div class=\"error\">";
$log_text .= htmlentities(get_class($exc) . ':' . $exc->getCode() . ' ' . $exc->getMessage());
$log_text .= "</div>\n";
}
$log_text .= "<br>\n";
}
function upgrade() {
global $db, $comment_text, $log_text, $num_errors;
$thisvers = false;
$tmp_log = "Using the following information from config.php:<br>\n";
$tmp_log .= "DB_TYPE: '" . DB_TYPE . "'<br>\n";
$tmp_log .= "DB_HOST: '" . DB_HOST . "'<br>\n";
$tmp_log .= "DB_DATABASE: '" . DB_DATABASE . "'<br>\n";
//$tmp_log .= "DB_USER: '".DB_USER."'<br>\n";
//$tmp_log .= "DB_PASSWORD: '".DB_PASSWORD."'<br>\n";
$tmp_log .= "<br>\n";
//$db->setErrorHandling(PEAR_ERROR_CALLBACK, "handle_upgrade_error");
// $query = 'select count(*) from ' . TBL_CONFIGURATION;
// $tmp_log .= "<p>SQL: " . $query . "<br>\n";
// $count = $db->getOne($query);
// if (DB::isError($count)) {
// $tmp_log .= $log_text;
// $log_text = "";
// $count = 0;
// }
// $tmp_log .= "count = " . $count . "</p>\n";
//if ($count > 30) {
$query = 'select varvalue from ' . TBL_CONFIGURATION . ' where varname = \'DB_VERSION\'';
$tmp_log .= "<p>SQL: " . $query . "<br>\n";
try {
$thisvers = $db->getOne($query);
} catch (Exception $exc) {
$tmp_log .= "<div class=\"error\">";
$tmp_log .= "Error while getting current DB version from DB: ";
$tmp_log .= htmlentities(get_class($exc) . ':' . $exc->getCode() . ' ' . $exc->getMessage());
$tmp_log .= "</div>\n";
}
//}
if (!is_numeric($thisvers)) {
die('failed to detect current database version');
}
$tmp_log .= "DB_VERSION = " . $thisvers . "</p>\n";
$upgradeTo = $thisvers + 1;
$comment_text .= "Current DB version = $thisvers<br>\n";
$comment_text .= "Release DB version = " . CUR_DB_VERSION . "<br>\n";
if ($thisvers < CUR_DB_VERSION) {
$comment_text .= "Upgrading to version = " . $upgradeTo . "<br>\n";
}
$comment_text .= "<br>\n";
$log_text = $tmp_log;
$needUpdate = 1;
if ($thisvers >= CUR_DB_VERSION) {
$needUpdate = 0;
}
if ($needUpdate == 1) {
switch (DB_TYPE) {
case 'pgsql' :
if (false) {
$comment_text .= "<div class=\"error\">Upgrading of old installs is still unsupported</div>";
$comment_text .= "<p>An upgrade script has been written, but it is completely UNTESTED! Proceed At Your Own Risk...</p>";
$comment_text .= "<p>Don't forget to report your success (or failure) story to sourceforge. We have interest in detailed error reports and patches from people who use PostgreSQL.</p>";
include 'templates/default/upgrade-finished.html';
exit;
}
if ($thisvers < 2) {
log_query("alter table " . TBL_AUTH_GROUP . " ADD assignable INT2");
log_query("alter table " . TBL_AUTH_GROUP . " alter assignable set DEFAULT 0");
log_query("update " . TBL_AUTH_GROUP . " set assignable = 0");
log_query("alter table " . TBL_AUTH_GROUP . " alter assignable set NOT NULL");
}
if ($thisvers < 3) {
log_query("ALTER TABLE " . TBL_USER_PREF . " ADD def_results INT4");
log_query("ALTER TABLE " . TBL_USER_PREF . " alter def_results set DEFAULT 20");
log_query("update " . TBL_USER_PREF . " set def_results = 20");
log_query("ALTER TABLE " . TBL_USER_PREF . " alter def_results set NOT NULL");
}
if ($thisvers < 4) {
log_query('ALTER TABLE ' . TBL_STATUS . ' ADD bug_open INT2');
log_query("ALTER TABLE " . TBL_STATUS . " alter bug_open set DEFAULT 1");
log_query("update " . TBL_STATUS . " set bug_open = 1");
log_query("ALTER TABLE " . TBL_STATUS . " alter bug_open set NOT NULL");
}
if ($thisvers < 5) {
log_query("create table " . TBL_PRIORITY . "( priority_id INT4 NOT NULL DEFAULT '0', priority_name varchar(30) NOT NULL DEFAULT '', priority_desc TEXT DEFAULT '' NOT NULL, sort_order INT2 NOT NULL DEFAULT '0', priority_color varchar(10) NOT NULL DEFAULT '#FFFFFF', PRIMARY KEY (priority_id) )");
log_query("create table " . TBL_BOOKMARK . "( user_id INT4 NOT NULL DEFAULT '0', bug_id INT4 NOT NULL DEFAULT '0' )");
log_query("ALTER TABLE " . TBL_COMPONENT . " ADD sort_order INT2");
log_query("ALTER TABLE " . TBL_COMPONENT . " alter sort_order set DEFAULT 0");
log_query("ALTER TABLE " . TBL_COMPONENT . " alter sort_order set NOT NULL");
log_query("ALTER TABLE " . TBL_VERSION . " ADD sort_order INT2");
log_query("ALTER TABLE " . TBL_VERSION . " alter sort_order set DEFAULT 0");
log_query("ALTER TABLE " . TBL_VERSION . " alter sort_order set NOT NULL");
log_query("CREATE SEQUENCE " . TBL_PRIORITY . "_seq START 6");
log_query("ALTER TABLE " . TBL_AUTH_GROUP . " ADD is_role INT2");
log_query("ALTER TABLE " . TBL_AUTH_GROUP . " alter is_role set DEFAULT 0");
log_query("ALTER TABLE " . TBL_AUTH_GROUP . " alter is_role set NOT NULL");
log_query("DROP SEQUENCE " . TBL_AUTH_GROUP . "_seq");
log_query("CREATE SEQUENCE " . TBL_AUTH_GROUP . "_seq START 10");
log_query("create table " . TBL_PROJECT_PERM . " ( project_id INT4 NOT NULL DEFAULT '0', user_id INT4 NOT NULL DEFAULT '0' )");
}
break;
case 'mysqli' :
case 'mysql' :
if (false) {
$comment_text .= "<div class=\"error\">Upgrading of old installs is probably available.</div>";
$comment_text .= "<p>An upgrade script has been written, but it is lightly tested! Proceed At Your Own Risk...</p>";
$comment_text .= "<p>Don't forget to report your success (or failure) story to sourceforge.net";
include 'templates/default/upgrade-finished.html';
exit;
}
if ($thisvers < 2) {
log_query("alter table " . TBL_AUTH_GROUP . " ADD assignable TINYINT DEFAULT 0 NOT NULL AFTER locked");
}
if ($thisvers < 3) {
log_query("ALTER TABLE " . TBL_USER_PREF . " ADD def_results INT DEFAULT '20' NOT NULL");
}
if ($thisvers < 4) {
log_query('ALTER TABLE ' . TBL_STATUS . ' ADD bug_open TINYINT DEFAULT \'1\' NOT NULL');
}
if ($thisvers < 5) {
log_query("create table if not exists " . TBL_PRIORITY . " ( priority_id int(10) unsigned NOT NULL default '0', priority_name varchar(30) NOT NULL default '', priority_desc text NOT NULL, sort_order tinyint(3) unsigned NOT NULL default '0', priority_color varchar(10) NOT NULL default '#FFFFFF', PRIMARY KEY (priority_id) )");
log_query("create table if not exists " . TBL_BOOKMARK . " ( user_id int(10) unsigned NOT NULL default '0', bug_id int(10) unsigned NOT NULL default '0' )");
log_query("alter table " . TBL_COMPONENT . " ADD sort_order tinyint(3) unsigned NOT NULL default '0' AFTER active");
log_query("alter table " . TBL_VERSION . " ADD sort_order tinyint(3) unsigned NOT NULL default '0' AFTER active");
log_query("CREATE TABLE IF NOT EXISTS " . TBL_PRIORITY . "_seq (id int unsigned auto_increment not null primary key)");
log_query("INSERT INTO " . TBL_PRIORITY . "_seq values (5)");
log_query("alter table " . TBL_AUTH_GROUP . " ADD is_role tinyint(1) unsigned NOT NULL default '0'");
log_query("DROP TABLE " . TBL_AUTH_GROUP . "_seq");
log_query("CREATE TABLE IF NOT EXISTS " . TBL_AUTH_GROUP . "_seq (id int unsigned auto_increment not null primary key)");
log_query("INSERT INTO " . TBL_AUTH_GROUP . "_seq values (9)");
log_query("create table if not exists " . TBL_PROJECT_PERM . " ( project_id int(11) NOT NULL default '0', user_id int(11) NOT NULL default '0' )");
}
if ($thisvers < 6) {
log_query("create INDEX bug_id_attachment ON " . TBL_ATTACHMENT . " (bug_id);");
log_query("create INDEX bug_id_bookmark ON " . TBL_BOOKMARK . " (bug_id);");
log_query("create INDEX bug_id_comment ON " . TBL_COMMENT . " (bug_id);");
}
if ($upgradeTo == 8) {
log_query("alter table " . TBL_ATTACHMENT . " engine=InnoDB;");
}
if ($upgradeTo == 9) {
log_query("alter table " . TBL_ATTACHMENT . " add column bytes longblob after file_name;");
}
if ($upgradeTo == 10) {
log_query("alter table " . TBL_BUG . " engine=InnoDB;");
}
if ($upgradeTo == 11) {
log_query("alter table " . TBL_COMMENT . " engine=InnoDB;");
}
if ($upgradeTo == 12) {
log_query("alter table " . TBL_BOOKMARK . " engine=InnoDB;");
}
if ($upgradeTo == 13) {
//log_query("alter table " . TBL_ACTIVE_SESSIONS . " engine=InnoDB;");
//log_query("alter table " . TBL_DB_SEQUENCE . " engine=InnoDB;");
log_query("alter table " . TBL_AUTH_GROUP . " engine=InnoDB;");
log_query("alter table " . TBL_AUTH_PERM . " engine=InnoDB;");
log_query("alter table " . TBL_AUTH_USER . " engine=InnoDB;");
}
if ($upgradeTo == 14) {
log_query("alter table " . TBL_BUG_CC . " engine=InnoDB;");
log_query("alter table " . TBL_BUG_DEPENDENCY . " engine=InnoDB;");
log_query("alter table " . TBL_BUG_GROUP . " engine=InnoDB;");
log_query("alter table " . TBL_BUG_HISTORY . " engine=InnoDB;");
log_query("alter table " . TBL_BUG_VOTE . " engine=InnoDB;");
}
if ($upgradeTo == 15) {
log_query("alter table " . TBL_COMPONENT . " engine=InnoDB;");
log_query("alter table " . TBL_CONFIGURATION . " engine=InnoDB;");
log_query("alter table " . TBL_GROUP_PERM . " engine=InnoDB;");
log_query("alter table " . TBL_OS . " engine=InnoDB;");
log_query("alter table " . TBL_PROJECT . " engine=InnoDB;");
log_query("alter table " . TBL_RESOLUTION . " engine=InnoDB;");
}
if ($upgradeTo == 16) {
log_query("alter table " . TBL_SAVED_QUERY . " engine=InnoDB;");
log_query("alter table " . TBL_SEVERITY . " engine=InnoDB;");
log_query("alter table " . TBL_STATUS . " engine=InnoDB;");
log_query("alter table " . TBL_USER_GROUP . " engine=InnoDB;");
log_query("alter table " . TBL_USER_PERM . " engine=InnoDB;");
log_query("alter table " . TBL_USER_PREF . " engine=InnoDB;");
}
if ($upgradeTo == 17) {
log_query("alter table " . TBL_VERSION . " engine=InnoDB;");
log_query("alter table " . TBL_PROJECT_GROUP . " engine=InnoDB;");
log_query("alter table " . TBL_PROJECT_PERM . " engine=InnoDB;");
log_query("alter table " . TBL_DATABASE . " engine=InnoDB;");
log_query("alter table " . TBL_SITE . " engine=InnoDB;");
log_query("alter table " . TBL_PRIORITY . " engine=InnoDB;");
}
if ($upgradeTo == 20) {
log_query("alter table " . TBL_VERSION . " engine=InnoDB;"); // just for upgrade testing
}
if ($upgradeTo == 21) {
log_query("alter table " . TBL_AUTH_USER . " modify column password char(60) not null default '';"); // for future use password_hash
}
break;
case 'oci8' :
if (true) {
$comment_text .= "<div class=\"error\">Upgrading of old installs is still unsupported</div>";
$comment_text .= "<p>An Oracle upgrade script has been written, but it is completely UNTESTED! Proceed At Your Own Risk...</p>";
$comment_text .= "<p>Don't forget to report your success (or failure) story to sourceforge if you do proceed. We have interest in detailed error reports and patches from people who use Oracle.</p>";
include 'templates/default/upgrade-finished.html';
exit;
}
log_query("create table " . TBL_PROJECT_PERM . " ( project_id number(10) default '0' NOT NULL, user_id number(10) default '0' NOT NULL )");
if ($thisvers < 2) {
log_query("alter table " . TBL_AUTH_GROUP . " ADD (assignable number(1) default '0' NOT NULL)");
}
if ($thisvers < 3) {
log_query("ALTER TABLE " . TBL_USER_PREF . " ADD (def_results number(10) default '20' NOT NULL)");
}
if ($thisvers < 4) {
log_query("ALTER TABLE " . TBL_STATUS . " ADD (bug_open number(1) default '1' NOT NULL)");
}
if ($thisvers < 5) {
log_query("create table " . TBL_PRIORITY . " ( priority_id number(3) default '0' NOT NULL, priority_name varchar2(30) default '' NOT NULL, priority_desc varchar2(4000) NOT NULL, sort_order number(3) default '0' NOT NULL, priority_color varchar2(10) default '#FFFFFF' NOT NULL, PRIMARY KEY (priority_id) )");
log_query("create table " . TBL_BOOKMARK . " ( user_id number(10) default '0' NOT NULL, bug_id number(10) default '0' NOT NULL )");
log_query("ALTER TABLE " . TBL_COMPONENT . " ADD ( sort_order number(3) default '0' NOT NULL )");
log_query("ALTER TABLE " . TBL_VERSION . " ADD ( sort_order number(3) default '0' NOT NULL )");
log_query("CREATE SEQUENCE " . TBL_PRIORITY . "_seq START WITH 6 NOCACHE");
log_query("ALTER TABLE " . TBL_AUTH_GROUP . " ADD ( is_role number(1) default '0' NOT NULL )");
log_query("DROP SEQUENCE " . TBL_AUTH_GROUP . "_seq");
log_query("CREATE SEQUENCE " . TBL_AUTH_GROUP . "_seq START WITH 10 NOCACHE");
}
break;
}
/** Database-independent changes */
if ($thisvers < 2) {
log_query("DELETE FROM " . TBL_CONFIGURATION . " WHERE varname = 'GROUP_ASSIGN_TO'");
log_query("UPDATE " . TBL_AUTH_GROUP . " SET assignable = 1 WHERE group_id = 3");
log_query("INSERT INTO " . TBL_CONFIGURATION . " VALUES ('EMAIL_DISABLED', '0', 'Whether to disable all mail sent from the system', 'bool');");
/* add db-version attribute */
log_query("INSERT INTO " . TBL_CONFIGURATION . " VALUES ('DB_VERSION', '" . (int) CUR_DB_VERSION . "', 'Database Version <b>Warning:</b> Changing this might make things go horribly wrong.', 'string')");
}
if ($thisvers < 4) {
log_query('DELETE FROM ' . TBL_CONFIGURATION . ' WHERE varname = \'BUG_CLOSED\'');
$comment_text .= "You must set your Statuses to either open or closed. Default settings should be modified so that \"resolved\", \"closed\", and \"verified\" are shown as being closed, and all other statuses are set to open.<br><br>\n";
log_query("INSERT INTO " . TBL_AUTH_PERM . " (perm_id, perm_name) VALUES (3, 'EditAssignment')");
}
if ($thisvers < 5) {
//log_query("DELETE FROM ".TBL_AUTH_GROUP." WHERE 1"); // Note mysqlism
//log_query("DELETE FROM ".TBL_AUTH_PERM." WHERE 1"); // Note mysqlism
//log_query("DELETE FROM ".TBL_GROUP_PERM." WHERE 1"); // Note mysqlism
log_query("INSERT INTO " . TBL_AUTH_GROUP . " (group_id, group_name, locked) VALUES (1, 'Admin', 1)");
log_query("INSERT INTO " . TBL_AUTH_GROUP . " (group_id, group_name, locked) VALUES (2, 'User', 1)");
log_query("INSERT INTO " . TBL_AUTH_GROUP . " (group_id, group_name, locked) VALUES (3, 'Developer', 0)");
//log_query("INSERT INTO ".TBL_AUTH_GROUP." (group_id, group_name, locked) VALUES (4, 'Manager', 1)");
log_query("INSERT INTO " . TBL_AUTH_GROUP . " (group_id, group_name, is_role, locked) VALUES (5, 'Guest', 1, 1)");
log_query("INSERT INTO " . TBL_AUTH_GROUP . " (group_id, group_name, is_role, locked) VALUES (6, 'User', 1, 1)"); // Magic don't edit
log_query("INSERT INTO " . TBL_AUTH_GROUP . " (group_id, group_name, is_role, locked) VALUES (7, 'Reporter', 1, 1)");
log_query("INSERT INTO " . TBL_AUTH_GROUP . " (group_id, group_name, is_role, locked) VALUES (8, 'Assignee', 1, 1)");
log_query("INSERT INTO " . TBL_AUTH_GROUP . " (group_id, group_name, is_role, locked) VALUES (9, 'Owner', 1, 1)");
log_query("INSERT INTO " . TBL_AUTH_PERM . " (perm_id, perm_name) VALUES (1, 'Admin')");
log_query("INSERT INTO " . TBL_AUTH_PERM . " (perm_id, perm_name) VALUES (2, 'AddBug')");
log_query("INSERT INTO " . TBL_AUTH_PERM . " (perm_id, perm_name) VALUES (3, 'EditAssignment')");
log_query("INSERT INTO " . TBL_AUTH_PERM . " (perm_id, perm_name) VALUES (4, 'Assignable')");
log_query("INSERT INTO " . TBL_AUTH_PERM . " (perm_id, perm_name) VALUES (5, 'EditBug')");
log_query("INSERT INTO " . TBL_AUTH_PERM . " (perm_id, perm_name) VALUES (6, 'CloseBug')");
log_query("INSERT INTO " . TBL_AUTH_PERM . " (perm_id, perm_name) VALUES (7, 'CommentBug')");
log_query("INSERT INTO " . TBL_AUTH_PERM . " (perm_id, perm_name) VALUES (8, 'EditPriority')");
log_query("INSERT INTO " . TBL_AUTH_PERM . " (perm_id, perm_name) VALUES (9, 'EditStatus')");
log_query("INSERT INTO " . TBL_AUTH_PERM . " (perm_id, perm_name) VALUES (10, 'EditSeverity')");
log_query("INSERT INTO " . TBL_AUTH_PERM . " (perm_id, perm_name) VALUES (11, 'EditResolution')");
log_query("INSERT INTO " . TBL_AUTH_PERM . " (perm_id, perm_name) VALUES (12, 'EditProject')");
log_query("INSERT INTO " . TBL_AUTH_PERM . " (perm_id, perm_name) VALUES (13, 'EditComponent')");
log_query("INSERT INTO " . TBL_AUTH_PERM . " (perm_id, perm_name) VALUES (14, 'ManageBug')");
log_query("INSERT INTO " . TBL_GROUP_PERM . " (group_id, perm_id) VALUES (1, 1)");
log_query("INSERT INTO " . TBL_GROUP_PERM . " (group_id, perm_id) VALUES (5, 7)");
log_query("INSERT INTO " . TBL_GROUP_PERM . " (group_id, perm_id) VALUES (6, 2)");
log_query("INSERT INTO " . TBL_GROUP_PERM . " (group_id, perm_id) VALUES (7, 5)");
log_query("INSERT INTO " . TBL_GROUP_PERM . " (group_id, perm_id) VALUES (7, 10)");
log_query("INSERT INTO " . TBL_GROUP_PERM . " (group_id, perm_id) VALUES (3, 4)");
log_query("INSERT INTO " . TBL_GROUP_PERM . " (group_id, perm_id) VALUES (3, 5)");
log_query("INSERT INTO " . TBL_GROUP_PERM . " (group_id, perm_id) VALUES (8, 8)");
log_query("INSERT INTO " . TBL_GROUP_PERM . " (group_id, perm_id) VALUES (8, 9)");
log_query("INSERT INTO " . TBL_GROUP_PERM . " (group_id, perm_id) VALUES (8, 11)");
log_query("INSERT INTO " . TBL_GROUP_PERM . " (group_id, perm_id) VALUES (4, 3)");
log_query("INSERT INTO " . TBL_GROUP_PERM . " (group_id, perm_id) VALUES (4, 6)");
log_query("INSERT INTO " . TBL_GROUP_PERM . " (group_id, perm_id) VALUES (4, 12)");
log_query("INSERT INTO " . TBL_GROUP_PERM . " (group_id, perm_id) VALUES (4, 13)");
log_query("INSERT INTO " . TBL_GROUP_PERM . " (group_id, perm_id) VALUES (4, 14)");
log_query("INSERT INTO " . TBL_GROUP_PERM . " (group_id, perm_id) VALUES (9, 6)");
log_query("INSERT INTO " . TBL_GROUP_PERM . " (group_id, perm_id) VALUES (9, 7)");
log_query("INSERT INTO " . TBL_GROUP_PERM . " (group_id, perm_id) VALUES (9, 8)");
log_query("INSERT INTO " . TBL_GROUP_PERM . " (group_id, perm_id) VALUES (9, 9)");
log_query("INSERT INTO " . TBL_GROUP_PERM . " (group_id, perm_id) VALUES (9, 10)");
log_query("INSERT INTO " . TBL_GROUP_PERM . " (group_id, perm_id) VALUES (9, 11)");
log_query("INSERT INTO " . TBL_GROUP_PERM . " (group_id, perm_id) VALUES (9, 13)");
log_query("INSERT INTO " . TBL_CONFIGURATION . " VALUES ('USE_PRIORITY_COLOR','0','Should the query list use the priority colors as the row background color','bool')");
log_query("INSERT INTO " . TBL_PRIORITY . " VALUES (1,'Low','Fix if possible',1,'#dadada')");
log_query("INSERT INTO " . TBL_PRIORITY . " VALUES (2,'Medium Low','Must fix before final',2,'#dad0d0')");
log_query("INSERT INTO " . TBL_PRIORITY . " VALUES (3,'Medium','Fix before next milestone (alpha, beta, etc.)',3,'#dac0c0')");
log_query("INSERT INTO " . TBL_PRIORITY . " VALUES (4,'Medium High','Fix as soon as possible',4,'#dab0b0')");
log_query("INSERT INTO " . TBL_PRIORITY . " VALUES (5,'High','Fix immediately',5,'#daaaaa')");
log_query("INSERT INTO " . TBL_CONFIGURATION . " VALUES ('NEW_ACCOUNTS_GROUP', 'User', 'The group assigned to new user accounts', 'string')");
log_query("UPDATE " . TBL_AUTH_USER . " SET bug_list_fields=null"); // Incompatible change, blow away user settings here
log_query("INSERT INTO " . TBL_AUTH_USER . " (user_id, login, first_name, last_name, email, password, active, bug_list_fields) values (0, 'Anonymous User', 'Anonymous', 'User', '', '', 0, null)");
}
if ($thisvers < 7) {
log_query("INSERT INTO " . TBL_CONFIGURATION . " VALUES ('USE_SEVERITY_COLOR_LINE','0','Should the query list use the severity colors as the row background color (like SourceForge)','bool');");
log_query("INSERT INTO " . TBL_CONFIGURATION . " VALUES ('USE_PRIORITY_COLOR_LINE','0','Should the query list use the priority colors as the row background color','bool');");
log_query("update " . TBL_CONFIGURATION . " set varvalue = 1, description = 'Should the query list use the severity colors as the field background color' where varname = 'USE_SEVERITY_COLOR'");
log_query("update " . TBL_CONFIGURATION . " set varvalue = 1, description = 'Should the query list use the priority colors as the field background color' where varname = 'USE_PRIORITY_COLOR'");
}
if ($num_errors == 0) {
/* update to current DB_VERSION */
log_query("UPDATE " . TBL_CONFIGURATION . " SET varvalue = '" . $upgradeTo . "' WHERE varname = 'DB_VERSION'");
$comment_text .= "Success!<br>\n";
} else {
$comment_text .= "Done, but with " . $num_errors . " error(s) <br>\n";
$comment_text .= "You need check upgrade.php script and your db to resolve errors <br>\n";
}
} else {
$comment_text .= "Nothing to do...<br>\n";
}
$comment_text .= "<br/><br/><font size='-1'>$log_text</font>";
require('templates/default/upgrade-finished.html.php');
}
if (filter_input(INPUT_GET, 'doit') == 1) {
upgrade();
} else {
$new_db_rev = CUR_DB_VERSION;
require('templates/default/upgrade.html');
}