diff options
Diffstat (limited to 'modules-available/rebootcontrol/install.inc.php')
-rw-r--r-- | modules-available/rebootcontrol/install.inc.php | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/modules-available/rebootcontrol/install.inc.php b/modules-available/rebootcontrol/install.inc.php index f400129e..d45a2443 100644 --- a/modules-available/rebootcontrol/install.inc.php +++ b/modules-available/rebootcontrol/install.inc.php @@ -39,7 +39,7 @@ $output[] = tableCreate('reboot_subnet_x_subnet', " $output[] = tableCreate('reboot_scheduler', " `locationid` INT(11) NOT NULL, - `action` ENUM('wol', 'sd', 'rb'), + `action` ENUM('WOL', 'SHUTDOWN', 'REBOOT'), `nextexecution` INT(10) UNSIGNED NOT NULL DEFAULT 0, `options` BLOB, PRIMARY KEY (`locationid`)"); @@ -60,9 +60,16 @@ if (tableColumnKeyType('reboot_scheduler', 'action') === 'PRI') { $res = Database::exec("ALTER TABLE `reboot_scheduler` DROP PRIMARY KEY, ADD PRIMARY KEY (`locationid`)"); $output[] = $res !== false ? UPDATE_DONE : UPDATE_FAILED; } -if (strpos(tableColumnType('reboot_scheduler', 'action'), 'rb') === false) { - $res = Database::exec("ALTER TABLE `reboot_scheduler` MODIFY COLUMN `action` ENUM('wol', 'sd', 'rb')"); - $output[] = $res !== false ? UPDATE_DONE : UPDATE_FAILED; +if (strpos(tableColumnType('reboot_scheduler', 'action'), 'REBOOT') === false) { + // Fiddle with column to rename ENUM values + $res = Database::exec("ALTER TABLE `reboot_scheduler` MODIFY COLUMN `action` ENUM('sd', 'rb', 'WOL', 'SHUTDOWN', 'REBOOT')"); + handleUpdateResult($res); + $res = Database::exec("UPDATE reboot_scheduler SET action = + CASE WHEN action = 'sd' THEN 'SHUTDOWN' WHEN action = 'rb' THEN 'REBOOT' ELSE 'WOL' END"); + handleUpdateResult($res); + $res = Database::exec("ALTER TABLE `reboot_scheduler` MODIFY COLUMN `action` ENUM('WOL', 'SHUTDOWN', 'REBOOT')"); + handleUpdateResult($res); + $output[] = UPDATE_DONE; } |