summaryrefslogtreecommitdiffstats
path: root/modules-available/locations/install.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/locations/install.inc.php')
-rw-r--r--modules-available/locations/install.inc.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/modules-available/locations/install.inc.php b/modules-available/locations/install.inc.php
index d4e1b67b..31d53560 100644
--- a/modules-available/locations/install.inc.php
+++ b/modules-available/locations/install.inc.php
@@ -35,5 +35,27 @@ $res[] = tableAddConstraint('subnet', 'locationid', 'location', 'locationid',
$res[] = tableAddConstraint('setting_location', 'locationid', 'location', 'locationid',
'ON UPDATE CASCADE ON DELETE CASCADE');
+// Update
+
+// 2020-07-14 Add openingtime column to location table, then migrate data and delete the column from locationinfo
+
+if (!tableHasColumn('location', 'openingtime')) {
+ if (Database::exec("ALTER TABLE location ADD openingtime BLOB") === false) {
+ finalResponse(UPDATE_FAILED, 'Could not create openingtime column');
+ } else {
+ if (Module::get('locationinfo') !== false) {
+ if (Database::exec(
+ "UPDATE location, locationinfo_locationconfig
+ SET location.openingtime = locationinfo_locationconfig.openingtime
+ WHERE location.locationid = locationinfo_locationconfig.locationid") === false) {
+ finalResponse(UPDATE_FAILED, 'Could not migrate openingtime data from table to table');
+ }
+ if (Database::exec("ALTER TABLE locationinfo_locationconfig DROP COLUMN openingtime") === false) {
+ finalResponse(UPDATE_FAILED, 'Could not delete openingtime column');
+ }
+ }
+ }
+}
+
// Create response for browser
responseFromArray($res);