Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit 36340d5

Browse files
1 parent 64e1a1b commit 36340d5

1 file changed

Lines changed: 9 additions & 27 deletions

File tree

sormas-backend/src/main/resources/sql/sormas_schema.sql

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6179,20 +6179,11 @@ ALTER TABLE action_history ALTER COLUMN reply TYPE text;
61796179
INSERT INTO schema_version (version_number, comment) VALUES (301, 'Change action''s columns description and reply type from varchar to text #3848');
61806180

61816181
-- 2020-12-03 Remove hospital from event's type of place #3617
6182-
UPDATE location
6183-
SET facilitytype = 'HOSPITAL'
6184-
FROM location AS l
6185-
INNER JOIN events ON events.eventlocation_id = l.id
6186-
WHERE events.typeofplace = 'HOSPITAL'
6187-
AND l.facilitytype IS NULL;
6182+
-- 2021-01-28 [Hotfix] Fixed migration code setting facility type for all locations in the system #4120
6183+
UPDATE location SET facilitytype = 'HOSPITAL' WHERE facilitytype IS NULL AND (SELECT typeofplace FROM events WHERE eventlocation_id = location.id) = 'HOSPITAL';
6184+
UPDATE events SET typeofplace = 'FACILITY' WHERE (SELECT facilitytype FROM location WHERE id = events.eventlocation_id) IS NOT NULL;
61886185

6189-
UPDATE events
6190-
SET typeofplace = 'FACILITY'
6191-
FROM events as e
6192-
INNER JOIN location ON location.id = e.eventlocation_id
6193-
WHERE location.facilitytype IS NOT NULL;
6194-
6195-
INSERT INTO schema_version (version_number, comment) VALUES (302, 'Remove hospital from event''s type of place #3617');
6186+
INSERT INTO schema_version (version_number, comment) VALUES (302, 'Remove hospital from event''s type of place #3617, #4120');
61966187

61976188
-- 2020-01-11 SurvNet Adaptation - Dedicated fields for technical and non-technical external IDs #3524
61986189
ALTER TABLE cases ADD COLUMN externaltoken varchar(512);
@@ -6265,20 +6256,11 @@ CREATE INDEX IF NOT EXISTS idx_events_superordinateevent_id ON events USING hash
62656256
INSERT INTO schema_version (version_number, comment) VALUES (308, 'Add superordinate event to events #4020');
62666257

62676258
-- 2020-12-03 Remove hospital from exposure type of places #3680
6268-
UPDATE location
6269-
SET facilitytype = 'HOSPITAL'
6270-
FROM location AS l
6271-
INNER JOIN exposures ON exposures.location_id = l.id
6272-
WHERE exposures.typeofplace = 'HOSPITAL'
6273-
AND l.facilitytype IS NULL;
6274-
6275-
UPDATE exposures
6276-
SET typeofplace = 'FACILITY'
6277-
FROM exposures as e
6278-
INNER JOIN location ON location.id = e.location_id
6279-
WHERE location.facilitytype IS NOT NULL;
6280-
6281-
INSERT INTO schema_version (version_number, comment) VALUES (309, 'Remove hospital from exposure type of places #3680');
6259+
-- 2021-01-28 [Hotfix] Fixed migration code setting facility type for all locations in the system #4120
6260+
UPDATE location SET facilitytype = 'HOSPITAL' WHERE facilitytype IS NULL AND (SELECT typeofplace FROM exposures WHERE location_id = location.id) = 'HOSPITAL';
6261+
UPDATE exposures SET typeofplace = 'FACILITY' WHERE (SELECT facilitytype FROM location WHERE id = exposures.location_id) IS NOT NULL;
6262+
6263+
INSERT INTO schema_version (version_number, comment) VALUES (309, 'Remove hospital from exposure type of places #3680, #4120');
62826264

62836265
-- 2020-12-21 Fix labmessage table #3486
62846266
ALTER TABLE labmessage OWNER TO sormas_user;

0 commit comments

Comments
 (0)