summaryrefslogtreecommitdiffstats
path: root/modules-available/sysconfig
diff options
context:
space:
mode:
authorSimon Rettberg2017-11-24 13:56:04 +0100
committerSimon Rettberg2017-11-24 13:56:04 +0100
commitdaa62c36e752cf7ff9fd80f06b9043fd0062e0e2 (patch)
tree110767e4886c14717fac855c3ad4aed75e0e9bd4 /modules-available/sysconfig
parent[runmode] Simplify installer (diff)
downloadslx-admin-daa62c36e752cf7ff9fd80f06b9043fd0062e0e2.tar.gz
slx-admin-daa62c36e752cf7ff9fd80f06b9043fd0062e0e2.tar.xz
slx-admin-daa62c36e752cf7ff9fd80f06b9043fd0062e0e2.zip
[sysconfig] Simplify installer, add constraint to location table
Diffstat (limited to 'modules-available/sysconfig')
-rw-r--r--modules-available/sysconfig/install.inc.php37
1 files changed, 20 insertions, 17 deletions
diff --git a/modules-available/sysconfig/install.inc.php b/modules-available/sysconfig/install.inc.php
index 91f282dd..251b3de9 100644
--- a/modules-available/sysconfig/install.inc.php
+++ b/modules-available/sysconfig/install.inc.php
@@ -39,21 +39,29 @@ $res[] = tableCreate('configtgz_location', "
// Constraints
if (in_array(UPDATE_DONE, $res)) {
- $ret = Database::exec("ALTER TABLE `configtgz_x_module`
- ADD CONSTRAINT `configtgz_x_module_ibfk_1` FOREIGN KEY (`configid`) REFERENCES `configtgz` (`configid`)
- ON DELETE CASCADE");
- $ret = Database::exec("ALTER TABLE `configtgz_x_module`
- ADD CONSTRAINT `configtgz_x_module_ibfk_2` FOREIGN KEY (`moduleid`) REFERENCES `configtgz_module` (`moduleid`)") || $ret;
- $ret = Database::exec("ALTER TABLE `configtgz_location`
- ADD CONSTRAINT `configtgz_location_fk_configid` FOREIGN KEY ( `configid` ) REFERENCES `openslx`.`configtgz` (`configid`)
- ON DELETE CASCADE ON UPDATE CASCADE") || $ret;
- if ($ret) {
- $res[] = UPDATE_DONE;
- }
+ // To self
+ $res[] = tableAddConstraint('configtgz_x_module', 'configid', 'configtgz', 'configid',
+ '');
+ $res[] = tableAddConstraint('configtgz_x_module', 'moduleid', 'configtgz_module', 'moduleid',
+ '');
+ $res[] = tableAddConstraint('configtgz_location', 'configid', 'configtgz', 'configid',
+ 'ON DELETE CASCADE ON UPDATE CASCADE');
+}
+// To location
+if (tableExists('location')) {
+ // Cleanup from when we didn't have the constraint
+ Database::exec("DELETE c FROM configtgz_location c
+ LEFT JOIN location l USING (locationid)
+ WHERE l.locationid IS NULL");
+ $res[] = tableAddConstraint('configtgz_location', 'locationid', 'location', 'locationid',
+ 'ON UPDATE CASCADE ON DELETE CASCADE');
+} elseif (Module::get('locations') !== false) {
+ $res[] = UPDATE_RETRY;
}
// Update path
+// #######################
// ##### 2014-12-12
// Rename config modules
Database::exec("UPDATE configtgz_module SET moduletype = 'Branding' WHERE moduletype = 'BRANDING'");
@@ -98,9 +106,4 @@ if ($list === false) {
}
// Create response for browser
-
-if (in_array(UPDATE_DONE, $res)) {
- finalResponse(UPDATE_DONE, 'Tables created successfully');
-}
-
-finalResponse(UPDATE_NOOP, 'Everything already up to date');
+responseFromArray($res);