Ignore:
Timestamp:
Feb 25, 2022, 9:30:55 AM (3 years ago)
Author:
chronos
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/UpdateTrace.php

    r911 r921  
    21752175{
    21762176  $Manager->Execute('ALTER TABLE `NetworkSignal` ADD `Remote` INT NOT NULL DEFAULT "0" AFTER `Device`;');
     2177}
     2178
     2179function UpdateTo921(UpdateManager $Manager): void
     2180{
     2181  $Manager->Execute('CREATE TABLE `NetworkMac` (
     2182    `Id` int(11) NOT NULL,
     2183    `MAC` varchar(17) NOT NULL
     2184  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
     2185  $Manager->Execute('ALTER TABLE `NetworkMac` ADD PRIMARY KEY (`Id`), ADD KEY `MAC` (`MAC`);');
     2186  $Manager->Execute('ALTER TABLE `NetworkMac` MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;'); 
     2187
     2188  // Convert NetworkSignal MAC from string into reference
     2189  $Manager->Execute('INSERT INTO `NetworkMac` (`MAC`) SELECT DISTINCT(`MAC`) FROM `NetworkSignal`;');
     2190  $Manager->Execute('ALTER TABLE `NetworkSignal` ADD `MACTemp` INT NOT NULL AFTER `Remote`;');
     2191  $Manager->Execute('UPDATE `NetworkSignal` SET `MACTemp` = (SELECT `Id` FROM `NetworkMac` WHERE `NetworkMac`.`MAC` = `NetworkSignal`.`MAC`);');
     2192  $Manager->Execute('ALTER TABLE `NetworkSignal` DROP `MAC`;');
     2193  $Manager->Execute('ALTER TABLE `NetworkSignal` CHANGE `MACTemp` `MAC` INT(11) NOT NULL;');
     2194  $Manager->Execute('ALTER TABLE `NetworkSignal` ADD KEY `MAC` (`MAC`);');
     2195  $Manager->Execute('ALTER TABLE `NetworkSignal` ADD FOREIGN KEY (`MAC`) REFERENCES `NetworkMac`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
     2196
     2197  // IS menu item
     2198  $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
     2199    `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
     2200    NULL , "", "Fyzické adresy", "1", "/is/?t=NetworkMac&a=list", NULL , NULL , NULL , "1");');
     2201  $ActionId = $Manager->Database->insert_id;
     2202  $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Síť"');
     2203  if ($DbResult->num_rows > 0)
     2204  {
     2205    $DbRow = $DbResult->fetch_assoc();
     2206    $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
     2207        "VALUES (NULL , 'Fyzické adresy', ".$DbRow['Id'].", '".$ActionId."', '1');");
     2208  }
    21772209}
    21782210
     
    22842316      901 => array('Revision' => 907, 'Function' => 'UpdateTo907'),
    22852317      907 => array('Revision' => 911, 'Function' => 'UpdateTo911'),
     2318      911 => array('Revision' => 921, 'Function' => 'UpdateTo921'),
    22862319    );
    22872320  }
Note: See TracChangeset for help on using the changeset viewer.