a6979f46e6d23d9d8e6e2462e7e5c27cff38fdeb
[racktables] / wwwroot / inc / upgrade.php
1 <?php
2
3 $relnotes = array
4 (
5 '0.17.0' => <<<ENDOFTEXT
6 LDAP options have been moved to LDAP_options array. This means, that if you were
7 using LDAP authentication for users in version 0.16.x, it will break right after
8 upgrade to 0.17.0. To get things working again, adjust existing secret.php file
9 according to secret-sample.php file provided with 0.17.0 release.
10
11 This release is the first to take advantage of the foreign key support
12 provided by the InnoDB storage engine in MySQL. The installer and
13 upgrader scripts check for InnoDB support and cannot complete without it.
14 If you have trouble, the first step is to make sure the 'skip-innodb'
15 option in my.cnf is commented out.
16
17 Another change is the addition of support for file uploads. Files are stored
18 in the database. There are several settings in php.ini which you may need to modify:
19 file_uploads - needs to be On
20 upload_max_filesize - max size for uploaded files
21 post_max_size - max size of all form data submitted via POST (including files)
22
23 User accounts used to have 'enabled' flag, which allowed individual blocking and
24 unblocking of each. This flag was dropped in favor of existing mean of access
25 setup (RackCode). An unconditional denying rule is automatically added into RackCode
26 for such blocked account, so the effective security policy remains the same.
27 ENDOFTEXT
28 ,
29 '0.18.2' => <<<ENDOFTEXT
30 RackTables from its version 0.18.0 and later is not compatible with
31 RHEL/CentOS (at least with versions up to 5.5) Linux distributions
32 in their default installation. There are yet options to work around that:
33 1. Install RackTables on a server with a different distribution/OS.
34 2. Request Linux distribution vendor to fix the bug with PCRE.
35 3. Repair your RHEL/CentOS installation yourself by fixing its PCRE
36 RPM as explained here: http://bugs.centos.org/view.php?id=3252
37 ENDOFTEXT
38 ,
39 '0.19.0' => <<<ENDOFTEXT
40 The files, which are intended for the httpd (web-server) directory, are
41 now in the "wwwroot" directory of the tar.gz archive. Files outside of
42 that directory are not directly intended for httpd environment and should
43 not be copied to the server.
44
45 This release incorporates ObjectLog functionality, which used to be
46 available as a separate plugin. For the best results it is advised to
47 disable (through local.php) external ObjectLog plugin permanently before
48 the new version is installed. All previously accumulated ObjectLog records
49 will be available through the updated standard interface.
50
51 RackTables is now using PHP JSON extension which is included in the PHP
52 core since 5.2.0.
53
54 The barcode attribute was removed. The upgrade script attempts to
55 preserve the data by moving it to either the 'OEM S/N 1' attribute or to
56 a Log entry. You should backup your database beforehand anyway.
57 ENDOFTEXT
58 ,
59 '0.19.2' => <<<ENDOFTEXT
60 This release is different in filesystem layout. The "gateways" directory
61 has been moved from "wwwroot" directory. This improves security a bit.
62 You can also separate your local settings and add-ons from the core RackTables code.
63 To do that, put a single index.php file into the DocumentRoot of your http server:
64
65 <?php
66 \$racktables_confdir='/directory/where/your/secret.php/and/local.php/files/are/stored';
67 require '/directory_where_you_extracted_racktables_distro/wwwroot/index.php';
68 ?>
69
70 No more files are needed to be available directly over the HTTP.
71 Full list of filesystem paths which could be specified in custom index.php or secret.php:
72 \$racktables_gwdir: path to the gateways directory;
73 \$racktables_staticdir: path to the directory containing 'pix', 'js', 'css' dirs;
74 \$racktables_confdir: path where secret.php and local.php are located. It is not
75 recommended to define it in secret.php, cause only the path to
76 local.php will be affected;
77 \$path_to_secret_php: Ignore \$racktables_confdir when locating secret.php and use
78 the specified path;
79 \$path_to_local_php: idem for local.php.
80 ENDOFTEXT
81 ,
82 );
83
84 // At the moment we assume, that for any two releases we can
85 // sequentally execute all batches, that separate them, and
86 // nothing will break. If this changes one day, the function
87 // below will have to generate smarter upgrade paths, while
88 // the upper layer will remain the same.
89 // Returning an empty array means that no upgrade is necessary.
90 // Returning NULL indicates an error.
91 function getDBUpgradePath ($v1, $v2)
92 {
93 $versionhistory = array
94 (
95 '0.16.4',
96 '0.16.5',
97 '0.16.6',
98 '0.17.0',
99 '0.17.1',
100 '0.17.2',
101 '0.17.3',
102 '0.17.4',
103 '0.17.5',
104 '0.17.6',
105 '0.17.7',
106 '0.17.8',
107 '0.17.9',
108 '0.17.10',
109 '0.17.11',
110 '0.18.0',
111 '0.18.1',
112 '0.18.2',
113 '0.18.3',
114 '0.18.4',
115 '0.18.5',
116 '0.18.6',
117 '0.18.7',
118 '0.19.0',
119 '0.19.1',
120 '0.19.2',
121 '0.19.3',
122 '0.20.0',
123 );
124 if (!in_array ($v1, $versionhistory) or !in_array ($v2, $versionhistory))
125 return NULL;
126 $skip = TRUE;
127 $path = NULL;
128 // foreach() below cannot handle this specific case
129 if ($v1 == $v2)
130 return array();
131 // Now collect all versions > $v1 and <= $v2
132 foreach ($versionhistory as $v)
133 {
134 if ($skip and $v == $v1)
135 {
136 $skip = FALSE;
137 $path = array();
138 continue;
139 }
140 if ($skip)
141 continue;
142 $path[] = $v;
143 if ($v == $v2)
144 break;
145 }
146 return $path;
147 }
148
149 // Upgrade batches are named exactly as the release where they first appear.
150 // That is simple, but seems sufficient for beginning.
151 function executeUpgradeBatch ($batchid)
152 {
153 $query = array();
154 global $dbxlink;
155 switch ($batchid)
156 {
157 case '0.16.5':
158 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('IPV4_TREE_SHOW_USAGE','yes','string','no','no','Show address usage in IPv4 tree')";
159 $query[] = "update Config set varvalue = '0.16.5' where varname = 'DB_VERSION'";
160 break;
161 case '0.16.6':
162 $query[] = "update Config set varvalue = '0.16.6' where varname = 'DB_VERSION'";
163 break;
164 case '0.17.0':
165 // create tables for storing files (requires InnoDB support)
166 if (!isInnoDBSupported ())
167 {
168 showError ("Cannot upgrade because InnoDB tables are not supported by your MySQL server. See the README for details.", __FUNCTION__);
169 die;
170 }
171
172 $query[] = "alter table Chapter change chapter_no id int(10) unsigned NOT NULL auto_increment";
173 $query[] = "alter table Chapter change chapter_name name char(128) NOT NULL";
174 $query[] = "alter table Chapter drop key chapter_name";
175 $query[] = "alter table Chapter add UNIQUE KEY name (name)";
176 $query[] = "alter table Attribute change attr_id id int(10) unsigned NOT NULL auto_increment";
177 $query[] = "alter table Attribute change attr_type type enum('string','uint','float','dict') default NULL";
178 $query[] = "alter table Attribute change attr_name name char(64) default NULL";
179 $query[] = "alter table Attribute drop key attr_name";
180 $query[] = "alter table Attribute add UNIQUE KEY name (name)";
181 $query[] = "alter table AttributeMap change chapter_no chapter_id int(10) unsigned NOT NULL";
182 $query[] = "alter table Dictionary change chapter_no chapter_id int(10) unsigned NOT NULL";
183 // Only after the above call it is Ok to use reloadDictionary()
184 $query = array_merge ($query, reloadDictionary ($batchid));
185 // schema changes for file management
186 $query[] = "
187 CREATE TABLE `File` (
188 `id` int(10) unsigned NOT NULL auto_increment,
189 `name` char(255) NOT NULL,
190 `type` char(255) NOT NULL,
191 `size` int(10) unsigned NOT NULL,
192 `ctime` datetime NOT NULL,
193 `mtime` datetime NOT NULL,
194 `atime` datetime NOT NULL,
195 `contents` longblob NOT NULL,
196 `comment` text,
197 PRIMARY KEY (`id`),
198 UNIQUE KEY `name` (`name`)
199 ) ENGINE=InnoDB";
200 $query[] = "
201 CREATE TABLE `FileLink` (
202 `id` int(10) unsigned NOT NULL auto_increment,
203 `file_id` int(10) unsigned NOT NULL,
204 `entity_type` enum('ipv4net','ipv4rspool','ipv4vs','object','rack','user') NOT NULL default 'object',
205 `entity_id` int(10) NOT NULL,
206 PRIMARY KEY (`id`),
207 UNIQUE KEY `FileLink-unique` (`file_id`,`entity_type`,`entity_id`),
208 KEY `FileLink-file_id` (`file_id`),
209 CONSTRAINT `FileLink-File_fkey` FOREIGN KEY (`file_id`) REFERENCES `File` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
210 ) ENGINE=InnoDB";
211 $query[] = "ALTER TABLE TagStorage MODIFY COLUMN target_realm enum('file','ipv4net','ipv4rspool','ipv4vs','object','rack','user') NOT NULL default 'object'";
212
213 $query[] = "INSERT INTO `Chapter` (`id`, `sticky`, `name`) VALUES (24,'no','network security models')";
214 $query[] = "INSERT INTO `Chapter` (`id`, `sticky`, `name`) VALUES (25,'no','wireless models')";
215 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,1,0)";
216 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,2,24)";
217 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,3,0)";
218 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,5,0)";
219 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,14,0)";
220 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,16,0)";
221 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,17,0)";
222 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,18,0)";
223 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,20,0)";
224 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,21,0)";
225 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,22,0)";
226 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,24,0)";
227 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (965,1,0)";
228 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (965,3,0)";
229 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (965,2,25)";
230 $query[] = 'alter table IPBonds rename to IPv4Allocation';
231 $query[] = 'alter table PortForwarding rename to IPv4NAT';
232 $query[] = 'alter table IPRanges rename to IPv4Network';
233 $query[] = 'alter table IPAddress rename to IPv4Address';
234 $query[] = 'alter table IPLoadBalancer rename to IPv4LB';
235 $query[] = 'alter table IPRSPool rename to IPv4RSPool';
236 $query[] = 'alter table IPRealServer rename to IPv4RS';
237 $query[] = 'alter table IPVirtualService rename to IPv4VS';
238 $query[] = "alter table TagStorage change column target_realm entity_realm enum('file','ipv4net','ipv4vs','ipv4rspool','object','rack','user') NOT NULL default 'object'";
239 $query[] = 'alter table TagStorage change column target_id entity_id int(10) unsigned NOT NULL';
240 $query[] = 'alter table TagStorage drop key entity_tag';
241 $query[] = 'alter table TagStorage drop key target_id';
242 $query[] = 'alter table TagStorage add UNIQUE KEY `entity_tag` (`entity_realm`,`entity_id`,`tag_id`)';
243 $query[] = 'alter table TagStorage add KEY `entity_id` (`entity_id`)';
244 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('PREVIEW_TEXT_MAXCHARS','10240','uint','yes','no','Max chars for text file preview')";
245 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('PREVIEW_TEXT_ROWS','25','uint','yes','no','Rows for text file preview')";
246 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('PREVIEW_TEXT_COLS','80','uint','yes','no','Columns for text file preview')";
247 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('PREVIEW_IMAGE_MAXPXS','320','uint','yes','no','Max pixels per axis for image file preview')";
248 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('VENDOR_SIEVE','','string','yes','no','Vendor sieve configuration')";
249 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('IPV4LB_LISTSRC','{\$typeid_4}','string','yes','no','List source: IPv4 load balancers')";
250 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('IPV4OBJ_LISTSRC','{\$typeid_4} or {\$typeid_7} or {\$typeid_8} or {\$typeid_12} or {\$typeid_445} or {\$typeid_447}','string','yes','no','List source: IPv4-enabled objects')";
251 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('IPV4NAT_LISTSRC','{\$typeid_4} or {\$typeid_7} or {\$typeid_8}','string','yes','no','List source: IPv4 NAT performers')";
252 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('ASSETWARN_LISTSRC','{\$typeid_4} or {\$typeid_7} or {\$typeid_8}','string','yes','no','List source: object, for which asset tag should be set')";
253 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('NAMEWARN_LISTSRC','{\$typeid_4} or {\$typeid_7} or {\$typeid_8}','string','yes','no','List source: object, for which common name should be set')";
254 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('RACKS_PER_ROW','12','unit','yes','no','Racks per row')";
255 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('FILTER_PREDICATE_SIEVE','','string','yes','no','Predicate sieve regex(7)')";
256 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('FILTER_DEFAULT_ANDOR','or','string','no','no','Default list filter boolean operation (or/and)')";
257 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('FILTER_SUGGEST_ANDOR','yes','string','no','no','Suggest and/or selector in list filter')";
258 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('FILTER_SUGGEST_TAGS','yes','string','no','no','Suggest tags in list filter')";
259 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('FILTER_SUGGEST_PREDICATES','yes','string','no','no','Suggest predicates in list filter')";
260 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('FILTER_SUGGEST_EXTRA','no','string','no','no','Suggest extra expression in list filter')";
261 $query[] = "delete from Config where varname = 'USER_AUTH_SRC'";
262 $query[] = "delete from Config where varname = 'COOKIE_TTL'";
263 $query[] = "delete from Config where varname = 'rtwidth_0'";
264 $query[] = "delete from Config where varname = 'rtwidth_1'";
265 $query[] = "delete from Config where varname = 'rtwidth_2'";
266 $query[] = "delete from Config where varname = 'NAMEFUL_OBJTYPES'";
267 $query[] = "delete from Config where varname = 'REQUIRE_ASSET_TAG_FOR'";
268 $query[] = "delete from Config where varname = 'IPV4_PERFORMERS'";
269 $query[] = "delete from Config where varname = 'NATV4_PERFORMERS'";
270 $query[] = "alter table TagTree add column valid_realm set('file','ipv4net','ipv4vs','ipv4rspool','object','rack','user') not null default 'file,ipv4net,ipv4vs,ipv4rspool,object,rack,user' after parent_id";
271 $result = $dbxlink->query ("select user_id, user_name, user_realname from UserAccount where user_enabled = 'no'");
272 while ($row = $result->fetch (PDO::FETCH_ASSOC))
273 $query[] = "update Script set script_text = concat('deny {\$userid_${row['user_id']}} # ${row['user_name']} (${row['user_realname']})\n', script_text) where script_name = 'RackCode'";
274 $query[] = "update Script set script_text = NULL where script_name = 'RackCodeCache'";
275 unset ($result);
276 $query[] = "alter table UserAccount drop column user_enabled";
277
278 $query[] = "CREATE TABLE RackRow ( id int(10) unsigned NOT NULL auto_increment, name char(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM";
279
280 $result = $dbxlink->query ("select dict_key, dict_value from Dictionary where chapter_no = 3");
281 while($row = $result->fetch(PDO::FETCH_NUM))
282 $query[] = "insert into RackRow set id=${row[0]}, name='${row[1]}'";
283 unset ($result);
284 $query[] = "delete from Dictionary where chapter_id = 3";
285 $query[] = "delete from Chapter where id = 3";
286 $query[] = "
287 CREATE TABLE `LDAPCache` (
288 `presented_username` char(64) NOT NULL,
289 `successful_hash` char(40) NOT NULL,
290 `first_success` timestamp NOT NULL default CURRENT_TIMESTAMP,
291 `last_retry` timestamp NOT NULL default '0000-00-00 00:00:00',
292 `displayed_name` char(128) default NULL,
293 `memberof` text,
294 UNIQUE KEY `presented_username` (`presented_username`),
295 KEY `scanidx` (`presented_username`,`successful_hash`)
296 ) ENGINE=InnoDB;";
297 $query[] = "alter table UserAccount modify column user_password_hash char(40) NULL";
298 $query[] = 'ALTER TABLE Rack DROP COLUMN deleted';
299 $query[] = 'ALTER TABLE RackHistory DROP COLUMN deleted';
300 $query[] = 'ALTER TABLE RackObject DROP COLUMN deleted';
301 $query[] = 'ALTER TABLE RackObjectHistory DROP COLUMN deleted';
302 // Can't be added straight due to many duplicates, even in "dictbase" data.
303 $result = $dbxlink->query ('SELECT type1, type2, count(*) - 1 as excess FROM PortCompat GROUP BY type1, type2 HAVING excess > 0');
304 while ($row = $result->fetch (PDO::FETCH_ASSOC))
305 $query[] = "DELETE FROM PortCompat WHERE type1 = ${row['type1']} AND type2 = ${row['type2']} limit ${row['excess']}";
306 unset ($result);
307 $query[] = 'ALTER TABLE PortCompat DROP KEY type1';
308 $query[] = 'ALTER TABLE PortCompat ADD UNIQUE `type1_2` (type1, type2)';
309 $query[] = "UPDATE Config SET varvalue = '0.17.0' WHERE varname = 'DB_VERSION'";
310
311 break;
312 case '0.17.1':
313 $query[] = "ALTER TABLE Dictionary DROP KEY `chap_to_key`";
314 $query = array_merge ($query, reloadDictionary ($batchid));
315 // Token set has changed, so the cache isn't valid any more.
316 $query[] = "UPDATE Script SET script_text = NULL WHERE script_name = 'RackCodeCache'";
317 $query[] = "UPDATE Config SET varvalue = '0.17.1' WHERE varname = 'DB_VERSION'";
318 break;
319 case '0.17.2':
320 $query[] = "INSERT INTO `Chapter` (`id`, `sticky`, `name`) VALUES (26,'no','fibre channel switch models')";
321 $query = array_merge ($query, reloadDictionary ($batchid));
322 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1055,2,26)";
323 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('DEFAULT_SNMP_COMMUNITY','public','string','no','no','Default SNMP Community string')";
324 // wipe irrelevant records (ticket:250)
325 $query[] = "DELETE FROM TagStorage WHERE entity_realm = 'file' AND entity_id NOT IN (SELECT id FROM File)";
326 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('IPV4_ENABLE_KNIGHT','yes','string','no','no','Enable IPv4 knight feature')";
327 $query[] = "ALTER TABLE IPv4Network ADD COLUMN comment text AFTER name";
328 $query[] = "ALTER TABLE Port ADD INDEX comment (reservation_comment)";
329 $query[] = "ALTER TABLE Port DROP KEY l2address"; // UNIQUE
330 $query[] = "ALTER TABLE Port ADD KEY (l2address)"; // not UNIQUE
331 $query[] = "ALTER TABLE Port DROP KEY object_id";
332 $query[] = "ALTER TABLE Port ADD UNIQUE KEY per_object (object_id, name, type)";
333 $query[] = "INSERT INTO PortCompat (type1, type2) VALUES (20,1083)";
334 $query[] = "INSERT INTO PortCompat (type1, type2) VALUES (21,1083)";
335 $query[] = "INSERT INTO PortCompat (type1, type2) VALUES (1077,1077)";
336 $query[] = "INSERT INTO PortCompat (type1, type2) VALUES (1083,20)";
337 $query[] = "INSERT INTO PortCompat (type1, type2) VALUES (1083,21)";
338 $query[] = "INSERT INTO PortCompat (type1, type2) VALUES (1083,1083)";
339 $query[] = "INSERT INTO PortCompat (type1, type2) VALUES (1087,1087)";
340 $query[] = "INSERT INTO `Chapter` (`id`, `sticky`, `name`) VALUES (27,'no','PDU models')";
341 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (2,2,27)";
342 $query[] = "UPDATE Config SET varvalue = '0.17.2' WHERE varname = 'DB_VERSION'";
343 break;
344 case '0.17.3':
345 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('TAGS_TOPLIST_SIZE','50','uint','yes','no','Tags top list size')";
346 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('TAGS_QUICKLIST_SIZE','20','uint','no','no','Tags quick list size')";
347 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('TAGS_QUICKLIST_THRESHOLD','50','uint','yes','no','Tags quick list threshold')";
348 $query[] = "ALTER TABLE AttributeMap MODIFY COLUMN chapter_id int(10) unsigned NULL";
349 $query[] = "UPDATE AttributeMap SET chapter_id = NULL WHERE attr_id IN (SELECT id FROM Attribute WHERE type != 'dict')";
350 // ticket:239
351 $query[] = 'UPDATE AttributeValue SET uint_value = 1018 WHERE uint_value = 731 AND attr_id IN (SELECT attr_id FROM AttributeMap WHERE chapter_id = 12)';
352 $query[] = 'DELETE FROM Dictionary WHERE dict_key = 731';
353 $query = array_merge ($query, reloadDictionary ($batchid));
354 $query[] = "UPDATE Config SET vartype='uint' WHERE varname='RACKS_PER_ROW'";
355 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('ENABLE_MULTIPORT_FORM','no','string','no','no','Enable \"Add/update multiple ports\" form')";
356 $query[] = "UPDATE Config SET varvalue = '0.17.3' WHERE varname = 'DB_VERSION'";
357 break;
358 case '0.17.4':
359 $query[] = "ALTER TABLE Link ENGINE=InnoDB";
360 $query[] = "ALTER TABLE Port ENGINE=InnoDB";
361 $query[] = "ALTER TABLE IPv4RS ENGINE=InnoDB";
362 $query[] = "ALTER TABLE IPv4RSPool ENGINE=InnoDB";
363 $query[] = "ALTER TABLE AttributeValue ENGINE=InnoDB";
364 $query[] = "ALTER TABLE RackObject ENGINE=InnoDB";
365 $query[] = "ALTER TABLE IPv4NAT ENGINE=InnoDB";
366 $query[] = "ALTER TABLE IPv4LB ENGINE=InnoDB";
367 $query[] = "ALTER TABLE IPv4VS ENGINE=InnoDB";
368 $query[] = "DELETE FROM IPv4RS WHERE rspool_id NOT IN (SELECT id FROM IPv4RSPool)";
369 $query[] = "ALTER TABLE Link ADD CONSTRAINT `Link-FK-b` FOREIGN KEY (portb) REFERENCES Port (id)";
370 $query[] = "ALTER TABLE Link ADD CONSTRAINT `Link-FK-a` FOREIGN KEY (porta) REFERENCES Port (id)";
371 $query[] = "ALTER TABLE IPv4RS ADD CONSTRAINT `IPv4RS-FK` FOREIGN KEY (rspool_id) REFERENCES IPv4RSPool (id) ON DELETE CASCADE";
372 $query[] = "ALTER TABLE AttributeValue ADD CONSTRAINT `AttributeValue-FK-object_id` FOREIGN KEY (object_id) REFERENCES RackObject (id)";
373 $query[] = "ALTER TABLE IPv4NAT ADD CONSTRAINT `IPv4NAT-FK-object_id` FOREIGN KEY (object_id) REFERENCES RackObject (id)";
374 $query[] = "ALTER TABLE Port ADD CONSTRAINT `Port-FK-object_id` FOREIGN KEY (object_id) REFERENCES RackObject (id)";
375 $query[] = "ALTER TABLE IPv4LB ADD CONSTRAINT `IPv4LB-FK-rspool_id` FOREIGN KEY (rspool_id) REFERENCES IPv4RSPool (id)";
376 $query[] = "ALTER TABLE IPv4LB ADD CONSTRAINT `IPv4LB-FK-object_id` FOREIGN KEY (object_id) REFERENCES RackObject (id)";
377 $query[] = "ALTER TABLE IPv4LB ADD CONSTRAINT `IPv4LB-FK-vs_id` FOREIGN KEY (vs_id) REFERENCES IPv4VS (id)";
378 $query = array_merge ($query, reloadDictionary ($batchid));
379 $query[] = "UPDATE Config SET varvalue = '0.17.4' WHERE varname = 'DB_VERSION'";
380 break;
381 case '0.17.5':
382 $query[] = "ALTER TABLE TagTree ENGINE=InnoDB";
383 $query[] = "ALTER TABLE TagStorage ENGINE=InnoDB";
384 $query[] = "ALTER TABLE TagStorage ADD CONSTRAINT `TagStorage-FK-tag_id` FOREIGN KEY (tag_id) REFERENCES TagTree (id)";
385 $query[] = "ALTER TABLE TagTree ADD CONSTRAINT `TagTree-K-parent_id` FOREIGN KEY (parent_id) REFERENCES TagTree (id)";
386 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (21,1195)';
387 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (22,1196)';
388 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (23,1196)';
389 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (20,1195)';
390 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (25,1202)';
391 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (26,1202)';
392 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (27,1204)';
393 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (28,1204)';
394 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1083,1195)';
395 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1084,1084)';
396 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1195,20)';
397 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1195,21)';
398 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1195,1083)';
399 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1195,1195)';
400 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1196,22)';
401 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1196,23)';
402 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1196,1196)';
403 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1197,1197)';
404 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1198,1199)';
405 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1199,1198)';
406 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1200,1200)';
407 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1201,1201)';
408 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1202,25)';
409 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1202,26)';
410 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1202,1202)';
411 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1203,1203)';
412 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1204,27)';
413 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1204,28)';
414 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1204,1204)';
415 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1205,1205)';
416 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1206,1207)';
417 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1207,1206)';
418 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1316,1316)';
419 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (16, 1322)';
420 $query[] = 'INSERT INTO PortCompat (type1, type2) VALUES (1322, 16)';
421 $query[] = 'DELETE FROM PortCompat WHERE type1 = 16 AND type2 = 16';
422 for ($i = 1209; $i <= 1300; $i++)
423 $query[] = "INSERT INTO PortCompat (type1, type2) VALUES (${i}, ${i})";
424 $query[] = "
425 CREATE TABLE `PortInnerInterface` (
426 `id` int(10) unsigned NOT NULL,
427 `iif_name` char(16) NOT NULL,
428 PRIMARY KEY (`id`),
429 UNIQUE KEY `iif_name` (`iif_name`)
430 ) ENGINE=InnoDB";
431 $query[] = "INSERT INTO `PortInnerInterface` VALUES (1,'hardwired')";
432 $query[] = "INSERT INTO `PortInnerInterface` VALUES (2,'SFP-100')";
433 $query[] = "INSERT INTO `PortInnerInterface` VALUES (3,'GBIC')";
434 $query[] = "INSERT INTO `PortInnerInterface` VALUES (4,'SFP-1000')";
435 $query[] = "INSERT INTO `PortInnerInterface` VALUES (5,'XENPAK')";
436 $query[] = "INSERT INTO `PortInnerInterface` VALUES (6,'X2')";
437 $query[] = "INSERT INTO `PortInnerInterface` VALUES (7,'XPAK')";
438 $query[] = "INSERT INTO `PortInnerInterface` VALUES (8,'XFP')";
439 $query[] = "INSERT INTO `PortInnerInterface` VALUES (9,'SFP+')";
440 $query[] = "
441 CREATE TABLE `PortInterfaceCompat` (
442 `iif_id` int(10) unsigned NOT NULL,
443 `oif_id` int(10) unsigned NOT NULL,
444 UNIQUE KEY `pair` (`iif_id`,`oif_id`),
445 CONSTRAINT `PortInterfaceCompat-FK-iif_id` FOREIGN KEY (`iif_id`) REFERENCES `PortInnerInterface` (`id`)
446 ) ENGINE=InnoDB";
447 $query[] = "ALTER TABLE Port ADD COLUMN iif_id int unsigned NOT NULL AFTER name"; // will set iif_id to 0
448 $query[] = "UPDATE Port SET iif_id = 2 WHERE type = 1208";
449 $query[] = "UPDATE Port SET iif_id = 3 WHERE type = 1078";
450 $query[] = "UPDATE Port SET iif_id = 4 WHERE type = 1077";
451 $query[] = "UPDATE Port SET iif_id = 5 WHERE type = 1079";
452 $query[] = "UPDATE Port SET iif_id = 6 WHERE type = 1080";
453 $query[] = "UPDATE Port SET iif_id = 7 WHERE type = 1081";
454 $query[] = "UPDATE Port SET iif_id = 8 WHERE type = 1082";
455 $query[] = "UPDATE Port SET iif_id = 9 WHERE type = 1084";
456 $query[] = "UPDATE Port SET iif_id = 1 WHERE iif_id = 0";
457 $query[] = 'ALTER TABLE Port ADD UNIQUE `object_iif_oif_name` (object_id, iif_id, type, name)';
458 $query[] = 'ALTER TABLE Port DROP KEY `per_object`';
459 $base1000 = array (24, 34, 1202, 1203, 1204, 1205, 1206, 1207);
460 $base10000 = array (30, 35, 36, 37, 38, 39, 40);
461 $PICdata = array
462 (
463 1 => array (16, 19, 24, 29, 31, 33, 446, 681, 682, 1322),
464 2 => array (1208, 1195, 1196, 1197, 1198, 1199, 1200, 1201),
465 3 => array_merge (array (1078), $base1000),
466 4 => array_merge (array (1077), $base1000),
467 5 => array_merge (array (1079), $base10000),
468 6 => array_merge (array (1080), $base10000),
469 7 => array_merge (array (1081), $base10000),
470 8 => array_merge (array (1082), $base10000),
471 9 => array_merge (array (1084), $base10000),
472 );
473 // make sure all IIF/OIF pairs referenced from Port exist in PortInterfaceCompat before enabling FK
474 // iif_id doesn't exist at this point
475 $result = $dbxlink->query ('SELECT DISTINCT type FROM Port WHERE type NOT IN (1208, 1078, 1077, 1079, 1080, 1081, 1082, 1084)');
476 while ($row = $result->fetch (PDO::FETCH_ASSOC))
477 if (FALSE === array_search ($row['type'], $PICdata[1]))
478 array_push ($PICdata[1], $row['type']);
479 unset ($result);
480 foreach ($PICdata as $iif_id => $oif_ids)
481 foreach ($oif_ids as $oif_id)
482 $query[] = "INSERT INTO PortInterfaceCompat (iif_id, oif_id) VALUES (${iif_id}, ${oif_id})";
483 $query[] = "ALTER TABLE Port ADD CONSTRAINT `Port-FK-iif-oif` FOREIGN KEY (`iif_id`, `type`) REFERENCES `PortInterfaceCompat` (`iif_id`, `oif_id`)";
484 $query[] = 'UPDATE Port SET type = 1322 WHERE type = 16 AND (SELECT objtype_id FROM RackObject WHERE id = object_id) IN (2, 12)';
485 $query = array_merge ($query, reloadDictionary ($batchid));
486 $query[] = "DELETE FROM Config WHERE varname = 'default_port_type'";
487 $query[] = "INSERT INTO Config VALUES ('DEFAULT_PORT_IIF_ID','1','uint','no','no','Default port inner interface ID')";
488 $query[] = "INSERT INTO Config VALUES ('DEFAULT_PORT_OIF_IDS','1=24; 3=1078; 4=1077; 5=1079; 6=1080; 8=1082; 9=1084','string','no','no','Default port outer interface IDs')";
489 $query[] = "INSERT INTO Config VALUES ('IPV4_TREE_RTR_AS_CELL','yes','string','no','no','Show full router info for each network in IPv4 tree view')";
490 $query[] = "UPDATE Chapter SET name = 'PortOuterInterface' WHERE id = 2";
491 // remap refs to duplicate records, which will be discarded (ticket:286)
492 $query[] = 'UPDATE AttributeValue SET uint_value = 147 WHERE uint_value = 1020 AND attr_id = 2';
493 $query[] = 'UPDATE AttributeValue SET uint_value = 377 WHERE uint_value = 1021 AND attr_id = 2';
494 $query[] = 'INSERT INTO AttributeMap (objtype_id, attr_id) VALUES (2, 1), (2, 3), (2, 5)';
495 $query[] = "UPDATE Config SET varvalue = '0.17.5' WHERE varname = 'DB_VERSION'";
496 break;
497 case '0.17.6':
498 $query[] = "INSERT INTO `Chapter` (`id`, `sticky`, `name`) VALUES (28,'no','Voice/video hardware')";
499 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1323,1,NULL)";
500 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1323,2,28)";
501 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1323,3,NULL)";
502 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1323,5,NULL)";
503 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('PROXIMITY_RANGE','0','uint','yes','no','Proximity range (0 is current rack only)')";
504 $query = array_merge ($query, reloadDictionary ($batchid));
505 $query[] = "UPDATE Config SET varvalue = '0.17.6' WHERE varname = 'DB_VERSION'";
506 break;
507 case '0.17.7':
508 $query[] = "UPDATE Config SET varvalue = '0.17.7' WHERE varname = 'DB_VERSION'";
509 break;
510 case '0.17.8':
511 $query = array_merge ($query, reloadDictionary ($batchid));
512 $query[] = "ALTER TABLE TagTree DROP COLUMN valid_realm";
513 $query[] = "UPDATE Config SET varvalue = '0.17.8' WHERE varname = 'DB_VERSION'";
514 break;
515 case '0.17.9':
516 $query[] = "ALTER table Config add `is_userdefined` enum('yes','no') NOT NULL default 'no' AFTER `is_hidden`";
517 $query[] = "
518 CREATE TABLE `UserConfig` (
519 `varname` char(32) NOT NULL,
520 `varvalue` char(255) NOT NULL,
521 `user` char(64) NOT NULL,
522 UNIQUE KEY `user_varname` (`user`,`varname`)
523 ) TYPE=InnoDB";
524 $query[] = "UPDATE Config SET is_userdefined = 'yes' WHERE varname IN
525 (
526 'MASSCOUNT',
527 'MAXSELSIZE',
528 'ROW_SCALE',
529 'PORTS_PER_ROW',
530 'IPV4_ADDRS_PER_PAGE',
531 'DEFAULT_RACK_HEIGHT',
532 'DEFAULT_SLB_VS_PORT',
533 'DEFAULT_SLB_RS_PORT',
534 'DETECT_URLS',
535 'RACK_PRESELECT_THRESHOLD',
536 'DEFAULT_IPV4_RS_INSERVICE',
537 'DEFAULT_OBJECT_TYPE',
538 'SHOW_EXPLICIT_TAGS',
539 'SHOW_IMPLICIT_TAGS',
540 'SHOW_AUTOMATIC_TAGS',
541 'IPV4_AUTO_RELEASE',
542 'SHOW_LAST_TAB',
543 'EXT_IPV4_VIEW',
544 'TREE_THRESHOLD',
545 'ADDNEW_AT_TOP',
546 'IPV4_TREE_SHOW_USAGE',
547 'PREVIEW_TEXT_MAXCHARS',
548 'PREVIEW_TEXT_ROWS',
549 'PREVIEW_TEXT_COLS',
550 'PREVIEW_IMAGE_MAXPXS',
551 'VENDOR_SIEVE',
552 'RACKS_PER_ROW'
553 )";
554 $query[] = "UPDATE Config SET varvalue = '0.17.9' WHERE varname = 'DB_VERSION'";
555 break;
556 case '0.17.10':
557 $query = array_merge ($query, reloadDictionary ($batchid));
558 $query[] = "ALTER TABLE MountOperation ADD KEY (object_id)";
559 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, is_userdefined, description) VALUES ('STATIC_FILTER','yes','string','no','no','yes','Enable Filter Caching');";
560 $query[] = "UPDATE Config SET varvalue = '0.17.10' WHERE varname = 'DB_VERSION'";
561 break;
562 case '0.17.11':
563 $query = array_merge ($query, reloadDictionary ($batchid));
564 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, is_userdefined, description) VALUES ('ENABLE_BULKPORT_FORM','yes','string','no','no','yes','Enable \"Bulk Port\" form');";
565 $query[] = "DELETE AttributeValue FROM AttributeValue JOIN Attribute where AttributeValue.attr_id = Attribute.id AND Attribute.type = 'dict' AND AttributeValue.uint_value = 0";
566 $query[] = "UPDATE Config SET varvalue = '0.17.11' WHERE varname = 'DB_VERSION'";
567 break;
568 case '0.18.0':
569 $query = array_merge ($query, reloadDictionary ($batchid));
570 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, is_userdefined, description) VALUES ('VLANSWITCH_LISTSRC', '', 'string', 'yes', 'no', 'yes', 'List of VLAN running switches')";
571 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, is_userdefined, description) VALUES ('VLANIPV4NET_LISTSRC', '', 'string', 'yes', 'no', 'yes', 'List of VLAN-based IPv4 networks')";
572 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, is_userdefined, description) VALUES ('DEFAULT_VDOM_ID','','uint','yes','no','yes','Default VLAN domain ID')";
573 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, is_userdefined, description) VALUES ('DEFAULT_VST_ID','','uint','yes','no','yes','Default VLAN switch template ID')";
574 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, is_userdefined, description) VALUES ('8021Q_DEPLOY_MINAGE','300','uint','no','no','no','802.1Q deploy minimum age')";
575 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, is_userdefined, description) VALUES ('8021Q_DEPLOY_MAXAGE','3600','uint','no','no','no','802.1Q deploy maximum age')";
576 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, is_userdefined, description) VALUES ('8021Q_DEPLOY_RETRY','10800','uint','no','no','no','802.1Q deploy retry timer')";
577 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, is_userdefined, description) VALUES ('8021Q_WRI_AFTER_CONFT','no','string','no','no','no','802.1Q: save device configuration after deploy')";
578 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, is_userdefined, description) VALUES ('8021Q_INSTANT_DEPLOY','no','string','no','no','yes','802.1Q: instant deploy')";
579 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, is_userdefined, description) VALUES ('IPV4_TREE_SHOW_VLAN','yes','string','no','no','yes','Show VLAN for each network in IPv4 tree')";
580 $query[] = "ALTER TABLE IPv4Network ENGINE=InnoDB";
581 $query[] = "SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0";
582 $query[] = "
583 CREATE TABLE `CachedPAV` (
584 `object_id` int(10) unsigned NOT NULL,
585 `port_name` char(255) NOT NULL,
586 `vlan_id` int(10) unsigned NOT NULL default '0',
587 PRIMARY KEY (`object_id`,`port_name`,`vlan_id`),
588 KEY `vlan_id` (`vlan_id`),
589 CONSTRAINT `CachedPAV-FK-object-port` FOREIGN KEY (`object_id`, `port_name`) REFERENCES `CachedPVM` (`object_id`, `port_name`) ON DELETE CASCADE,
590 CONSTRAINT `CachedPAV-FK-vlan_id` FOREIGN KEY (`vlan_id`) REFERENCES `VLANValidID` (`vlan_id`)
591 ) ENGINE=InnoDB
592 ";
593 $query[] = "
594 CREATE TABLE `CachedPNV` (
595 `object_id` int(10) unsigned NOT NULL,
596 `port_name` char(255) NOT NULL,
597 `vlan_id` int(10) unsigned NOT NULL default '0',
598 PRIMARY KEY (`object_id`,`port_name`,`vlan_id`),
599 UNIQUE KEY `port_id` (`object_id`,`port_name`),
600 CONSTRAINT `CachedPNV-FK-compound` FOREIGN KEY (`object_id`, `port_name`, `vlan_id`) REFERENCES `CachedPAV` (`object_id`, `port_name`, `vlan_id`) ON DELETE CASCADE
601 ) ENGINE=InnoDB
602 ";
603 $query[] = "
604 CREATE TABLE `CachedPVM` (
605 `object_id` int(10) unsigned NOT NULL,
606 `port_name` char(255) NOT NULL,
607 `vlan_mode` enum('access','trunk') NOT NULL default 'access',
608 PRIMARY KEY (`object_id`,`port_name`),
609 CONSTRAINT `CachedPVM-FK-object_id` FOREIGN KEY (`object_id`) REFERENCES `RackObject` (`id`) ON DELETE CASCADE
610 ) ENGINE=InnoDB
611 ";
612 $query[] = "
613 CREATE TABLE `PortAllowedVLAN` (
614 `object_id` int(10) unsigned NOT NULL,
615 `port_name` char(255) NOT NULL,
616 `vlan_id` int(10) unsigned NOT NULL default '0',
617 PRIMARY KEY (`object_id`,`port_name`,`vlan_id`),
618 KEY `vlan_id` (`vlan_id`),
619 CONSTRAINT `PortAllowedVLAN-FK-object-port` FOREIGN KEY (`object_id`, `port_name`) REFERENCES `PortVLANMode` (`object_id`, `port_name`) ON DELETE CASCADE,
620 CONSTRAINT `PortAllowedVLAN-FK-vlan_id` FOREIGN KEY (`vlan_id`) REFERENCES `VLANValidID` (`vlan_id`)
621 ) ENGINE=InnoDB
622 ";
623 $query[] = "
624 CREATE TABLE `PortNativeVLAN` (
625 `object_id` int(10) unsigned NOT NULL,
626 `port_name` char(255) NOT NULL,
627 `vlan_id` int(10) unsigned NOT NULL default '0',
628 PRIMARY KEY (`object_id`,`port_name`,`vlan_id`),
629 UNIQUE KEY `port_id` (`object_id`,`port_name`),
630 CONSTRAINT `PortNativeVLAN-FK-compound` FOREIGN KEY (`object_id`, `port_name`, `vlan_id`) REFERENCES `PortAllowedVLAN` (`object_id`, `port_name`, `vlan_id`) ON DELETE CASCADE
631 ) ENGINE=InnoDB
632 ";
633 $query[] = "
634 CREATE TABLE `PortVLANMode` (
635 `object_id` int(10) unsigned NOT NULL,
636 `port_name` char(255) NOT NULL,
637 `vlan_mode` enum('access','trunk') NOT NULL default 'access',
638 PRIMARY KEY (`object_id`,`port_name`),
639 CONSTRAINT `PortVLANMode-FK-object-port` FOREIGN KEY (`object_id`, `port_name`) REFERENCES `CachedPVM` (`object_id`, `port_name`)
640 ) ENGINE=InnoDB
641 ";
642 $query[] = "
643 CREATE TABLE `VLANDescription` (
644 `domain_id` int(10) unsigned NOT NULL,
645 `vlan_id` int(10) unsigned NOT NULL default '0',
646 `vlan_type` enum('ondemand','compulsory','alien') NOT NULL default 'ondemand',
647 `vlan_descr` char(255) default NULL,
648 PRIMARY KEY (`domain_id`,`vlan_id`),
649 KEY `vlan_id` (`vlan_id`),
650 CONSTRAINT `VLANDescription-FK-domain_id` FOREIGN KEY (`domain_id`) REFERENCES `VLANDomain` (`id`) ON DELETE CASCADE,
651 CONSTRAINT `VLANDescription-FK-vlan_id` FOREIGN KEY (`vlan_id`) REFERENCES `VLANValidID` (`vlan_id`)
652 ) ENGINE=InnoDB
653 ";
654 $query[] = "
655 CREATE TABLE `VLANDomain` (
656 `id` int(10) unsigned NOT NULL auto_increment,
657 `description` char(255) default NULL,
658 PRIMARY KEY (`id`),
659 UNIQUE KEY `description` (`description`)
660 ) ENGINE=InnoDB
661 ";
662 $query[] = "
663 CREATE TABLE `VLANIPv4` (
664 `domain_id` int(10) unsigned NOT NULL,
665 `vlan_id` int(10) unsigned NOT NULL,
666 `ipv4net_id` int(10) unsigned NOT NULL,
667 UNIQUE KEY `network-domain` (`ipv4net_id`,`domain_id`),
668 KEY `VLANIPv4-FK-compound` (`domain_id`,`vlan_id`),
669 CONSTRAINT `VLANIPv4-FK-compound` FOREIGN KEY (`domain_id`, `vlan_id`) REFERENCES `VLANDescription` (`domain_id`, `vlan_id`) ON DELETE CASCADE,
670 CONSTRAINT `VLANIPv4-FK-ipv4net_id` FOREIGN KEY (`ipv4net_id`) REFERENCES `IPv4Network` (`id`) ON DELETE CASCADE
671 ) ENGINE=InnoDB
672 ";
673 $query[] = "
674 CREATE TABLE `VLANSTRule` (
675 `vst_id` int(10) unsigned NOT NULL,
676 `rule_no` int(10) unsigned NOT NULL,
677 `port_pcre` char(255) NOT NULL,
678 `port_role` enum('access','trunk','uplink','downlink','none') NOT NULL default 'none',
679 `wrt_vlans` char(255) default NULL,
680 `description` char(255) default NULL,
681 UNIQUE KEY `vst-rule` (`vst_id`,`rule_no`),
682 CONSTRAINT `VLANSTRule-FK-vst_id` FOREIGN KEY (`vst_id`) REFERENCES `VLANSwitchTemplate` (`id`) ON DELETE CASCADE
683 ) ENGINE=InnoDB
684 ";
685 $query[] = "
686 CREATE TABLE `VLANSwitch` (
687 `object_id` int(10) unsigned NOT NULL,
688 `domain_id` int(10) unsigned NOT NULL,
689 `template_id` int(10) unsigned NOT NULL,
690 `mutex_rev` int(10) unsigned NOT NULL default '0',
691 `out_of_sync` enum('yes','no') NOT NULL default 'yes',
692 `last_errno` int(10) unsigned NOT NULL default '0',
693 `last_change` timestamp NOT NULL default '0000-00-00 00:00:00',
694 `last_push_started` timestamp NOT NULL default '0000-00-00 00:00:00',
695 `last_push_finished` timestamp NOT NULL default '0000-00-00 00:00:00',
696 `last_error_ts` timestamp NOT NULL default '0000-00-00 00:00:00',
697 UNIQUE KEY `object_id` (`object_id`),
698 KEY `domain_id` (`domain_id`),
699 KEY `template_id` (`template_id`),
700 KEY `out_of_sync` (`out_of_sync`),
701 KEY `last_errno` (`last_errno`),
702 CONSTRAINT `VLANSwitch-FK-domain_id` FOREIGN KEY (`domain_id`) REFERENCES `VLANDomain` (`id`),
703 CONSTRAINT `VLANSwitch-FK-object_id` FOREIGN KEY (`object_id`) REFERENCES `RackObject` (`id`),
704 CONSTRAINT `VLANSwitch-FK-template_id` FOREIGN KEY (`template_id`) REFERENCES `VLANSwitchTemplate` (`id`)
705 ) ENGINE=InnoDB
706 ";
707 $query[] = "
708 CREATE TABLE `VLANSwitchTemplate` (
709 `id` int(10) unsigned NOT NULL auto_increment,
710 `max_local_vlans` int(10) unsigned default NULL,
711 `description` char(255) default NULL,
712 PRIMARY KEY (`id`),
713 UNIQUE KEY `description` (`description`)
714 ) ENGINE=InnoDB
715 ";
716 $query[] = "
717 CREATE TABLE `VLANValidID` (
718 `vlan_id` int(10) unsigned NOT NULL default '1',
719 PRIMARY KEY (`vlan_id`)
720 ) ENGINE=InnoDB
721 ";
722 $query[] = "SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS";
723 for ($i = 1; $i <= 4094; $i++)
724 $query[] = "INSERT INTO VLANValidID (vlan_id) VALUES (${i})";
725 $query[] = "UPDATE Config SET varvalue = '0.18.0' WHERE varname = 'DB_VERSION'";
726 break;
727 case '0.18.1':
728 $query = array_merge ($query, reloadDictionary ($batchid));
729 $query[] = "ALTER TABLE Atom ENGINE=InnoDB";
730 $query[] = "ALTER TABLE AttributeMap ENGINE=InnoDB";
731 $query[] = "ALTER TABLE Config ENGINE=InnoDB";
732 $query[] = "ALTER TABLE IPv4Address ENGINE=InnoDB";
733 $query[] = "ALTER TABLE IPv4Allocation ENGINE=InnoDB";
734 $query[] = "ALTER TABLE Molecule ENGINE=InnoDB";
735 $query[] = "ALTER TABLE MountOperation ENGINE=InnoDB";
736 $query[] = "ALTER TABLE PortCompat ENGINE=InnoDB";
737 $query[] = "ALTER TABLE Rack ENGINE=InnoDB";
738 $query[] = "ALTER TABLE RackHistory ENGINE=InnoDB";
739 $query[] = "ALTER TABLE RackObjectHistory ENGINE=InnoDB";
740 $query[] = "ALTER TABLE RackRow ENGINE=InnoDB";
741 $query[] = "ALTER TABLE RackSpace ENGINE=InnoDB";
742 $query[] = "ALTER TABLE Script ENGINE=InnoDB";
743 $query[] = "ALTER TABLE AttributeValue DROP FOREIGN KEY `AttributeValue-FK-object_id`";
744 $query[] = "ALTER TABLE AttributeValue ADD CONSTRAINT `AttributeValue-FK-object_id` FOREIGN KEY (`object_id`) REFERENCES `RackObject` (`id`) ON DELETE CASCADE";
745 $query[] = "ALTER TABLE RackObjectHistory ADD KEY (id)";
746 $query[] = "ALTER TABLE RackObjectHistory ADD CONSTRAINT `RackObjectHistory-FK-object_id` FOREIGN KEY (id) REFERENCES `RackObject` (`id`) ON DELETE CASCADE";
747 $query[] = "ALTER TABLE MountOperation ADD CONSTRAINT `MountOperation-FK-object_id` FOREIGN KEY (object_id) REFERENCES RackObject (id) ON DELETE CASCADE";
748 $query[] = "ALTER TABLE RackSpace ADD CONSTRAINT `RackSpace-FK-object_id` FOREIGN KEY (object_id) REFERENCES RackObject (id) ON DELETE CASCADE";
749 $query[] = "ALTER TABLE Link DROP FOREIGN KEY `Link-FK-a`";
750 $query[] = "ALTER TABLE Link ADD CONSTRAINT `Link-FK-a` FOREIGN KEY (`porta`) REFERENCES `Port` (`id`) ON DELETE CASCADE";
751 $query[] = "ALTER TABLE Link DROP FOREIGN KEY `Link-FK-b`";
752 $query[] = "ALTER TABLE Link ADD CONSTRAINT `Link-FK-b` FOREIGN KEY (`portb`) REFERENCES `Port` (`id`) ON DELETE CASCADE";
753 $query[] = "ALTER TABLE Port DROP FOREIGN KEY `Port-FK-object_id`";
754 $query[] = "ALTER TABLE Port ADD CONSTRAINT `Port-FK-object_id` FOREIGN KEY (`object_id`) REFERENCES `RackObject` (`id`) ON DELETE CASCADE";
755 $query[] = "ALTER TABLE AttributeMap MODIFY `chapter_id` int(10) unsigned default NULL";
756 $query[] = "ALTER TABLE IPv4Address MODIFY `ip` int(10) unsigned NOT NULL default '0'";
757 $query[] = "ALTER TABLE IPv4Address MODIFY `name` char(255) NOT NULL default ''";
758 $query[] = "ALTER TABLE IPv4Allocation MODIFY `object_id` int(10) unsigned NOT NULL default '0'";
759 $query[] = "ALTER TABLE IPv4Allocation MODIFY `ip` int(10) unsigned NOT NULL default '0'";
760 $query[] = "ALTER TABLE IPv4Allocation MODIFY `name` char(255) NOT NULL default ''";
761 $query[] = "ALTER TABLE IPv4NAT MODIFY `object_id` int(10) unsigned NOT NULL default '0'";
762 $query[] = "ALTER TABLE IPv4NAT MODIFY `proto` enum('TCP','UDP') NOT NULL default 'TCP'";
763 $query[] = "ALTER TABLE IPv4NAT MODIFY `localip` int(10) unsigned NOT NULL default '0'";
764 $query[] = "ALTER TABLE IPv4NAT MODIFY `localport` smallint(5) unsigned NOT NULL default '0'";
765 $query[] = "ALTER TABLE IPv4NAT MODIFY `remoteip` int(10) unsigned NOT NULL default '0'";
766 $query[] = "ALTER TABLE IPv4NAT MODIFY `remoteport` smallint(5) unsigned NOT NULL default '0'";
767 $query[] = "ALTER TABLE IPv4Network MODIFY `ip` int(10) unsigned NOT NULL default '0'";
768 $query[] = "ALTER TABLE IPv4Network MODIFY `mask` int(10) unsigned NOT NULL default '0'";
769 $query[] = "ALTER TABLE Link MODIFY `porta` int(10) unsigned NOT NULL default '0'";
770 $query[] = "ALTER TABLE Link MODIFY `portb` int(10) unsigned NOT NULL default '0'";
771 $query[] = "ALTER TABLE MountOperation MODIFY `object_id` int(10) unsigned NOT NULL default '0'";
772 $query[] = "ALTER TABLE MountOperation MODIFY `ctime` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP";
773 $query[] = "ALTER TABLE Port MODIFY `object_id` int(10) unsigned NOT NULL default '0'";
774 $query[] = "ALTER TABLE Port MODIFY `name` char(255) NOT NULL default ''";
775 $query[] = "ALTER TABLE Port MODIFY `type` int(10) unsigned NOT NULL default '0'";
776 $query[] = "ALTER TABLE PortCompat MODIFY `type1` int(10) unsigned NOT NULL default '0'";
777 $query[] = "ALTER TABLE PortCompat MODIFY `type2` int(10) unsigned NOT NULL default '0'";
778 $query[] = "ALTER TABLE RackHistory MODIFY `ctime` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP";
779 $query[] = "ALTER TABLE RackObjectHistory MODIFY `ctime` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP";
780 $query[] = "ALTER TABLE TagStorage MODIFY `tag_id` int(10) unsigned NOT NULL default '0'";
781 $query[] = "ALTER TABLE UserAccount MODIFY `user_name` char(64) NOT NULL default ''";
782 $query[] = "UPDATE Config SET varvalue = '0.18.1' WHERE varname = 'DB_VERSION'";
783 break;
784 case '0.18.2':
785 $query = array_merge ($query, reloadDictionary ($batchid));
786 $query[] = "ALTER TABLE Rack ADD CONSTRAINT `Rack-FK-row_id` FOREIGN KEY (row_id) REFERENCES RackRow (id)";
787 $query[] = "ALTER TABLE RackRow ADD UNIQUE KEY `name` (name)";
788 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, is_userdefined, description) VALUES ('CDP_RUNNERS_LISTSRC', '', 'string', 'yes', 'no', 'no', 'List of devices running CDP')";
789 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, is_userdefined, description) VALUES ('LLDP_RUNNERS_LISTSRC', '', 'string', 'yes', 'no', 'no', 'List of devices running LLDP')";
790 $query[] = "UPDATE Config SET varvalue = '0.18.2' WHERE varname = 'DB_VERSION'";
791 break;
792 case '0.18.3':
793 $query = array_merge ($query, reloadDictionary ($batchid));
794 $query[] = "UPDATE Config SET varname='8021Q_WRI_AFTER_CONFT_LISTSRC', varvalue='false', description='802.1Q: save device configuration after deploy (RackCode)' WHERE varname='8021Q_WRI_AFTER_CONFT'";
795 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, is_userdefined, description) VALUES ('HNDP_RUNNERS_LISTSRC', '', 'string', 'yes', 'no', 'no', 'List of devices running HNDP (RackCode)')";
796 $query[] = "UPDATE Config SET varvalue = '0.18.3' WHERE varname = 'DB_VERSION'";
797 break;
798 case '0.18.4':
799 $query = array_merge ($query, reloadDictionary ($batchid));
800 $query[] = "ALTER TABLE VLANSTRule MODIFY port_role enum('access','trunk','anymode','uplink','downlink','none') NOT NULL default 'none'";
801 $query[] = "UPDATE Config SET varvalue = '0.18.4' WHERE varname = 'DB_VERSION'";
802 break;
803 case '0.18.5':
804 $query = array_merge ($query, reloadDictionary ($batchid));
805 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, is_userdefined, description) VALUES ('SHRINK_TAG_TREE_ON_CLICK','yes','string','no','no','yes','Dynamically hide useless tags in tagtree')";
806 $query[] = "ALTER TABLE `IPv4LB` ADD COLUMN `prio` int(10) unsigned DEFAULT NULL AFTER `vs_id`";
807 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, is_userdefined, description) VALUES ('MAX_UNFILTERED_ENTITIES','0','uint','no','no','yes','Max item count to display on unfiltered result page')";
808 $query[] = "UPDATE Config SET varvalue = '0.18.5' WHERE varname = 'DB_VERSION'";
809 break;
810 case '0.18.6':
811 $query = array_merge ($query, reloadDictionary ($batchid));
812 $query[] = "UPDATE Config SET varvalue = '0.18.6' WHERE varname = 'DB_VERSION'";
813 break;
814 case '0.18.7':
815 $query = array_merge ($query, reloadDictionary ($batchid));
816 $query[] = "UPDATE Config SET varvalue = '0.18.7' WHERE varname = 'DB_VERSION'";
817 break;
818 case '0.19.0':
819 $query = array_merge ($query, reloadDictionary ($batchid));
820 $query[] = 'ALTER TABLE `File` ADD `thumbnail` LONGBLOB NULL AFTER `atime`';
821 $query[] = "
822 CREATE TABLE `IPv6Address` (
823 `ip` binary(16) NOT NULL,
824 `name` char(255) NOT NULL default '',
825 `reserved` enum('yes','no') default NULL,
826 PRIMARY KEY (`ip`)
827 ) ENGINE=InnoDB
828 ";
829 $query[] = "
830 CREATE TABLE `IPv6Allocation` (
831 `object_id` int(10) unsigned NOT NULL default '0',
832 `ip` binary(16) NOT NULL,
833 `name` char(255) NOT NULL default '',
834 `type` enum('regular','shared','virtual','router') default NULL,
835 PRIMARY KEY (`object_id`,`ip`),
836 CONSTRAINT `IPv6Allocation-FK-object_id` FOREIGN KEY (`object_id`) REFERENCES `RackObject` (`id`) ON DELETE CASCADE
837 ) ENGINE=InnoDB
838 ";
839 $query[] = "
840 CREATE TABLE `IPv6Network` (
841 `id` int(10) unsigned NOT NULL auto_increment,
842 `ip` binary(16) NOT NULL,
843 `mask` int(10) unsigned NOT NULL,
844 `last_ip` binary(16) NOT NULL,
845 `name` char(255) default NULL,
846 `comment` text,
847 PRIMARY KEY (`id`),
848 UNIQUE KEY `ip` (`ip`,`mask`)
849 ) ENGINE=InnoDB
850 ";
851 $query[] = "
852 CREATE TABLE `VLANIPv6` (
853 `domain_id` int(10) unsigned NOT NULL,
854 `vlan_id` int(10) unsigned NOT NULL,
855 `ipv6net_id` int(10) unsigned NOT NULL,
856 UNIQUE KEY `network-domain` (`ipv6net_id`,`domain_id`),
857 KEY `VLANIPv6-FK-compound` (`domain_id`,`vlan_id`),
858 CONSTRAINT `VLANIPv6-FK-compound` FOREIGN KEY (`domain_id`, `vlan_id`) REFERENCES `VLANDescription` (`domain_id`, `vlan_id`) ON DELETE CASCADE,
859 CONSTRAINT `VLANIPv6-FK-ipv6net_id` FOREIGN KEY (`ipv6net_id`) REFERENCES `IPv6Network` (`id`) ON DELETE CASCADE
860 ) ENGINE=InnoDB
861 ";
862 $query[] = "
863 CREATE TABLE IF NOT EXISTS `ObjectLog` (
864 `id` int(10) NOT NULL AUTO_INCREMENT,
865 `object_id` int(10) NOT NULL,
866 `user` varchar(64) NOT NULL,
867 `date` datetime NOT NULL,
868 `content` text NOT NULL,
869 PRIMARY KEY (`id`)
870 ) ENGINE=InnoDB
871 ";
872 # Now we have the same structure of ObjectLog table, which objectlog.php
873 # could have left. Subsequent column updates will handle any existing data.
874 $query[] = "ALTER TABLE ObjectLog MODIFY COLUMN `id` int(10) unsigned NOT NULL AUTO_INCREMENT";
875 $query[] = "ALTER TABLE ObjectLog MODIFY COLUMN `object_id` int(10) unsigned NOT NULL";
876 $query[] = "ALTER TABLE ObjectLog MODIFY COLUMN `user` char(64) NOT NULL";
877 $query[] = "ALTER TABLE ObjectLog ADD KEY `object_id` (`object_id`)";
878 $query[] = "ALTER TABLE ObjectLog ADD KEY `date` (`date`)";
879 $query[] = "ALTER TABLE ObjectLog ADD CONSTRAINT `ObjectLog-FK-object_id` FOREIGN KEY (`object_id`) REFERENCES `RackObject` (`id`) ON DELETE CASCADE";
880 # Now it's the way 0.19.0 is expecting it to be.
881 $query[] = "
882 CREATE TABLE `ObjectParentCompat` (
883 `parent_objtype_id` int(10) unsigned NOT NULL,
884 `child_objtype_id` int(10) unsigned NOT NULL,
885 UNIQUE KEY `parent_child` (`parent_objtype_id`,`child_objtype_id`)
886 ) ENGINE=InnoDB
887 ";
888 $query[] = "
889 CREATE TABLE `EntityLink` (
890 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
891 `parent_entity_type` enum('ipv4net','ipv4rspool','ipv4vs','ipv6net','object','rack','user') NOT NULL,
892 `parent_entity_id` int(10) unsigned NOT NULL,
893 `child_entity_type` enum('file','object') NOT NULL,
894 `child_entity_id` int(10) unsigned NOT NULL,
895 PRIMARY KEY (`id`),
896 UNIQUE KEY `EntityLink-unique` (`parent_entity_type`,`parent_entity_id`,`child_entity_type`,`child_entity_id`)
897 ) ENGINE=InnoDB
898 ";
899 $query[] = "ALTER TABLE `TagStorage` CHANGE COLUMN `entity_realm` `entity_realm` ENUM('file','ipv4net','ipv4vs','ipv4rspool','object','rack','user','ipv6net') NOT NULL DEFAULT 'object' FIRST";
900 $query[] = "ALTER TABLE `FileLink` CHANGE COLUMN `entity_type` `entity_type` ENUM('ipv4net','ipv4rspool','ipv4vs','object','rack','user','ipv6net') NOT NULL DEFAULT 'object' AFTER `file_id`";
901 $query[] = 'ALTER TABLE Link ADD COLUMN cable char(64) NULL AFTER portb';
902 $query[] = 'ALTER TABLE RackSpace ADD CONSTRAINT `RackSpace-FK-rack_id` FOREIGN KEY (rack_id) REFERENCES Rack (id)';
903 $query[] = "ALTER TABLE `IPv4Allocation` ADD CONSTRAINT `IPv4Allocation-FK-object_id` FOREIGN KEY (`object_id`) REFERENCES `RackObject` (`id`) ON DELETE CASCADE";
904 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('SYNCDOMAIN_MAX_PROCESSES','0','uint','yes','no', 'How many worker proceses syncdomain cron script should create')";
905 $query[] = "ALTER TABLE `VLANSwitchTemplate` ADD COLUMN `mutex_rev` int(10) NOT NULL AFTER `id`";
906 $query[] = "ALTER TABLE `VLANSwitchTemplate` ADD COLUMN `saved_by` char(64) NOT NULL AFTER `description`";
907 $query[] = "INSERT INTO `Attribute` (`id`, `type`, `name`) VALUES (26,'dict','Hypervisor')";
908 $query[] = "INSERT INTO `Chapter` (`id`, `sticky`, `name`) VALUES (29,'no','Yes/No')";
909 $query[] = "INSERT INTO `Chapter` (`id`, `sticky`, `name`) VALUES (30,'no','network chassis models')";
910 $query[] = "INSERT INTO `Chapter` (`id`, `sticky`, `name`) VALUES (31,'no','server chassis models')";
911 $query[] = "INSERT INTO `Chapter` (`id`, `sticky`, `name`) VALUES (32,'no','virtual switch models')";
912 $query[] = "INSERT INTO `Chapter` (`id`, `sticky`, `name`) VALUES (33,'no','virtual switch OS type')";
913 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (4,26,29)";
914 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1502,1,NULL)";
915 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1502,2,31)";
916 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1502,3,NULL)";
917 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1502,14,NULL)";
918 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1502,20,NULL)";
919 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1502,21,NULL)";
920 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1502,22,NULL)";
921 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1503,1,NULL)";
922 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1503,2,30)";
923 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1503,3,NULL)";
924 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1503,4,14)";
925 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1503,5,NULL)";
926 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1503,14,NULL)";
927 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1503,16,NULL)";
928 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1503,17,NULL)";
929 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1503,18,NULL)";
930 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1503,20,NULL)";
931 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1503,21,NULL)";
932 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1503,22,NULL)";
933 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1503,24,NULL)";
934 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1504,3,NULL)";
935 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1504,4,13)";
936 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1504,14,NULL)";
937 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1504,24,NULL)";
938 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1505,14,NULL)";
939 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1506,14,NULL)";
940 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1506,17,NULL)";
941 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1506,18,NULL)";
942 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1507,1,NULL)";
943 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1507,2,32)";
944 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1507,3,NULL)";
945 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1507,4,33)";
946 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1507,5,NULL)";
947 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1507,14,NULL)";
948 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1507,20,NULL)";
949 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1507,21,NULL)";
950 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1507,22,NULL)";
951 $query[] = "INSERT INTO `ObjectParentCompat` (`parent_objtype_id`, `child_objtype_id`) VALUES (3,13)";
952 $query[] = "INSERT INTO `ObjectParentCompat` (`parent_objtype_id`, `child_objtype_id`) VALUES (4,1504)";
953 $query[] = "INSERT INTO `ObjectParentCompat` (`parent_objtype_id`, `child_objtype_id`) VALUES (4,1507)";
954 $query[] = "INSERT INTO `ObjectParentCompat` (`parent_objtype_id`, `child_objtype_id`) VALUES (1502,4)";
955 $query[] = "INSERT INTO `ObjectParentCompat` (`parent_objtype_id`, `child_objtype_id`) VALUES (1503,8)";
956 $query[] = "INSERT INTO `ObjectParentCompat` (`parent_objtype_id`, `child_objtype_id`) VALUES (1505,4)";
957 $query[] = "INSERT INTO `ObjectParentCompat` (`parent_objtype_id`, `child_objtype_id`) VALUES (1505,1504)";
958 $query[] = "INSERT INTO `ObjectParentCompat` (`parent_objtype_id`, `child_objtype_id`) VALUES (1505,1506)";
959 $query[] = "INSERT INTO `ObjectParentCompat` (`parent_objtype_id`, `child_objtype_id`) VALUES (1505,1507)";
960 $query[] = "INSERT INTO `ObjectParentCompat` (`parent_objtype_id`, `child_objtype_id`) VALUES (1506,1504)";
961 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, is_userdefined, description) VALUES ('PORT_EXCLUSION_LISTSRC','{\$typeid_3} or {\$typeid_10} or {\$typeid_11} or {\$typeid_1505} or {\$typeid_1506}','string','yes','no','no','List source: objects without ports')";
962 $query[] = "UPDATE Config SET varvalue = CONCAT(varvalue, ' or {\$typeid_1502} or {\$typeid_1503} or {\$typeid_1504} or {\$typeid_1507}') WHERE varname = 'IPV4OBJ_LISTSRC'";
963 $query[] = "UPDATE Config SET varvalue = '8' WHERE varname = 'MASSCOUNT'";
964 $query[] = "UPDATE RackObject SET label = NULL WHERE label = ''";
965 // Move barcode data so the column can be dropped
966 $result = $dbxlink->query ('SELECT id, objtype_id, barcode FROM RackObject WHERE barcode IS NOT NULL');
967 $rows = $result->fetchAll (PDO::FETCH_ASSOC);
968 unset ($result);
969 foreach ($rows as $row)
970 {
971 // Determine if this object type has the 'OEM S/N 1' attribute associated with it, and if it's set
972 $sn_query = "SELECT (SELECT COUNT(*) FROM AttributeMap WHERE objtype_id=${row['objtype_id']} AND attr_id=1) AS AM_count, ";
973 $sn_query .= "(SELECT COUNT(*) FROM AttributeValue WHERE object_id=${row['id']} AND attr_id=1) AS AV_count";
974 $sn_result = $dbxlink->query ($sn_query);
975 $sn_row = $sn_result->fetch (PDO::FETCH_ASSOC);
976 if ($sn_row['AM_count'] == 1 && $sn_row['AV_count'] == 0)
977 {
978 // 'OEM S/N 1' attribute is mapped to this object type, but it is not set. Good!
979 // Copy the barcode value to the attribute.
980 $query[] = "INSERT INTO AttributeValue (`object_id`, `attr_id`, `string_value`) VALUES (${row['id']}, 1, '${row['barcode']}')";
981 }
982 else
983 {
984 // Some other set of circumstances. Not as good!
985 // Copy the barcode value to a new ObjectLog record.
986 $query[] = "INSERT INTO ObjectLog (`object_id`, `user`, `date`, `content`) VALUES (${row['id']}, '${_SERVER['PHP_AUTH_USER']}', NOW(), 'Upgrade to 0.19 dropped the barcode column. Value was: ${row['barcode']}')";
987 }
988 unset ($sn_query, $sn_result, $sn_row);
989 }
990 $query[] = 'ALTER TABLE RackObject DROP COLUMN `barcode`';
991 $query[] = 'ALTER TABLE RackObjectHistory DROP COLUMN `barcode`';
992 $query[] = 'ALTER TABLE `VLANSwitchTemplate` DROP COLUMN `max_local_vlans`';
993 $query[] = "UPDATE Config SET varvalue = '0.19.0' WHERE varname = 'DB_VERSION'";
994 break;
995 case '0.19.1':
996 $query = array_merge ($query, reloadDictionary ($batchid));
997 $query[] = "ALTER TABLE `Config` CHANGE COLUMN `varvalue` `varvalue` text NOT NULL";
998 $query[] = "ALTER TABLE `UserConfig` CHANGE COLUMN `varvalue` `varvalue` text NOT NULL";
999 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, is_userdefined, description) VALUES ('FILTER_RACKLIST_BY_TAGS','yes','string','yes','no','yes','Rackspace: show only racks matching the current object\'s tags')";
1000 $result = $dbxlink->query ("SHOW TABLES LIKE 'Objectlog'");
1001 $rows = $result->fetchAll (PDO::FETCH_ASSOC);
1002 unset ($result);
1003 if (count ($rows))
1004 {
1005 # Now the ObjectLog merge... again, because the original table is named
1006 # "Objectlog". The job is to merge contents of Objectlog and ObjectLog
1007 # into the latter.
1008 $query[] = "INSERT INTO ObjectLog (object_id, user, date, content) SELECT object_id, user, date, content FROM Objectlog WHERE object_id IN(SELECT id FROM RackObject)";
1009 $query[] = "DELETE FROM Objectlog WHERE object_id IN(SELECT id FROM RackObject)";
1010 # Don't delete the old table, if the merge wasn't exhaustive.
1011 $result = $dbxlink->query ('SELECT COUNT(*) AS c FROM Objectlog WHERE object_id NOT IN(SELECT id FROM RackObject)');
1012 $row = $result->fetch (PDO::FETCH_ASSOC);
1013 unset ($result);
1014 if ($row['c'] == 0)
1015 $query[] = 'DROP TABLE Objectlog';
1016 else
1017 $query[] = 'ALTER TABLE Objectlog RENAME TO Objectlog_old_unmerged';
1018 }
1019 $query[] = "UPDATE Config SET varvalue = '0.19.1' WHERE varname = 'DB_VERSION'";
1020 break;
1021 case '0.19.2':
1022 $query = array_merge ($query, reloadDictionary ($batchid));
1023 $query[] = "ALTER TABLE IPv4Allocation ADD KEY `ip` (`ip`)";
1024 $query[] = "ALTER TABLE IPv6Allocation ADD KEY `ip` (`ip`)";
1025 $query[] = "ALTER TABLE IPv4VS ADD KEY `vip` (`vip`)";
1026 $query[] = "ALTER TABLE IPv4RS ADD KEY `rsip` (`rsip`)";
1027 $query[] = "INSERT INTO `Chapter` (`id`, `sticky`, `name`) VALUES (34,'no','power supply chassis models')";
1028 $query[] = "INSERT INTO `Chapter` (`id`, `sticky`, `name`) VALUES (35,'no','power supply models')";
1029 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1397,1,NULL)";
1030 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1397,2,34)";
1031 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1397,14,NULL)";
1032 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1397,21,NULL)";
1033 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1397,22,NULL)";
1034 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1398,1,NULL)";
1035 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1398,2,35)";
1036 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1398,14,NULL)";
1037 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1398,21,NULL)";
1038 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1398,22,NULL)";
1039 $query[] = "INSERT INTO `ObjectParentCompat` (`parent_objtype_id`, `child_objtype_id`) VALUES (1397,1398)";
1040 $query[] = "INSERT INTO `PortCompat` (`type1`, `type2`) VALUES (1399,1399)";
1041 $query[] = "INSERT INTO `PortInterfaceCompat` (`iif_id`, `oif_id`) VALUES (1,1399)";
1042 $query[] = "UPDATE Config SET varvalue = CONCAT(varvalue, ' or {\$typeid_1397}') WHERE varname = 'IPV4OBJ_LISTSRC'";
1043 $query[] = "ALTER TABLE AttributeValue ADD KEY `attr_id-uint_value` (`attr_id`,`uint_value`)";
1044 $query[] = "ALTER TABLE AttributeValue ADD KEY `attr_id-string_value` (`attr_id`,`string_value`(12))";
1045 $query[] = "UPDATE Config SET varvalue = '0.19.2' WHERE varname = 'DB_VERSION'";
1046 break;
1047 case '0.19.3':
1048 $query = array_merge ($query, reloadDictionary ($batchid));
1049 $query[] = "DELETE FROM RackSpace WHERE object_id IS NULL AND state = 'T'";
1050 $query[] = "UPDATE Config SET varvalue = '0.19.3' WHERE varname = 'DB_VERSION'";
1051 break;
1052 case '0.20.0':
1053 $query = array_merge ($query, reloadDictionary ($batchid));
1054 $query[] = "
1055 CREATE TABLE `PortLog` (
1056 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
1057 `port_id` int(10) unsigned NOT NULL,
1058 `user` char(64) NOT NULL,
1059 `date` datetime NOT NULL,
1060 `content` text NOT NULL,
1061 PRIMARY KEY (`id`),
1062 KEY `port_id-date` (`port_id`,`date`),
1063 CONSTRAINT `PortLog_ibfk_1` FOREIGN KEY (`port_id`) REFERENCES `Port` (`id`) ON DELETE CASCADE
1064 ) ENGINE=InnoDB;
1065 ";
1066 for ($i = 1424; $i <= 1466; $i++) # CX, then 42 ER channels
1067 $query[] = "INSERT INTO `PortCompat` (`type1`, `type2`) VALUES (${i},${i})";
1068 # Dismiss some overly-specific OIF types in favour of more generic counterparts.
1069 $squeeze = array
1070 (
1071 1202 => array # 1000Base-SX
1072 (
1073 25, # 1000Base-SX (SC)
1074 26, # 1000Base-SX (LC)
1075 ),
1076 1204 => array # 1000Base-LX
1077 (
1078 27, # 1000Base-LX (SC)
1079 28, # 1000Base-LX (LC)
1080 ),
1081 1196 => array # 100Base-SX
1082 (
1083 22, # 100Base-SX (SC)
1084 23, # 100Base-SX (LC)
1085 ),
1086 1195 => array # 100Base-FX
1087 (
1088 20, # 100Base-FX (SC)
1089 21, # 100Base-FX (LC)
1090 1083, # 100Base-FX (MT-RJ)
1091 ),
1092 );
1093 foreach ($squeeze as $stays => $leaves)
1094 {
1095 $csv = implode (', ', $leaves);
1096 $query[] = "DELETE FROM PortCompat WHERE type1 IN(${csv}) OR type2 IN(${csv})";
1097 $query[] = "INSERT IGNORE INTO PortInterfaceCompat (iif_id, oif_id) SELECT iif_id, ${stays} FROM Port WHERE type IN (${csv})";
1098 $query[] = "UPDATE Port SET type = ${stays} WHERE type IN(${csv})";
1099 $query[] = "DELETE FROM PortInterfaceCompat WHERE oif_id IN(${csv})";
1100 }
1101 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, is_userdefined, description) VALUES ('SSH_OBJS_LISTSRC','none','string','yes','no','yes','Rackcode filter for SSH-managed objects')";
1102 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, is_userdefined, description) VALUES ('TELNET_OBJS_LISTSRC','none','string','yes','no','yes','Rackcode filter for telnet-managed objects')";
1103 $query[] = "UPDATE Config SET varvalue = '0.20.0' WHERE varname = 'DB_VERSION'";
1104 break;
1105 default:
1106 showError ("executeUpgradeBatch () failed, because batch '${batchid}' isn't defined", __FUNCTION__);
1107 die;
1108 break;
1109 }
1110 $failures = array();
1111 echo "<tr><th>Executing batch '${batchid}'</th><td>";
1112 foreach ($query as $q)
1113 {
1114 $result = $dbxlink->query ($q);
1115 if ($result == NULL)
1116 {
1117 $errorInfo = $dbxlink->errorInfo();
1118 $failures[] = array ($q, $errorInfo[2]);
1119 }
1120 }
1121 if (!count ($failures))
1122 echo "<strong><font color=green>done</font></strong>";
1123 else
1124 {
1125 echo "<strong><font color=red>The following queries failed:</font></strong><br><pre>";
1126 foreach ($failures as $f)
1127 {
1128 list ($q, $i) = $f;
1129 echo "${q} -- ${i}\n";
1130 }
1131 echo "</pre>";
1132 }
1133 echo '</td></tr>';
1134 }
1135
1136 function authenticate_admin ($username, $password)
1137 {
1138 global $dbxlink;
1139 $prepared = $dbxlink->prepare ('SELECT COUNT(*) FROM UserAccount WHERE user_id=1 AND user_name=? AND user_password_hash=?');
1140 if (!$prepared->execute (array ($username, sha1 ($password))))
1141 die ('SQL query failed in ' . __FUNCTION__);
1142 $rows = $prepared->fetchAll (PDO::FETCH_NUM);
1143 return $rows[0][0] == 1;
1144 }
1145
1146 // Database version detector. Should behave corretly on any
1147 // working dataset a user might have.
1148 function getDatabaseVersion ()
1149 {
1150 global $dbxlink;
1151 $prepared = $dbxlink->prepare ('SELECT varvalue FROM Config WHERE varname = "DB_VERSION" and vartype = "string"');
1152 if (! $prepared->execute())
1153 {
1154 $errorInfo = $dbxlink->errorInfo();
1155 die (__FUNCTION__ . ': SQL query failed with error ' . $errorInfo[2]);
1156 }
1157 $rows = $prepared->fetchAll (PDO::FETCH_NUM);
1158 unset ($result);
1159 if (count ($rows) != 1 || !strlen ($rows[0][0]))
1160 die (__FUNCTION__ . ': Cannot guess database version. Config table is present, but DB_VERSION is missing or invalid. Giving up.');
1161 $ret = $rows[0][0];
1162 return $ret;
1163 }
1164
1165 function showError ($info = '', $location = 'N/A')
1166 {
1167 if (preg_match ('/\.php$/', $location))
1168 $location = basename ($location);
1169 elseif ($location != 'N/A')
1170 $location = $location . '()';
1171 echo "<div class=msg_error>An error has occured in [${location}]. ";
1172 if (!strlen ($info))
1173 echo 'No additional information is available.';
1174 else
1175 echo "Additional information:<br><p>\n<pre>\n${info}\n</pre></p>";
1176 echo "Go back or try starting from <a href='index.php'>index page</a>.<br></div>\n";
1177 }
1178
1179 function renderUpgraderHTML()
1180 {
1181 global $found_secret_file;
1182 if (! $found_secret_file)
1183 die ('<center>There is no working RackTables instance here, <a href="?module=installer">install</a>?</center>');
1184
1185 try
1186 {
1187 connectDB();
1188 }
1189 catch (RackTablesError $e)
1190 {
1191 die ("Database connection failed:\n\n" . $e->getMessage());
1192 }
1193
1194 if
1195 (
1196 !isset ($_SERVER['PHP_AUTH_USER']) or
1197 !strlen ($_SERVER['PHP_AUTH_USER']) or
1198 !isset ($_SERVER['PHP_AUTH_PW']) or
1199 !strlen ($_SERVER['PHP_AUTH_PW']) or
1200 !authenticate_admin ($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])
1201 )
1202 {
1203 header ('WWW-Authenticate: Basic realm="RackTables upgrade"');
1204 header ('HTTP/1.0 401 Unauthorized');
1205 showError ('You must be authenticated as an administrator to complete the upgrade.', __FUNCTION__);
1206 die;
1207 }
1208
1209 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1210 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
1211 <head><title>RackTables upgrade script</title>
1212 <style type="text/css">
1213 .tdleft {
1214 text-align: left;
1215 }
1216
1217 .trok {
1218 background-color: #80FF80;
1219 }
1220
1221 .trwarning {
1222 background-color: #FFFF80;
1223 }
1224
1225 .trerror {
1226 background-color: #FF8080;
1227 }
1228 </style>
1229 </head>
1230 <body>
1231 <h1>Platform check status</h1>
1232 <?php
1233
1234 if (!platform_is_ok())
1235 die ('</body></html>');
1236
1237 echo '<h1>Upgrade status</h1>';
1238 $dbver = getDatabaseVersion();
1239 echo '<table border=1 cellpadding=5>';
1240 echo "<tr><th>Current status</th><td>Data version: ${dbver}<br>Code version: " . CODE_VERSION . "</td></tr>\n";
1241
1242 $path = getDBUpgradePath ($dbver, CODE_VERSION);
1243 if ($path === NULL)
1244 {
1245 echo "<tr><th>Upgrade path</th><td><font color=red>not found</font></td></tr>\n";
1246 echo "<tr><th>Summary</th><td>Check README for more information. RackTables releases prior to 0.16.4 ";
1247 echo "must be upgraded to 0.16.4 first.</td></tr>\n";
1248 }
1249 else
1250 {
1251 if (!count ($path))
1252 echo "<tr><th>Summary</th><td>Come back later.</td></tr>\n";
1253 else
1254 {
1255 echo "<tr><th>Upgrade path</th><td>${dbver} &rarr; " . implode (' &rarr; ', $path) . "</td></tr>\n";
1256 foreach ($path as $batchid)
1257 {
1258 executeUpgradeBatch ($batchid);
1259 if (isset ($relnotes[$batchid]))
1260 echo "<tr><th>Release notes for ${batchid}</th><td><pre>" . $relnotes[$batchid] . "</pre></td></tr>\n";
1261 }
1262 echo "<tr><th>Summary</th><td>Upgrade complete, it is Ok to <a href='index.php'>enter</a> the system.</td></tr>\n";
1263 }
1264 }
1265 echo '</table>';
1266 echo '</body></html>';
1267 }
1268
1269 ?>