summaryrefslogtreecommitdiffstats
path: root/modules-available/serversetup-bwlp-ipxe/install.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/serversetup-bwlp-ipxe/install.inc.php')
-rw-r--r--modules-available/serversetup-bwlp-ipxe/install.inc.php31
1 files changed, 22 insertions, 9 deletions
diff --git a/modules-available/serversetup-bwlp-ipxe/install.inc.php b/modules-available/serversetup-bwlp-ipxe/install.inc.php
index 5af00493..9714d381 100644
--- a/modules-available/serversetup-bwlp-ipxe/install.inc.php
+++ b/modules-available/serversetup-bwlp-ipxe/install.inc.php
@@ -7,7 +7,7 @@ $result[] = tableCreate('serversetup_bootentry', "
`hotkey` varchar(8) CHARACTER SET ascii NOT NULL,
`title` varchar(100) NOT NULL,
`builtin` tinyint(1) NOT NULL,
- `module` varchar(30) DEFAULT NULL,
+ `module` varchar(30) NOT NULL,
`data` blob NOT NULL,
PRIMARY KEY (`entryid`)
");
@@ -113,18 +113,31 @@ if (Module::get('locations') !== false) {
// 2019-09-21 Add module column to bootentry
if (!tableHasColumn('serversetup_bootentry', 'module')) {
+ // First, nullable, so we can update old entries
if (Database::exec("ALTER TABLE serversetup_bootentry
ADD COLUMN `module` varchar(30) CHARACTER SET ascii DEFAULT NULL AFTER `builtin`") !== false) {
$result[] = UPDATE_DONE;
- $res = Database::simpleQuery('SELECT entryid, data FROM serversetup_bootentry WHERE module IS NULL');
- foreach ($res as $row) {
- $json = json_decode($row['data'], true);
- if (isset($json['script'])) {
- Database::exec("UPDATE serversetup_bootentry SET module = '.script' WHERE entryid = :id", ['id' => $row['entryid']]);
- } else {
- Database::exec("UPDATE serversetup_bootentry SET module = '.exec' WHERE entryid = :id", ['id' => $row['entryid']]);
- }
+ } else {
+ $result[] = UPDATE_FAILED;
+ }
+}
+// 2024-07-22 NULLable module column makes no sense and breaks slx-admin - disallow
+if (tableGetDescribeColumn('serversetup_bootentry', 'module', 'Null') === 'YES') {
+ // Update any old fields that now have NULL as module
+ $res = Database::simpleQuery('SELECT entryid, data FROM serversetup_bootentry WHERE module IS NULL');
+ foreach ($res as $row) {
+ $json = json_decode($row['data'], true);
+ if (isset($json['script'])) {
+ Database::exec("UPDATE serversetup_bootentry SET module = '.script' WHERE entryid = :id", ['id' => $row['entryid']]);
+ } else {
+ Database::exec("UPDATE serversetup_bootentry SET module = '.exec' WHERE entryid = :id", ['id' => $row['entryid']]);
}
+ }
+ // Just to be safe
+ Database::simpleQuery('DELETE FROM serversetup_bootentry WHERE module IS NULL');
+ if (Database::exec("ALTER TABLE serversetup_bootentry
+ MODIFY `module` varchar(30) CHARACTER SET ascii NOT NULL") !== false) {
+ $result[] = UPDATE_DONE;
} else {
$result[] = UPDATE_FAILED;
}