diff options
author | Simon Rettberg | 2017-06-21 18:37:55 +0200 |
---|---|---|
committer | Simon Rettberg | 2017-06-21 18:37:55 +0200 |
commit | 2382d53a3b6fda1a004f321c1eec049b09e3138c (patch) | |
tree | 53e44a127d23569828b71222e9b7a4588032f8a8 /modules-available/locationinfo | |
parent | [locationinfo] Detect config changes, tweak display colors (diff) | |
download | slx-admin-2382d53a3b6fda1a004f321c1eec049b09e3138c.tar.gz slx-admin-2382d53a3b6fda1a004f321c1eec049b09e3138c.tar.xz slx-admin-2382d53a3b6fda1a004f321c1eec049b09e3138c.zip |
[locationinfo] Update install script
Diffstat (limited to 'modules-available/locationinfo')
-rw-r--r-- | modules-available/locationinfo/install.inc.php | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/modules-available/locationinfo/install.inc.php b/modules-available/locationinfo/install.inc.php index 0dc29578..a738a863 100644 --- a/modules-available/locationinfo/install.inc.php +++ b/modules-available/locationinfo/install.inc.php @@ -6,11 +6,10 @@ $t1 = $res[] = tableCreate('locationinfo_locationconfig', ' `locationid` INT(11) NOT NULL, `serverid` INT(10) UNSIGNED, `serverlocationid` VARCHAR(150), - `hidden` BOOLEAN NOT NULL DEFAULT 0, `openingtime` BLOB, - `config` BLOB, `calendar` BLOB, - `lastcalendarupdate` INT(11) NOT NULL DEFAULT 0, + `lastcalendarupdate` INT(10) UNSIGNED NOT NULL DEFAULT 0, + `lastchange` int(10) UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (`locationid`) '); @@ -19,14 +18,42 @@ $t2 = $res[] = tableCreate('locationinfo_coursebackend', ' `servername` VARCHAR(200) NOT NULL, `servertype` VARCHAR(100) NOT NULL, `credentials` BLOB, - `error` VARCHAR(1000), + `error` VARCHAR(500), PRIMARY KEY (`serverid`) '); +$t3 = $res[] = tableCreate('locationinfo_panel', " + `paneluuid` char(36) CHARACTER SET ascii NOT NULL, + `panelname` varchar(30) NOT NULL, + `locationids` varchar(20) CHARACTER SET ascii NOT NULL, + `paneltype` enum('DEFAULT','SUMMARY') NOT NULL, + `panelconfig` blob NOT NULL, + `lastchange` int(10) UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY (`paneluuid`), + KEY `panelname` (`panelname`) +"); + // Update if ($t1 === UPDATE_NOOP) { + if ($t3 === UPDATE_DONE) { + // Upgrade from old beta version - convert panels + Database::exec('INSERT INTO locationinfo_panel (paneluuid, panelname, locationids, paneltype, panelconfig, lastchange)' + . " SELECT UUID(), Concat('Import: ', l.locationname), o.locationid, 'DEFAULT', o.config, 0 " + . " FROM locationinfo_locationconfig o INNER JOIN location l USING (locationid)" + . ' WHERE Length(o.config) > 10 OR Length(o.openingtime) > 10'); + } Database::exec("ALTER TABLE locationinfo_locationconfig CHANGE `serverid` `serverid` INT(10) UNSIGNED NULL"); + tableDropColumn('locationinfo_locationconfig', 'hidden'); + tableDropColumn('locationinfo_locationconfig', 'config'); + if (!tableHasColumn('locationinfo_locationconfig', 'lastchange')) { + $ret = Database::exec('ALTER TABLE locationinfo_locationconfig ADD `lastchange` INT(10) UNSIGNED NOT NULL DEFAULT 0'); + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Could not add lastchange field'); + } elseif ($ret > 0) { + $ret[] = UPDATE_DONE; + } + } } if ($t1 === UPDATE_DONE || $t2 === UPDATE_DONE) { Database::exec('UPDATE locationinfo_locationconfig SET serverid = NULL WHERE serverid = 0'); |