summaryrefslogtreecommitdiffstats
path: root/modules-available/locations
diff options
context:
space:
mode:
authorSimon Rettberg2020-09-11 14:38:30 +0200
committerSimon Rettberg2020-09-11 14:38:30 +0200
commitc2aa47f3cfbfb994439328dd7c045645d08ce4b0 (patch)
tree15bcf027d4fdd0ec6da3be91757346bc1977e6ef /modules-available/locations
parent[locationinfo] Always use cached data if backend fails (diff)
downloadslx-admin-c2aa47f3cfbfb994439328dd7c045645d08ce4b0.tar.gz
slx-admin-c2aa47f3cfbfb994439328dd7c045645d08ce4b0.tar.xz
slx-admin-c2aa47f3cfbfb994439328dd7c045645d08ce4b0.zip
[locations] install: Make openingtime migration a bit more robust
This decouples column creation in location table from checking existence of the old column in locationinfo_locationconfig. In case import fails the first time, this will simply "resume" the update in case it is triggered a second time.
Diffstat (limited to 'modules-available/locations')
-rw-r--r--modules-available/locations/install.inc.php28
1 files changed, 15 insertions, 13 deletions
diff --git a/modules-available/locations/install.inc.php b/modules-available/locations/install.inc.php
index 9a232829..5664c7ed 100644
--- a/modules-available/locations/install.inc.php
+++ b/modules-available/locations/install.inc.php
@@ -15,6 +15,7 @@ $res[] = tableCreate('location', '
`locationid` INT(11) NOT NULL AUTO_INCREMENT,
`parentlocationid` INT(11) NOT NULL,
`locationname` VARCHAR(100) NOT NULL,
+ `openingtime` BLOB,
PRIMARY KEY (`locationid`),
KEY `locationname` (`locationname`),
KEY `parentlocationid` (`parentlocationid`)
@@ -38,24 +39,25 @@ $res[] = tableAddConstraint('setting_location', 'locationid', 'location', 'locat
// 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
+ }
+ $res[] = UPDATE_DONE;
+}
+if (tableHasColumn('locationinfo_locationconfig', 'openingtime')) {
+ 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');
- }
- $res[] = UPDATE_DONE;
- }
+ WHERE location.locationid = locationinfo_locationconfig.locationid
+ AND Length(location.openingtime) < 5
+ AND Length(locationinfo_locationconfig.openingtime) > 5") === 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 old openingtime column');
}
+ $res[] = UPDATE_DONE;
}
// Create response for browser