fetch(PDO::FETCH_ASSOC)) { $new = strtoupper('baad1d00-9491-4716-b98b-' . preg_replace('/[^0-9a-f]/i', '', $row['macaddr'])); error_log('Replacing ' . $row['machineuuid'] . ' with ' . $new); if (strlen($new) === 36) { if (Database::exec("UPDATE machine SET machineuuid = :new WHERE machineuuid = :old", ['old' => $row['machineuuid'], 'new' => $new]) === false) { error_log('Result: ' . Database::lastError()); Database::exec("DELETE FROM machine WHERE machineuuid = :old", ['old' => $row['machineuuid']]); } } } // 2019-10-31: New table for per-machine config override $res[] = tableAddConstraint('setting_machine', 'machineuuid', 'machine', 'machineuuid', 'ON UPDATE CASCADE ON DELETE CASCADE'); // 2020-04-25: Track enter/exit standby count, live CPU load if (!tableHasColumn('machine', 'live_cpuload')) { $ret = Database::exec("ALTER TABLE `machine` ADD COLUMN `live_cpuload` tinyint(3) UNSIGNED NOT NULL DEFAULT '255' AFTER `live_memfree`, ADD COLUMN `live_cputemp` tinyint(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `live_cpuload`, ADD COLUMN `standbysem` tinyint(3) UNSIGNED NOT NULL DEFAULT '0', ADD INDEX `live_cpuload` (`live_cpuload`), ADD INDEX `live_cputemp` (`live_cputemp`)"); if ($ret === false) { finalResponse(UPDATE_FAILED, 'Adding live_cpuload column to machine table failed: ' . Database::lastError()); } $res[] = UPDATE_DONE; } // 2020-06-29: Track current runmode (as reported by client) if (!tableHasColumn('machine', 'currentrunmode')) { $ret = Database::exec("ALTER TABLE `machine` ADD COLUMN `currentrunmode` varchar(30) NOT NULL DEFAULT '' AFTER `hostname`"); if ($ret === false) { finalResponse(UPDATE_FAILED, 'Adding live_cpuload column to machine table failed: ' . Database::lastError()); } $res[] = UPDATE_DONE; } // Create response responseFromArray($res);