diff options
author | Simon Rettberg | 2016-09-01 19:28:12 +0200 |
---|---|---|
committer | Simon Rettberg | 2016-09-01 19:28:12 +0200 |
commit | 0ea240b825b571d668b3413391ee5c86c464403f (patch) | |
tree | e72a8ada099166ec09bdd036e404084f1916b18c /modules-available/statistics | |
parent | [roomplanner] Don't pretty print json (diff) | |
download | slx-admin-0ea240b825b571d668b3413391ee5c86c464403f.tar.gz slx-admin-0ea240b825b571d668b3413391ee5c86c464403f.tar.xz slx-admin-0ea240b825b571d668b3413391ee5c86c464403f.zip |
[statistics] Enlarge position column as json might get a little longer
Diffstat (limited to 'modules-available/statistics')
-rw-r--r-- | modules-available/statistics/install.inc.php | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/modules-available/statistics/install.inc.php b/modules-available/statistics/install.inc.php index f5203d7a..be07274c 100644 --- a/modules-available/statistics/install.inc.php +++ b/modules-available/statistics/install.inc.php @@ -29,7 +29,7 @@ $res[] = tableCreate('machine', " `firstseen` int(10) unsigned NOT NULL, `lastseen` int(10) unsigned NOT NULL, `logintime` int(10) unsigned NOT NULL, - `position` varchar(40) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, + `position` varchar(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, `lastboot` int(10) unsigned NOT NULL, `realcores` smallint(5) unsigned NOT NULL, `mbram` int(10) unsigned NOT NULL, @@ -40,6 +40,8 @@ $res[] = tableCreate('machine', " `badsectors` int(10) unsigned NOT NULL, `data` mediumtext NOT NULL, `hostname` varchar(200) NOT NULL DEFAULT '', + `currentsession` varchar(120) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, + `currentuser` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, `notes` text, PRIMARY KEY (`machineuuid`), KEY `macaddr` (`macaddr`), @@ -79,6 +81,7 @@ if (!tableHasColumn('statistic', 'machineuuid')) { $res[] = UPDATE_DONE; } +// Rename roomid to locationid if (tableHasColumn('machine', 'roomid')) { $ret = Database::exec("ALTER TABLE `machine` CHANGE `roomid` `locationid` INT(11) DEFAULT NULL") !== false; $ret = Database::exec("ALTER TABLE `machine` DROP `roomid`") !== false || $ret; @@ -88,6 +91,27 @@ if (tableHasColumn('machine', 'roomid')) { $res[] = UPDATE_DONE; } +// 2016-08-31: Add lectureid and user name +if (!tableHasColumn('machine', 'currentsession')) { + $ret = Database::exec("ALTER TABLE `machine` ADD COLUMN `currentsession` varchar(120) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL AFTER hostname") !== false; + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Adding currentsession to machine failed: ' . Database::lastError()); + } + $res[] = UPDATE_DONE; +} +if (!tableHasColumn('machine', 'currentuser')) { + $ret = Database::exec("ALTER TABLE `machine` ADD COLUMN `currentuser` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL AFTER currentsession") !== false; + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Adding currentuser to machine failed: ' . Database::lastError()); + } + $res[] = UPDATE_DONE; +} +// 2016-09-01: Fix position column size +$ret = Database::exec("ALTER TABLE `machine` CHANGE `position` `position` VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL"); +if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Expanding position column failed: ' . Database::lastError()); +} + // Create response if (in_array(UPDATE_DONE, $res)) { |