diff options
author | Simon Rettberg | 2016-09-07 19:13:24 +0200 |
---|---|---|
committer | Simon Rettberg | 2016-09-07 19:13:24 +0200 |
commit | 78c2407ba64007256f61328e2c58daa3bd49cd97 (patch) | |
tree | f2f05b1794a83e9c59782cf5b615fab0a3072feb /modules-available/roomplanner/install.inc.php | |
parent | [sysconfig] Confirm dialog for deletion; show success message after deleting ... (diff) | |
download | slx-admin-78c2407ba64007256f61328e2c58daa3bd49cd97.tar.gz slx-admin-78c2407ba64007256f61328e2c58daa3bd49cd97.tar.xz slx-admin-78c2407ba64007256f61328e2c58daa3bd49cd97.zip |
[roomplanner] Add managerip field, move mgr/tutor fields to location_roomplanner table, add to install.inc.php
Diffstat (limited to 'modules-available/roomplanner/install.inc.php')
-rw-r--r-- | modules-available/roomplanner/install.inc.php | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/modules-available/roomplanner/install.inc.php b/modules-available/roomplanner/install.inc.php index f20985d9..0a6c3729 100644 --- a/modules-available/roomplanner/install.inc.php +++ b/modules-available/roomplanner/install.inc.php @@ -3,12 +3,37 @@ $res = array(); -$res[] = tableCreate('location_roomplan', ' +$res[] = tableCreate('location_roomplan', " `locationid` INT(11) NOT NULL, + `managerip` varchar(45) CHARACTER SET ascii DEFAULT '', + `tutoruuid` char(36) CHARACTER SET ascii DEFAULT NULL, `roomplan` BLOB DEFAULT NULL, - PRIMARY KEY (`locationid`)'); + PRIMARY KEY (`locationid`), + KEY `tutoruuid` (`tutoruuid`)"); + +if (!tableHasColumn('location_roomplan', 'managerip')) { + $ret = Database::exec("ALTER TABLE `location_roomplan` ADD COLUMN `managerip` varchar(45) CHARACTER SET ascii DEFAULT '' AFTER locationid") !== false; + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Adding managerip to location_roomplan failed: ' . Database::lastError()); + } + $res[] = UPDATE_DONE; +} +if (!tableHasColumn('location_roomplan', 'tutoruuid')) { + $ret = Database::exec("ALTER TABLE `location_roomplan` ADD COLUMN `tutoruuid` char(36) CHARACTER SET ascii DEFAULT NULL AFTER managerip," + . " ADD KEY `tutoruuid` (`tutoruuid`)") !== false; + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Adding tutoruuid to location_roomplan failed: ' . Database::lastError()); + } + $res[] = UPDATE_DONE; +} +if (in_array(UPDATE_DONE, $res)) { + Database::exec("ALTER TABLE `location_roomplan` + ADD CONSTRAINT `location_roomplan_ibfk_1` FOREIGN KEY (`locationid`) REFERENCES `location` (`locationid`) ON DELETE CASCADE"); + Database::exec("ALTER TABLE `location_roomplan` + ADD CONSTRAINT `location_roomplan_ibfk_2` FOREIGN KEY (`tutoruuid`) REFERENCES `machine` (`machineuuid`) ON DELETE SET NULL ON UPDATE CASCADE"); +} if (in_array(UPDATE_DONE, $res)) { finalResponse(UPDATE_DONE, 'Table created successfully'); |