Ignore:
Timestamp:
Dec 29, 2014, 12:09:46 AM (10 years ago)
Author:
chronos
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Setup/Updates.php

    r707 r710  
    914914function UpdateTo696($Manager)
    915915{
    916         $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` ADD `Duration` INT NOT NULL ;');
    917         $Manager->Execute('UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = IFNULL(TIMESTAMPDIFF(SECOND,
    918     (SELECT `Time` FROM (SELECT * FROM `NetworkInterfaceUpDown`) AS `TA` WHERE (`TA`.`Time` < `TM`.`Time`)
    919     AND (`TA`.`Interface`=`TM`.`Interface`) ORDER BY `TA`.`Time` DESC LIMIT 1), `TM`.`Time`), 0)');
     916  $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` ADD `Duration` INT NOT NULL ;');
     917  $Manager->Execute('UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = IFNULL(TIMESTAMPDIFF(SECOND,
     918  (SELECT `Time` FROM (SELECT * FROM `NetworkInterfaceUpDown`) AS `TA` WHERE (`TA`.`Time` < `TM`.`Time`)
     919  AND (`TA`.`Interface`=`TM`.`Interface`) ORDER BY `TA`.`Time` DESC LIMIT 1), `TM`.`Time`), 0)');
    920920}
    921921
    922922function UpdateTo697($Manager)
    923923{
    924         $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` CHANGE `Duration` `Duration` INT( 11 ) NULL ;');
    925         $Manager->Execute('UPDATE `NetworkInterfaceUpDown` SET `Duration` = NULL');
    926         $Manager->Execute('UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = TIMESTAMPDIFF(SECOND,
    927     `TM`.`Time`, (SELECT `Time` FROM (SELECT * FROM `NetworkInterfaceUpDown`) AS `TA` WHERE (`TA`.`Time` > `TM`.`Time`)
    928     AND (`TA`.`Interface`=`TM`.`Interface`) ORDER BY `TA`.`Time` ASC LIMIT 1))');
     924  $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` CHANGE `Duration` `Duration` INT( 11 ) NULL ;');
     925  $Manager->Execute('UPDATE `NetworkInterfaceUpDown` SET `Duration` = NULL');
     926  $Manager->Execute('UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = TIMESTAMPDIFF(SECOND,
     927  `TM`.`Time`, (SELECT `Time` FROM (SELECT * FROM `NetworkInterfaceUpDown`) AS `TA` WHERE (`TA`.`Time` > `TM`.`Time`)
     928  AND (`TA`.`Interface`=`TM`.`Interface`) ORDER BY `TA`.`Time` ASC LIMIT 1))');
    929929}
    930930
    931931function UpdateTo707($Manager)
    932932{
    933         $Manager->Execute('ALTER TABLE `NetworkDevice` CHANGE `Product` `Product` INT(11) NULL;');
     933  $Manager->Execute('ALTER TABLE `NetworkDevice` CHANGE `Product` `Product` INT(11) NULL;');
     934}
     935
     936function UpdateTo710($Manager)
     937{       
     938  $Manager->Execute('RENAME TABLE `StockItem` TO `StockSerialNumber`;');
     939  $Manager->Execute('UPDATE `Action` SET `URL`="/is/?t=StockSerialNumber&a=list",`Title`="Sériová čísla" WHERE `URL`="/is/?t=StockItem&a=list";');
     940 
     941  // StockMove
     942  $Manager->Execute('CREATE TABLE IF NOT EXISTS `StockMove` (
     943  `Id` int(11) NOT NULL,
     944  `Time` datetime NOT NULL,
     945  `StockFrom` int(11) DEFAULT NULL,
     946  `StockTo` int(11) DEFAULT NULL,
     947  `BillCode` varchar(255) NOT NULL,
     948  `DocumentLine` int(11) NOT NULL,
     949  `File` int(11) DEFAULT NULL
     950  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
     951   
     952  $Manager->Execute('ALTER TABLE `StockMove`
     953  ADD PRIMARY KEY (`Id`), ADD KEY `DocumentLine` (`DocumentLine`), ADD KEY `StockFrom` (`StockFrom`), ADD KEY `StockTo` (`StockTo`), ADD KEY `File` (`File`);');
     954   
     955  $Manager->Execute('ALTER TABLE `StockMove`
     956  MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;');
     957 
     958  $Manager->Execute('ALTER TABLE `StockMove`
     959  ADD CONSTRAINT `StockMove_ibfk_1` FOREIGN KEY (`StockFrom`) REFERENCES `Stock` (`Id`),
     960  ADD CONSTRAINT `StockMove_ibfk_2` FOREIGN KEY (`StockTo`) REFERENCES `Stock` (`Id`),
     961  ADD CONSTRAINT `StockMove_ibfk_3` FOREIGN KEY (`DocumentLine`) REFERENCES `DocumentLine` (`Id`);');
     962 
     963  // StockMoveItem
     964  $Manager->Execute('CREATE TABLE IF NOT EXISTS `StockMoveItem` (
     965  `Id` int(11) NOT NULL,
     966  `StockMove` int(11) NOT NULL,
     967  `Product` int(11) NOT NULL,
     968  `Amount` int(11) NOT NULL,
     969  `Text` varchar(255) NOT NULL,
     970  `UnitPrice` int(11) NOT NULL
     971  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
     972 
     973  $Manager->Execute('ALTER TABLE `StockMoveItem`
     974  ADD PRIMARY KEY (`Id`), ADD KEY `Product` (`Product`), ADD KEY `StockMove` (`StockMove`);');
     975 
     976  $Manager->Execute('ALTER TABLE `StockMoveItem`
     977  MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;');
     978
     979  $Manager->Execute('ALTER TABLE `StockMoveItem`
     980  ADD CONSTRAINT `StockMoveItem_ibfk_2` FOREIGN KEY (`Product`) REFERENCES `Product` (`Id`),
     981  ADD CONSTRAINT `StockMoveItem_ibfk_1` FOREIGN KEY (`StockMove`) REFERENCES `StockMove` (`Id`);'); 
     982
     983  // IS menu item
     984  $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
     985`Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
     986NULL , "", "Skladové pohyby", "1", "/is/?t=StockMove&a=list", NULL , NULL , NULL , "1");');
     987  $ActionId = $Manager->Database->insert_id;
     988  $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Sklad"');
     989  if($DbResult->num_rows > 0)
     990  {
     991        $DbRow = $DbResult->fetch_assoc();
     992    $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
     993      "VALUES (NULL , 'Skladové pohyby', ".$DbRow['Id'].", '".$ActionId."', '1');");
     994  }
    934995}
    935996
     
    9871048      696 => array('Revision' => 697, 'Function' => 'UpdateTo697'),
    9881049      697 => array('Revision' => 707, 'Function' => 'UpdateTo707'),
     1050      707 => array('Revision' => 710, 'Function' => 'UpdateTo710'),
    9891051    ));
    9901052  }
Note: See TracChangeset for help on using the changeset viewer.