source: trunk/Common/Setup/Updates.php@ 623

Last change on this file since 623 was 623, checked in by chronos, 11 years ago
  • Přidáno: Nový formulářový typ obrázek(Image).
  • Opraveno: Chyba v číslování aktualizací.
  • Opraveno: Chybné zobrazení dolního postraního kanálu ve frekvenčním plánu.
  • Přidáno: Nové ikony akcí.
File size: 28.8 KB
Line 
1<?php
2
3function UpdateTo493($Manager)
4{
5 $Manager->Execute("ALTER TABLE `UserOnline` CHANGE `User` `User` INT( 11 ) NULL DEFAULT NULL COMMENT 'User.Id'");
6}
7
8function UpdateTo494($Manager)
9{
10 $Manager->Execute("ALTER TABLE `FinanceOperation` DROP FOREIGN KEY `FinanceOperation_ibfk_2` ;\n".
11 "ALTER TABLE `FinanceOperation` CHANGE `Bill` `File` INT( 11 ) NULL DEFAULT NULL;\n".
12 "ALTER TABLE `FinanceOperation` ADD FOREIGN KEY ( `File` ) REFERENCES `File` (`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
13}
14
15function UpdateTo495($Manager)
16{
17 $Manager->Execute("INSERT INTO `MapPosition` (SELECT NULL AS `Id`, `Name`, `MapPositionX` AS `Latitude`, `MapPositionY` AS `Longitude` FROM `Subject`)");
18 $Manager->Execute("ALTER TABLE `Subject` ADD `MapPosition` INT NULL AFTER `PayVAT`");
19 $Manager->Execute("UPDATE `Subject` SET `MapPosition` = (SELECT `MapPosition`.`Id` FROM `MapPosition` WHERE `MapPosition`.`Name` = `Subject`.`Name` LIMIT 1)");
20 $Manager->Execute("ALTER TABLE `Subject` DROP `MapPositionX`, DROP `MapPositionY`;");
21 $Manager->Execute("ALTER TABLE `Subject` ADD INDEX ( `MapPosition` ) ");
22 $Manager->Execute("ALTER TABLE `Subject` ADD FOREIGN KEY ( `MapPosition` ) REFERENCES `MapPosition` (".
23 "`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
24}
25
26function UpdateTo497($Manager)
27{
28 $Manager->Execute("ALTER TABLE `FinanceCharge` ADD `Id` INT NOT NULL AUTO_INCREMENT FIRST , ADD PRIMARY KEY ( `Id` ) ");
29 $Manager->Execute("ALTER TABLE `FinanceCharge` ADD `ReplaceId` INT NULL ,ADD INDEX ( `ReplaceId` ) ");
30 $Manager->Execute("DELETE FROM `FinanceCharge` WHERE `FinanceCharge`.`Period` = 1");
31 $Manager->Execute("ALTER TABLE `FinanceCharge` DROP `Period`");
32 $Manager->Execute("ALTER TABLE `FinanceCharge` ADD `Action` ENUM( 'add', 'modify', 'remove' ) NULL AFTER `TopTariffPrice` ");
33 $Manager->Execute("ALTER TABLE `FinanceCharge` ADD FOREIGN KEY ( `ReplaceId` ) REFERENCES `FinanceCharge` (".
34 "`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
35 $Manager->Execute("ALTER TABLE `FinanceCharge` ADD INDEX ( `Action` )");
36 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
37 "VALUES (NULL , 'Parametry účtování', '2', 'FinanceCharge', '');");
38 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
39 "VALUES (NULL , 'Úseky sítě', '2', 'NetworkSegment', '');");
40 $Manager->Execute("ALTER TABLE `ServiceCustomerRel` ADD `Action` ENUM( 'add', 'modify', 'remove' ) NULL , ".
41 "ADD `ReplaceId` INT NULL");
42 $Manager->Execute("DELETE FROM `ServiceCustomerRel` WHERE `Period`=1");
43 $Manager->Execute("ALTER TABLE `ServiceCustomerRel` DROP `Period`");
44 $Manager->Execute("ALTER TABLE `ServiceCustomerRel` ADD INDEX ( `Action` )");
45 $Manager->Execute("ALTER TABLE `ServiceCustomerRel` ADD INDEX ( `ReplaceId` ) ");
46 $Manager->Execute("ALTER TABLE `ServiceCustomerRel` ADD FOREIGN KEY ( `ReplaceId` ) REFERENCES `ServiceCustomerRel` (".
47 "`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
48 $Manager->Execute("ALTER TABLE `Service` ADD `Action` ENUM( 'add', 'modify', 'remove' ) NULL AFTER `CustomerCount`");
49 $Manager->Execute("ALTER TABLE `Service` ADD INDEX ( `Action` )");
50 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
51 "VALUES (NULL , 'Placení zákazníků', '2', 'MemberPayment', '');");
52}
53
54function UpdateTo498($Manager)
55{
56 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
57 "VALUES (NULL , 'Sítové služby', '1', 'NetworkConfiguration', '');");
58 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
59 "VALUES (NULL , 'Fronta e-mailů', '23', 'EmailQueue', '');");
60 $Manager->Execute("CREATE TABLE IF NOT EXISTS `FinanceVAT` (
61 `Id` int(11) NOT NULL AUTO_INCREMENT,
62 `Name` varchar(255) NOT NULL,
63 `ValidFrom` date NOT NULL,
64 `Value` int(11) NOT NULL,
65 PRIMARY KEY (`Id`)
66) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
67INSERT INTO `FinanceVAT` (`Id`, `Name`, `ValidFrom`, `Value`) VALUES
68(1, 'DPH snížená sazba', '2013-01-01', 15),
69(2, 'DPH běžná sazba', '2013-01-01', 21);");
70 $Manager->Execute("ALTER TABLE `Service` ADD `VAT` INT NOT NULL AFTER `Price`");
71 $Manager->Execute("ALTER TABLE `Service` ADD INDEX ( `VAT` ) ");
72 $Manager->Execute("UPDATE `Service` SET `VAT` = 2;");
73 $Manager->Execute("ALTER TABLE `Service` ADD FOREIGN KEY ( `VAT` ) REFERENCES `FinanceVAT` (".
74 "`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
75 $Manager->Execute("ALTER TABLE `FinanceInvoice` ADD `Cash` INT NOT NULL DEFAULT '0'");
76}
77
78function UpdateTo499($Manager)
79{
80 $Manager->Execute("CREATE TABLE IF NOT EXISTS `Currency` (
81 `Id` int(11) NOT NULL AUTO_INCREMENT,
82 `Code` varchar(3) NOT NULL,
83 `Name` varchar(255) NOT NULL,
84 `Symbol` varchar(255) NOT NULL,
85 PRIMARY KEY (`Id`)
86) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
87
88INSERT INTO `Currency` (`Id`, `Code`, `Name`, `Symbol`) VALUES
89(1, 'CZK', 'Česká koruna', 'Kč'),
90(2, 'EUR', 'Euro', '€'),
91(3, 'USD', 'Americký dolar', '$'),
92(4, 'CNY', 'Čínský jüan', '¥');");
93 $Manager->Execute("CREATE TABLE IF NOT EXISTS `FinanceBankImport` (
94 `Id` int(11) NOT NULL AUTO_INCREMENT,
95 `BankAccount` int(11) NOT NULL,
96 `Time` date NOT NULL,
97 `Identification` varchar(255) NOT NULL,
98 `AccountNumber` varchar(255) NOT NULL,
99 `VariableSymbol` varchar(255) NOT NULL,
100 `ConstantSymbol` varchar(255) NOT NULL,
101 `SpecificSymbol` varchar(255) NOT NULL,
102 `Value` decimal(10,0) NOT NULL,
103 `Currency` int(11) NOT NULL,
104 `Description` varchar(255) NOT NULL,
105 `OffsetAccountName` varchar(255) NOT NULL,
106 `FinanceOperation` int(11) DEFAULT NULL,
107 PRIMARY KEY (`Id`),
108 KEY `FinanceOperation` (`FinanceOperation`),
109 KEY `Currency` (`Currency`),
110 KEY `BankAccount` (`BankAccount`)
111) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
112
113ALTER TABLE `FinanceBankImport`
114 ADD CONSTRAINT `FinanceBankImport_ibfk_3` FOREIGN KEY (`FinanceOperation`) REFERENCES `FinanceOperation` (`Id`),
115 ADD CONSTRAINT `FinanceBankImport_ibfk_1` FOREIGN KEY (`BankAccount`) REFERENCES `FinanceBankAccount` (`Id`),
116 ADD CONSTRAINT `FinanceBankImport_ibfk_2` FOREIGN KEY (`Currency`) REFERENCES `Currency` (`Id`);");
117 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`)".
118 "VALUES (NULL , 'Měny', '2', 'Currency', '');");
119 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
120 "VALUES (NULL , 'Import z účtu', '2', 'FinanceBankImport', '');");
121}
122
123function UpdateTo500($Manager)
124{
125 $Manager->Execute("CREATE TABLE IF NOT EXISTS `FinanceBank` (
126 `Id` int(11) NOT NULL AUTO_INCREMENT,
127 `Name` varchar(255) NOT NULL,
128 `Code` varchar(4) NOT NULL,
129 `BIC` varchar(255) NOT NULL,
130 `Country` int(11) NOT NULL,
131 PRIMARY KEY (`Id`),
132 KEY `Country` (`Country`)
133) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
134 $Manager->Execute("ALTER TABLE `FinanceBank`
135 ADD CONSTRAINT `FinanceBank_ibfk_1` FOREIGN KEY (`Country`) REFERENCES `Country` (`Id`);");
136 $Manager->Execute("ALTER TABLE `FinanceBankAccount` ADD `Bank` INT NOT NULL AFTER `Number` ,".
137 " ADD INDEX ( `Bank` )");
138 $Manager->Execute("INSERT INTO `FinanceBank` (`Id`, `Name`, `Code`, `BIC`, `Country`) VALUES
139 (1, 'Neznámá banka', '', '', 1);");
140 $Manager->Execute("UPDATE `FinanceBankAccount` SET `Bank` = 1 WHERE `Bank` = 0");
141 $Manager->Execute("ALTER TABLE `FinanceBankAccount` ADD FOREIGN KEY ( `Bank` ) REFERENCES `FinanceBank` (".
142 "`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
143 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
144 "VALUES (NULL , 'Banky', '2', 'FinanceBank', '');");
145}
146
147function UpdateTo502($Manager)
148{
149 $Manager->Execute("ALTER TABLE `FinanceBankAccount` ADD `LoginName` VARCHAR( 255 ) NOT NULL ");
150 $Manager->Execute("ALTER TABLE `FinanceBankAccount` ADD `LoginPassword` VARCHAR( 255 ) NOT NULL");
151 $Manager->Execute("ALTER TABLE `FinanceBankAccount` ADD `Currency` INT NOT NULL AFTER `Use` ,".
152 "ADD INDEX ( `Currency` ) ");
153 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
154 "VALUES (NULL , 'Banka', '2', '', '');");
155 $Id = $Manager->Database->insert_id;
156 $Manager->Execute("UPDATE `ISMenuItem` SET `Parent` = '".$Id."' WHERE `ISMenuItem`.`Id` ='Bankovní účty'; ".
157 "UPDATE `ISMenuItem` SET `Parent` = '".$Id."' WHERE `ISMenuItem`.`Id` ='Import z účtu';".
158 "UPDATE `ISMenuItem` SET `Parent` = '".$Id."' WHERE `ISMenuItem`.`Name` ='Banky';");
159}
160
161function UpdateTo505($Manager)
162{
163 $Manager->Execute("UPDATE `ISMenuItem` SET `Name` = 'Služby', `Table` = 'Service' WHERE `ISMenuItem`.`Name` ='Tarify';");
164 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
165 "VALUES (NULL , 'Kategorie služeb', '2', 'ServiceCategory', '');");
166 $Manager->Execute("CREATE TABLE IF NOT EXISTS `NetworkShareItem` (
167 `Id` int(11) NOT NULL AUTO_INCREMENT,
168 `Name` varchar(255) NOT NULL DEFAULT '',
169 `Parent` int(11) NOT NULL DEFAULT '0',
170 `Host` int(11) NOT NULL DEFAULT '0',
171 `Size` bigint(20) NOT NULL DEFAULT '0',
172 `Ext` varchar(64) NOT NULL DEFAULT '',
173 `Date` date NOT NULL DEFAULT '0000-00-00',
174 `Type` int(11) NOT NULL DEFAULT '0',
175 PRIMARY KEY (`Id`),
176 KEY `Parent` (`Parent`),
177 KEY `Search` (`Name`,`Size`),
178 KEY `Name` (`Name`)
179) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
180 $Manager->Execute("CREATE TABLE IF NOT EXISTS `NetworkShareError` (
181 `Id` int(11) NOT NULL AUTO_INCREMENT,
182 `Host` varchar(16) NOT NULL DEFAULT '',
183 `Message` varchar(255) NOT NULL DEFAULT '',
184 PRIMARY KEY (`Id`)
185) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
186}
187
188function UpdateTo507($Manager)
189{
190 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
191 "VALUES (NULL , 'Aktuality', NULL, '', '');");
192 $Id = $Manager->Database->insert_id;
193 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
194 "VALUES (NULL , 'Aktuality', '".$Id."', 'News', '');");
195 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
196 "VALUES (NULL , 'Kategorie aktualit', '".$Id."', 'NewsCategory', '');");
197 $Manager->Execute("INSERT INTO `FileDirectory` (`Id` ,`Name` ,`Parent`".
198 ") VALUES (NULL , 'news', NULL);");
199 $Manager->Execute("ALTER TABLE `File` ADD `Time` DATETIME NOT NULL ");
200 // Convert Hire column to Service item
201 $Manager->Execute("INSERT INTO `ServiceCategory` (
202`Id` ,`Name`) VALUES (NULL , 'Pevný nájem');");
203 $ServiceCategoryHire = $Manager->Database->insert_id;
204 $DbResult = $Manager->Execute("SELECT * FROM Member WHERE Hire>0");
205 while($Member = $DbResult->fetch_assoc())
206 {
207 $Manager->Execute("INSERT INTO `Service` (
208`Id` ,`Name` ,`Category` ,`Price` ,`VAT` ,`CustomerCount` ,`Action` ,`ReplaceId` ,
209`Public` ,`InternetSpeedMin` ,`InternetSpeedMax` ,`UploadAsymmetry` ,`Memory` ,`MemorySwap` ,`Storage` ,`CPUCount`)
210VALUES (
211NULL , 'Nájem', '".$ServiceCategoryHire."', '-".$Member['Hire']."', '2', '', NULL , NULL , '', '', '', '', '', '', '', ''
212);");
213 $ServiceHire = $Manager->Database->insert_id;
214 $Manager->Execute("INSERT INTO `ServiceCustomerRel` (`Service`, `Customer`) VALUES ".
215 "(".$ServiceHire.",".$Member['Id'].")");
216 }
217 $Manager->Execute("ALTER TABLE `Member` DROP `Hire`");
218 // Each device and subnet have to be assigned to payed service to determine service parameters
219 $Manager->Execute("ALTER TABLE `NetworkDevice` ADD `Service` INT NULL AFTER `Location` ,
220ADD INDEX ( `Service` )");
221 $Manager->Execute("ALTER TABLE `NetworkDevice` ADD FOREIGN KEY ( `Service` ) REFERENCES `ServiceCustomerRel` (
222`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
223 $Manager->Execute("UPDATE `NetworkDevice` SET `Service` = (SELECT `Id` FROM `ServiceCustomerRel` WHERE `ServiceCustomerRel`.`Customer` = `NetworkDevice`.`Member` LIMIT 1)");
224 $Manager->Execute("ALTER TABLE `NetworkSubnet` ADD `Service` INT NULL AFTER `Member` ,
225ADD INDEX ( `Service` ) ");
226 $Manager->Execute("ALTER TABLE `NetworkSubnet` ADD FOREIGN KEY ( `Service` ) REFERENCES `ServiceCustomerRel` (
227`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
228 $Manager->Execute("UPDATE `NetworkSubnet` SET `Service` = (SELECT `Id` FROM `ServiceCustomerRel` WHERE `ServiceCustomerRel`.`Customer` = `NetworkSubnet`.`Member` LIMIT 1)");
229}
230
231function UpdateTo515($Manager)
232{
233 $Manager->Execute("ALTER TABLE `PermissionUserAssignment` CHANGE `User` `User` INT( 11 ) NULL");
234}
235
236function UpdateTo517($Manager)
237{
238 $Manager->Execute("ALTER TABLE `Log` ADD `IPAddress` VARCHAR( 16 ) NOT NULL");
239}
240
241function UpdateTo526($Manager)
242{
243 $Manager->Execute("ALTER TABLE `Hyperlink` CHANGE `Name` `Title` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL");
244 $Manager->Execute("ALTER TABLE `Hyperlink` ADD `Name` VARCHAR( 255 ) NOT NULL AFTER `Id`");
245 //$Manager->Execute("ALTER TABLE `Hyperlink` ADD UNIQUE ( `Name` )");
246 $Manager->Execute("ALTER TABLE `Hyperlink` ADD `Type` INT NOT NULL AFTER `Title` , ADD INDEX ( `Type` )");
247 $Manager->Execute("RENAME TABLE `Hyperlink` TO `Action` ;");
248 $Manager->Execute("RENAME TABLE `HyperlinkGroup` TO `ActionGroup` ;");
249 $Manager->Execute("CREATE TABLE IF NOT EXISTS `ActionType` (
250 `Id` int(11) NOT NULL AUTO_INCREMENT,
251 `Name` varchar(255) NOT NULL,
252 PRIMARY KEY (`Id`)
253 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
254
255 INSERT INTO `ActionType` (`Id`, `Name`) VALUES
256 (1, 'Odkaz'),
257 (2, 'Obrázek');");
258 $Manager->Execute("UPDATE `Action` SET `Type` = 1;");
259 $Manager->Execute("ALTER TABLE `Action` ADD FOREIGN KEY ( `Type` ) REFERENCES `ActionType` (".
260 "`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
261 $Manager->Execute("UPDATE `Panel` SET `Module` = 'ActionGroup' WHERE `Module` = 'HyperlinkGroup'");
262 $Manager->Execute("CREATE TABLE IF NOT EXISTS `ActionIcon` (
263 `Id` int(11) NOT NULL AUTO_INCREMENT,
264 `Name` varchar(255) NOT NULL,
265 PRIMARY KEY (`Id`)
266) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
267 $Manager->Execute("INSERT INTO `ActionIcon` (SELECT NULL AS `Id`, `IconFile` AS `Name` FROM `Action` WHERE `IconFile` != '' GROUP BY `IconFile`)");
268 $Manager->Execute("ALTER TABLE `Action` CHANGE `IconFile` `IconFile` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
269 $Manager->Execute("UPDATE `Action` SET `IconFile` = (SELECT `Id` FROM `ActionIcon` WHERE `ActionIcon`.`Name` = `Action`.`IconFile`) ");
270 $Manager->Execute("ALTER TABLE `Action` CHANGE `IconFile` `Icon` INT NULL ");
271 $Manager->Execute("UPDATE `Action` SET `Icon` = NULL WHERE `Icon` = 0");
272 $Manager->Execute("ALTER TABLE `Action` ADD INDEX ( `Icon` ) ");
273 $Manager->Execute("ALTER TABLE `Action` ADD FOREIGN KEY ( `Icon` ) REFERENCES `ActionIcon` (`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
274 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
275 "VALUES (NULL , 'Akce', '23', 'Action', '');");
276}
277
278function UpdateTo527($Manager)
279{
280 $Manager->Execute("RENAME TABLE `ISMenuItem` TO `MenuItem` ;");
281 $Manager->Execute("CREATE TABLE IF NOT EXISTS `Menu` (
282 `Id` int(11) NOT NULL AUTO_INCREMENT,
283 `Name` varchar(255) NOT NULL,
284 PRIMARY KEY (`Id`)
285) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
286 $Manager->Execute("INSERT INTO `Menu` (`Id` ,`Name`)VALUES (NULL , 'IS');");
287 $Manager->Execute("ALTER TABLE `MenuItem` ADD `Menu` INT NOT NULL , ADD INDEX ( `Menu` )");
288 $Manager->Execute("UPDATE `MenuItem` SET `Menu` = 1");
289 $Manager->Execute("ALTER TABLE `MenuItem` ADD FOREIGN KEY ( `Menu` ) REFERENCES `Menu` (".
290 "`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
291 $Manager->Execute("ALTER TABLE `Action` CHANGE `Group` `Group` INT( 11 ) NULL ");
292 $Manager->Execute("INSERT INTO `Action` (SELECT NULL AS `Id`, '' AS `Name`, `Name` AS `Title`, 1 AS `Type`, CONCAT('/is/?t=', `Table`, '&a=list') AS `URL`, NULL AS `Group`, NULL AS `Icon`, NULL AS `PermisionModule`, NULL AS `PermissionOperation`, 1 AS `Enable` FROM `MenuItem` WHERE `Parent` IS NOT NULL)");
293 $Manager->Execute("ALTER TABLE `MenuItem` DROP `IconName`");
294 $Manager->Execute("UPDATE `MenuItem` SET `Table` = (SELECT `Id` FROM `Action` WHERE `Action`.`URL` = CONCAT('/is/?t=', `MenuItem`.`Table`, '&a=list')) WHERE `MenuItem`.`Table` != ''");
295 $Manager->Execute("ALTER TABLE `MenuItem` CHANGE `Table` `Action` INT NULL");
296 $Manager->Execute("UPDATE `MenuItem` SET `Action` = NULL WHERE `Action` = 0");
297 $Manager->Execute("ALTER TABLE `MenuItem` ADD INDEX ( `Action` ) ");
298 $Manager->Execute("ALTER TABLE `MenuItem` ADD FOREIGN KEY ( `Action` ) REFERENCES `Action` (`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
299 $Manager->Execute("INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionModule` ,`PermissionOperation` ,`Enable`)".
300 "VALUES (NULL , '', 'Nabídky', '1', '/is/?t=Menu&a=list', NULL , NULL , '', '', '1');");
301 $ActionId = $Manager->Database->insert_id;
302 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
303 "VALUES (NULL , 'Nabídky', '23', '".$ActionId."', '1');");
304}
305
306function UpdateTo535($Manager)
307{
308 // Set all string collation to utf8 general
309 $DbResult = $Manager->Execute("SHOW TABLES");
310 while($DbRow = $DbResult->fetch_row())
311 {
312 $Manager->Execute("ALTER TABLE `".$DbRow[0]."` CONVERT TO CHARACTER SET utf8");
313 }
314}
315
316function UpdateTo549($Manager)
317{
318 $Manager->Execute("ALTER TABLE `FinanceOperation` ADD `Generate` INT NOT NULL DEFAULT '0',
319ADD INDEX ( `Generate` ) ;");
320 $Manager->Execute("ALTER TABLE `FinanceInvoice` ADD `Generate` INT NOT NULL DEFAULT '0',
321ADD INDEX ( `Generate` ) ;");
322}
323
324function UpdateTo550($Manager)
325{
326 $Manager->Execute('ALTER TABLE `FinanceBankAccount` ADD `LastImportId` VARCHAR( 255 ) NOT NULL ;');
327 $Manager->Execute('ALTER TABLE `FinanceBankAccount` ADD `LastImportDate` DATE NULL ;');
328 $Manager->Execute('ALTER TABLE `FinanceBankImport` ADD `BankCode` VARCHAR( 255 ) NOT NULL AFTER `AccountNumber` ;');
329}
330
331function UpdateTo551($Manager)
332{
333 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `DocumentLine` INT NULL AFTER `Value` ,
334ADD INDEX ( `DocumentLine` ) ;');
335 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD FOREIGN KEY ( `DocumentLine` ) REFERENCES `DocumentLine` (
336`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;');
337 $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD `DocumentLine` INT NULL AFTER `Id` ,
338ADD INDEX ( `DocumentLine` ) ;');
339 $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD FOREIGN KEY ( `DocumentLine` ) REFERENCES `DocumentLine` (
340`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;');
341 $Manager->Execute('DROP TABLE `FinanceBillsItemsOld`');
342 $Manager->Execute('DROP TABLE `FinanceBillsOld`');
343}
344
345function UpdateTo565($Manager)
346{
347 $Manager->Execute('CREATE TABLE IF NOT EXISTS `WikiPage` (
348 `Id` int(11) NOT NULL AUTO_INCREMENT,
349 `Name` varchar(255) NOT NULL,
350 `NormalizedName` varchar(255) NOT NULL,
351 `VisibleInMenu` int(11) NOT NULL,
352 PRIMARY KEY (`Id`),
353 UNIQUE KEY `Name` (`Name`),
354 KEY `VisibleInMenu` (`VisibleInMenu`)
355 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
356 $Manager->Execute('CREATE TABLE IF NOT EXISTS `WikiPageContent` (
357 `Id` int(11) NOT NULL AUTO_INCREMENT,
358 `Page` int(11) NOT NULL,
359 `Time` datetime NOT NULL,
360 `Content` text NOT NULL,
361 `User` int(11) NOT NULL,
362 PRIMARY KEY (`Id`),
363 KEY `User` (`User`),
364 KEY `Page` (`Page`)
365 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
366 $Manager->Execute('ALTER TABLE `WikiPageContent`
367 ADD CONSTRAINT `WikiPageContent_ibfk_2` FOREIGN KEY (`Page`) REFERENCES `WikiPage` (`Id`),
368ADD CONSTRAINT `WikiPageContent_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`ID`);');
369}
370
371function UpdateTo571($Manager)
372{
373 $Manager->Execute('ALTER TABLE `NetworkDevice` ADD `LoginName` VARCHAR( 255 ) NOT NULL ,
374ADD `LoginPassword` VARCHAR( 255 ) NOT NULL ;');
375}
376
377function UpdateTo574($Manager)
378{
379 $Manager->Execute('ALTER TABLE `MapPosition` ADD `Pos` VARCHAR( 255 ) NOT NULL ;');
380 $Manager->Execute('UPDATE `MapPosition` SET `Pos`=CONCAT(`Latitude`, ";", `Longitude`)');
381 $Manager->Execute('ALTER TABLE `MapPosition` DROP `Latitude`');
382 $Manager->Execute('ALTER TABLE `MapPosition` DROP `Longitude`');
383}
384
385function UpdateTo584($Manager)
386{
387 $Manager->Execute("CREATE TABLE IF NOT EXISTS `Module` (
388 `Id` int(11) NOT NULL AUTO_INCREMENT,
389 `Name` varchar(255) NOT NULL,
390 `Title` varchar(255) NOT NULL,
391 PRIMARY KEY (`Id`)
392 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=33 ;");
393
394 $Manager->Execute("INSERT INTO `Module` (`Id`, `Name`, `Title`) VALUES
395 (1, 'Customer', 'Zákazník'),
396 (2, 'EmailQueue', 'Fronta emailů'),
397 (3, 'Error', 'Obsluha chyb'),
398 (4, 'File', 'Správa souborů'),
399 (5, 'Finance', 'Finance'),
400 (6, 'FinanceBankAPI', 'Rozhraní pro bankovní účty'),
401 (7, 'Chat', 'Pokec'),
402 (8, 'IS', 'Informační systém'),
403 (9, 'Log', 'Záznam událostí'),
404 (10, 'Map', 'Mapa'),
405 (11, 'Meals', 'Jídelníček'),
406 (12, 'Meteostation', 'Meteostanice'),
407 (13, 'Network', 'Síť'),
408 (14, 'NetworkConfig', 'Nastavení sítě'),
409 (15, 'NetworkConfigLinux', 'Nastavení linuxových zařízení'),
410 (16, 'NetworkConfigRouterOS', 'Nastavení RouterOS zařízení'),
411 (17, 'NetworkShare', 'Síťové sdílení'),
412 (18, 'NetworkTopology', 'Síťová topologie'),
413 (19, 'News', 'Aktuality'),
414 (20, 'OpeningHours', 'Otvírací doby'),
415 (21, 'Portal', 'Portál'),
416 (22, 'Search', 'Vyhledávání'),
417 (23, 'Setup', 'Instalace systému'),
418 (24, 'SpeedTest', 'Měření rychlosti'),
419 (25, 'Stock', 'Sklad'),
420 (26, 'System', 'Systém'),
421 (27, 'Task', 'Úlohy'),
422 (28, 'TimeMeasure', 'Časové průběhy'),
423 (29, 'TV', 'Televize'),
424 (30, 'User', 'Uživatelé'),
425 (31, 'WebCam', 'Web kamery'),
426 (32, 'Wiki', 'Wiki');");
427 $Manager->Execute("UPDATE `PermissionOperation` SET `Module` = 'Meals' WHERE `PermissionOperation`.`Module` ='EatingPlace';");
428 $Manager->Execute("UPDATE `PermissionOperation` SET `Module` = 'NetworkShare' WHERE `PermissionOperation`.`Module` ='Share';");
429 $Manager->Execute("UPDATE `PermissionOperation` SET `Module` = 'OpeningHours' WHERE `PermissionOperation`.`Module` ='SubjectOpenTime';");
430 $Manager->Execute("UPDATE `PermissionOperation` SET `Module`=(SELECT `Id` FROM `Module` WHERE `Module`.`Name` = `PermissionOperation`.`Module`)");
431 $Manager->Execute("ALTER TABLE `PermissionOperation` CHANGE `Module` `Module` INT( 11 ) NOT NULL ;");
432 $Manager->Execute("ALTER TABLE `PermissionOperation` ADD FOREIGN KEY ( `Module` ) REFERENCES `Module` (
433`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
434 $Manager->Execute("UPDATE `Action` SET `Action`.`PermissionOperation` =(SELECT Id FROM `PermissionOperation` WHERE `PermissionOperation`.`Operation`=`Action`.`PermissionOperation` AND `PermissionOperation`.`Module` = (SELECT Id FROM `Module` WHERE `Module`.`Name`=`Action`.`PermissionModule`))");
435 $Manager->Execute("ALTER TABLE `Action` CHANGE `PermissionOperation` `PermissionOperation` INT( 11 ) NULL ;");
436 $Manager->Execute("ALTER TABLE `Action` DROP `PermissionModule` ;");
437 $Manager->Execute("UPDATE `Action` SET `PermissionOperation`=NULL WHERE `PermissionOperation`=0");
438 $Manager->Execute("ALTER TABLE `Action` ADD INDEX (`PermissionOperation`);");
439 $Manager->Execute("ALTER TABLE `Action` ADD FOREIGN KEY ( `PermissionOperation` ) REFERENCES `PermissionOperation` (
440`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
441}
442
443function UpdateTo591($Manager)
444{
445 $Manager->Execute('ALTER TABLE `StockItem` ADD `Esemble` INT NULL ,
446ADD INDEX ( `Esemble` ) ;');
447 $Manager->Execute('ALTER TABLE `StockItem` ADD FOREIGN KEY ( `Esemble` ) REFERENCES `StockItem` (
448`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;');
449}
450
451function UpdateTo597($Manager)
452{
453 $Manager->Execute('CREATE TABLE IF NOT EXISTS `Model` (
454 `Id` int(11) NOT NULL AUTO_INCREMENT,
455 `Name` varchar(255) NOT NULL,
456 `Module` int(11) NOT NULL,
457 PRIMARY KEY (`Id`),
458 KEY `Module` (`Module`)
459) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
460
461 $Manager->Execute('ALTER TABLE `Model`
462 ADD CONSTRAINT `Model_ibfk_1` FOREIGN KEY (`Module`) REFERENCES `Module` (`Id`);');
463}
464
465function UpdateTo601($Manager)
466{
467 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkInterfaceWireless` (
468 `Id` int(11) NOT NULL AUTO_INCREMENT,
469 `NetworkInterface` int(11) NOT NULL,
470 `TxPower` int(11) NOT NULL,
471 `CableAttenuation` int(11) NOT NULL,
472 `AntenaGain` int(11) NOT NULL,
473 `Frequency` float NOT NULL,
474 `ChannelWidth` int(11) NOT NULL,
475 `SSID` varchar(255) NOT NULL,
476 PRIMARY KEY (`Id`),
477 KEY `NetworkInterface` (`NetworkInterface`)
478) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
479
480 $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless`
481 ADD CONSTRAINT `NetworkInterfaceWireless_ibfk_1` FOREIGN KEY (`NetworkInterface`) REFERENCES `NetworkInterface` (`Id`);');
482 $Manager->Execute("INSERT INTO `Action` (
483`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` ,
484`Enable`) VALUES (NULL , '', 'Wifi rozhraní', '1', '/is/?t=NetworkInterfaceWireless&a=list', NULL , NULL , NULL , '1'
485);");
486 $ActionId = $Manager->Database->insert_id;
487 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
488 "VALUES (NULL , 'Bezdrátové rozhraní', '1', '".$ActionId."', '1');");
489}
490
491function UpdateTo615($Manager)
492{
493 $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD `AntennaPolarity` INT NOT NULL ,
494ADD `Description` VARCHAR( 255 ) NOT NULL ;');
495 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NewsImport` (
496 `Id` int(11) NOT NULL,
497 `Name` varchar(255) NOT NULL,
498 `Enabled` int(11) NOT NULL,
499 `Source` varchar(255) NOT NULL,
500 `Category` int(11) NOT NULL,
501 `BlockStart` varchar(255) NOT NULL,
502 `BlockEnd` varchar(255) NOT NULL,
503 `ItemStart` varchar(255) NOT NULL,
504 `ItemEnd` varchar(255) NOT NULL,
505 `TitleStart` varchar(255) NOT NULL,
506 `TitleEnd` varchar(255) NOT NULL,
507 `ContentStart` varchar(255) NOT NULL,
508 `ContentEnd` varchar(255) NOT NULL,
509 `LinkStart` varchar(255) NOT NULL,
510 `LinkEnd` varchar(255) NOT NULL,
511 `DateStart` varchar(255) NOT NULL,
512 `DateEnd` varchar(255) NOT NULL,
513 KEY `Category` (`Category`)
514) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
515 $Manager->Execute('ALTER TABLE `NewsImport` '.
516 'ADD CONSTRAINT `NewsImport_ibfk_1` FOREIGN KEY (`Category`) '.
517 ' REFERENCES `NewsCategory` (`Id`);');
518 $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD `Antenna` INT NULL AFTER `AntennaPolarity` ,
519ADD INDEX ( `Product` ) ;');
520 $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD FOREIGN KEY ( `Antenna` ) REFERENCES `Product` (
521`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;');
522 $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD `MAC` VARCHAR( 17 ) NOT NULL ;');
523}
524
525function UpdateTo619($Manager)
526{
527 $Manager->Execute('ALTER TABLE `UserOnline` ADD `StayLogged` INT NOT NULL ;');
528}
529
530function UpdateTo620($Manager)
531{
532 $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD `ChannelWidthLower` INT NOT NULL ,
533ADD `ChannelWidthUpper` INT NOT NULL ;');
534 $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD `Mode` INT NOT NULL ;');
535 $Manager->Execute('DROP TABLE `NetworkAP`');
536}
537
538class Updates
539{
540 function Get()
541 {
542 return(array(
543 491 => array('Revision' => 493, 'Function' => 'UpdateTo493'),
544 493 => array('Revision' => 494, 'Function' => 'UpdateTo494'),
545 494 => array('Revision' => 495, 'Function' => 'UpdateTo495'),
546 495 => array('Revision' => 497, 'Function' => 'UpdateTo497'),
547 497 => array('Revision' => 498, 'Function' => 'UpdateTo498'),
548 498 => array('Revision' => 499, 'Function' => 'UpdateTo499'),
549 499 => array('Revision' => 500, 'Function' => 'UpdateTo500'),
550 500 => array('Revision' => 502, 'Function' => 'UpdateTo502'),
551 502 => array('Revision' => 505, 'Function' => 'UpdateTo505'),
552 505 => array('Revision' => 507, 'Function' => 'UpdateTo507'),
553 507 => array('Revision' => 515, 'Function' => 'UpdateTo515'),
554 515 => array('Revision' => 517, 'Function' => 'UpdateTo517'),
555 517 => array('Revision' => 526, 'Function' => 'UpdateTo526'),
556 526 => array('Revision' => 527, 'Function' => 'UpdateTo527'),
557 527 => array('Revision' => 535, 'Function' => 'UpdateTo535'),
558 535 => array('Revision' => 549, 'Function' => 'UpdateTo549'),
559 549 => array('Revision' => 550, 'Function' => 'UpdateTo550'),
560 550 => array('Revision' => 551, 'Function' => 'UpdateTo551'),
561 551 => array('Revision' => 565, 'Function' => 'UpdateTo565'),
562 565 => array('Revision' => 571, 'Function' => 'UpdateTo571'),
563 571 => array('Revision' => 574, 'Function' => 'UpdateTo574'),
564 574 => array('Revision' => 584, 'Function' => 'UpdateTo584'),
565 584 => array('Revision' => 591, 'Function' => 'UpdateTo591'),
566 591 => array('Revision' => 597, 'Function' => 'UpdateTo597'),
567 597 => array('Revision' => 601, 'Function' => 'UpdateTo601'),
568 601 => array('Revision' => 615, 'Function' => 'UpdateTo615'),
569 615 => array('Revision' => 619, 'Function' => 'UpdateTo619'),
570 619 => array('Revision' => 620, 'Function' => 'UpdateTo620'),
571 ));
572 }
573}
Note: See TracBrowser for help on using the repository browser.