From 878dbac85a9f684916e2d30cab4782e21a03e767 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 4 Jul 2022 15:42:13 +0200 Subject: [rebootcontrol/main] Add subkey column to property_list table This makes it easier to reference to list entries that have non-trivial data values, e.g. long json data. --- modules-available/main/install.inc.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'modules-available/main/install.inc.php') diff --git a/modules-available/main/install.inc.php b/modules-available/main/install.inc.php index b7dd2c4d..a19a069d 100644 --- a/modules-available/main/install.inc.php +++ b/modules-available/main/install.inc.php @@ -28,10 +28,13 @@ $res[] = tableCreate('property', " $res[] = tableCreate('property_list', " `name` varchar(50) NOT NULL, + `subkey` int(10) unsigned NOT NULL AUTO_INCREMENT, `dateline` int(10) unsigned NOT NULL DEFAULT '0', `value` text NOT NULL, KEY (`name`), - KEY `dateline` (`dateline`) + KEY `dateline` (`dateline`), + ADD KEY (`subkey`), + UNIQUE KEY `compound` (`name`, `subkey`) "); $res[] = tableCreate('user', " @@ -116,6 +119,19 @@ if (!tableHasColumn('user', 'serverid')) { Database::exec("ALTER TABLE `user` ADD `serverid` int(10) unsigned NULL DEFAULT NULL"); } +// +// +if (!tableHasColumn('property_list', 'subkey')) { + $ret = Database::exec("ALTER TABLE property_list + ADD COLUMN `subkey` int(10) unsigned NOT NULL AUTO_INCREMENT AFTER `name`, + ADD KEY (`subkey`), + ADD UNIQUE KEY `compound` (`name`, `subkey`)"); + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Cannot add subkey to property_list: ' . Database::lastError()); + } + $res[] = UPDATE_DONE; +} + // Make sure that if any users exist, one of the has UID=1, otherwise if the permission module is // used we'd lock out everyone $someUser = Database::queryFirst('SELECT userid FROM user ORDER BY userid ASC LIMIT 1'); -- cgit v1.2.3-55-g7522