Changeset 740 for trunk/Common/Setup/Updates.php
- Timestamp:
- Jul 3, 2015, 11:36:07 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Setup/Updates.php
r739 r740 1354 1354 `Address` varchar(255) NOT NULL, 1355 1355 `Domain` int(11) NOT NULL, 1356 `Sequence` int(11) NOT NULL 1356 `Sequence` int(11) NOT NULL, 1357 1357 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;'); 1358 1358 … … 1362 1362 $Manager->Execute('ALTER TABLE `NetworkDomainServer` 1363 1363 ADD CONSTRAINT `NetworkDomainServer_ibfk_1` FOREIGN KEY (`Domain`) REFERENCES `NetworkDomain` (`Id`);'); 1364 1364 } 1365 1366 function UpdateTo740($Manager) 1367 { 1368 $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceInvoiceGroup` ( 1369 `Id` int(11) NOT NULL AUTO_INCREMENT, 1370 `Name` varchar(255) NOT NULL, 1371 `DocumentLine` int(11) NOT NULL, 1372 `ValueSign` int(11) NOT NULL, 1373 PRIMARY KEY (`Id`), 1374 KEY `DocumentLine` (`DocumentLine`) 1375 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;'); 1376 $Manager->Execute('ALTER TABLE `FinanceInvoiceGroup` 1377 ADD CONSTRAINT `FinanceInvoiceGroup_ibfk_1` FOREIGN KEY (`DocumentLine`) REFERENCES `DocumentLine` (`Id`);'); 1378 $Manager->Execute('INSERT INTO `FinanceInvoiceGroup` (`Id`, `Name`, `DocumentLine`, `ValueSign`) VALUES 1379 (1, "Přijaté faktury", 5, -1), 1380 (2, "Vydané faktury", 6, 1);'); 1381 1382 // Transform FinanceInvoice.DocumentLine reference to FinanceInvoiceGroup 1383 $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD `Group` INT NULL AFTER `Id`;'); 1384 $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD INDEX(`Group`);'); 1385 $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD FOREIGN KEY (`Group`) REFERENCES `FinanceInvoiceGroup`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); 1386 $Manager->Execute('UPDATE `FinanceInvoice` SET `Group`=1 WHERE `DocumentLine`=5'); 1387 $Manager->Execute('UPDATE `FinanceInvoice` SET `Group`=2 WHERE `DocumentLine`=6'); 1388 $Manager->Execute('ALTER TABLE `FinanceInvoice` DROP FOREIGN KEY `FinanceInvoice_ibfk_3`;'); 1389 $Manager->Execute('ALTER TABLE `FinanceInvoice` DROP `DocumentLine`;'); 1390 1391 $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceOperationGroup` ( 1392 `Id` int(11) NOT NULL AUTO_INCREMENT, 1393 `Name` varchar(255) NOT NULL, 1394 `DocumentLine` int(11) NOT NULL, 1395 `ValueSign` int(11) NOT NULL, 1396 PRIMARY KEY (`Id`), 1397 KEY `DocumentLine` (`DocumentLine`) 1398 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;'); 1399 $Manager->Execute('ALTER TABLE `FinanceOperationGroup` 1400 ADD CONSTRAINT `FinanceOperationGroup_ibfk_1` FOREIGN KEY (`DocumentLine`) REFERENCES `DocumentLine` (`Id`);'); 1401 $Manager->Execute('INSERT INTO `FinanceOperationGroup` (`Id`, `Name`, `DocumentLine`, `ValueSign`) VALUES 1402 (1, "Příjem do pokladny", 1, 1), 1403 (2, "Výdej z pokladny", 2, -1), 1404 (3, "Příjem na účet", 3, 1), 1405 (4, "Výdej z účtu", 4, -1), 1406 (5, "Nezařazené (ručně vyčistit)", 1, 1);'); 1407 1408 // Transform FinanceOperation.DocumentLine reference to FinanceOperationGroup 1409 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `Group` INT NULL AFTER `Id`;'); 1410 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD INDEX (`Group`);'); 1411 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD FOREIGN KEY (`Group`) REFERENCES `FinanceOperationGroup`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); 1412 $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=1 WHERE `DocumentLine`=1'); 1413 $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=2 WHERE `DocumentLine`=2'); 1414 $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=3 WHERE `DocumentLine`=3'); 1415 $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=4 WHERE `DocumentLine`=4'); 1416 $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=5 WHERE `DocumentLine`=10'); 1417 $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=5 WHERE `DocumentLine`=5'); 1418 $Manager->Execute('ALTER TABLE `FinanceOperation` DROP FOREIGN KEY `FinanceOperation_ibfk_6`;'); 1419 $Manager->Execute('ALTER TABLE `FinanceOperation` DROP `DocumentLine`;'); 1420 1421 $Manager->Execute('ALTER TABLE `FinanceInvoice` CHANGE `Direction` `ValueSign` INT(11) NOT NULL;'); 1422 $Manager->Execute('ALTER TABLE `FinanceOperation` CHANGE `Direction` `ValueSign` INT(11) NOT NULL;'); 1365 1423 } 1366 1424
Note:
See TracChangeset
for help on using the changeset viewer.