-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f7cdb07
commit 6c4e886
Showing
4 changed files
with
70 additions
and
5 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
server/main-api/migrations/20240505224430_fix-calendar-id-not-extracted.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
-- Add down migration script here | ||
-- was never used | ||
create table rooms | ||
( | ||
key text primary key not null, | ||
tumonline_org_id integer not null, | ||
tumonline_calendar_id integer not null, | ||
tumonline_room_id integer not null, | ||
last_scrape timestamp without time zone not null | ||
); | ||
|
||
-- migrating to | ||
DROP TABLE en; | ||
create table en | ||
( | ||
key text not null | ||
primary key | ||
references de, | ||
name text not null, | ||
tumonline_room_nr integer, | ||
type text not null, | ||
type_common_name text not null, | ||
lat double precision not null, | ||
lon double precision not null, | ||
data text not null, | ||
last_calendar_scrape_at timestamp with time zone | ||
); | ||
comment on column en.last_calendar_scrape_at is 'the last time the calendar was scraped for this room'; | ||
|
||
DROP TABLE de; | ||
create table de | ||
( | ||
key text not null primary key, | ||
name text not null, | ||
tumonline_room_nr integer, | ||
type text not null, | ||
type_common_name text not null, | ||
lat double precision not null, | ||
lon double precision not null, | ||
data text not null, | ||
last_calendar_scrape_at timestamp with time zone | ||
); | ||
comment on column de.last_calendar_scrape_at is 'the last time the calendar was scraped for this room'; |
20 changes: 20 additions & 0 deletions
20
server/main-api/migrations/20240505224430_fix-calendar-id-not-extracted.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-- Add up migration script here | ||
-- was never used | ||
DROP TABLE rooms; | ||
|
||
-- migrating to using the json type instead of having elaborate insertion logic | ||
alter table de alter column data type json using data::json; | ||
|
||
alter table de drop column lat; | ||
alter table de add column lat FLOAT NOT NULL GENERATED ALWAYS AS (CAST (data->'coords'->>'lat' AS FLOAT)) STORED; | ||
alter table de drop column lon; | ||
alter table de add column lon FLOAT NOT NULL GENERATED ALWAYS AS (CAST (data->'coords'->>'lon' AS FLOAT)) STORED; | ||
alter table de drop column name; | ||
alter table de add column name TEXT NOT NULL GENERATED ALWAYS AS (CAST (data->>'name' AS TEXT)) STORED; | ||
alter table de drop column type_common_name; | ||
alter table de add column type_common_name TEXT NOT NULL GENERATED ALWAYS AS (CAST (data->>'type_common_name' AS TEXT)) STORED; | ||
alter table de drop column type; | ||
alter table de add column type TEXT NOT NULL GENERATED ALWAYS AS (CAST (data->>'type' AS TEXT)) STORED; | ||
alter table de drop column calendar_url; | ||
alter table de add column calendar_url TEXT GENERATED ALWAYS AS (CAST (data->'props'->>'calendar_url' AS TEXT)) STORED; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters