-
Notifications
You must be signed in to change notification settings - Fork 0
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
f8bf092
commit 293ce4f
Showing
4 changed files
with
30 additions
and
23 deletions.
There are no files selected for viewing
3 changes: 0 additions & 3 deletions
3
migrate/data/migrations/1701872471_initialise_schema.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 |
---|---|---|
@@ -1,9 +1,6 @@ | ||
-- Commented out the statements below as you never want to undo the initialise. | ||
-- DROP TABLE IF EXISTS users; | ||
-- DROP TABLE IF EXISTS observation; | ||
-- DROP TABLE IF EXISTS geo_point; | ||
-- -- not supported yet | ||
-- -- DROP TABLE IF EXISTS geo_polygon; | ||
-- DROP TABLE IF EXISTS time_series; | ||
-- DROP USER IF EXISTS db_user; | ||
-- DROP EXTENSION IF EXISTS postgis; |
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
7 changes: 7 additions & 0 deletions
7
migrate/data/not_supported_yet/1702281165_geo_polygon.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,7 @@ | ||
ALTER TABLE observation | ||
DROP COLUMN IF EXISTS geo_polygon_id, | ||
DROP COLUMN IF EXISTS obstime_start, -- obs time variant 2: interval | ||
DROP COLUMN IF EXISTS obstime_end, | ||
DROP CONSTRAINT IF EXISTS observation_chk_one_obs_time; | ||
|
||
DROP TABLE IF EXISTS geo_polygon; |
22 changes: 22 additions & 0 deletions
22
migrate/data/not_supported_yet/1702281165_geo_polygon.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,22 @@ | ||
-- not supported yet | ||
CREATE TABLE IF NOT EXISTS geo_polygon ( | ||
id BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY, | ||
polygon GEOGRAPHY(Polygon, 4326) NOT NULL | ||
); | ||
|
||
CREATE INDEX geo_polygon_idx ON geo_polygon USING GIST(polygon); | ||
|
||
------- BEGIN support both single instant and interval for obs time --------- | ||
-- TODO: Fix geo_polygon_id. How to fill the existing rows, otherwise column cannot be added | ||
-- ALTER TABLE observation | ||
-- ADD geo_polygon_id integer NOT NULL REFERENCES geo_polygon(id) ON DELETE CASCADE; -- not supported yet | ||
|
||
ALTER TABLE observation | ||
ADD obstime_start timestamptz, -- obs time variant 2: interval | ||
ADD obstime_end timestamptz, | ||
ADD CONSTRAINT observation_chk_one_obs_time | ||
CHECK ( -- ensure exactly one of [1] obstime_instant and [2] obstime_start/-end is defined | ||
((obstime_instant IS NOT NULL) AND (obstime_start IS NULL) AND (obstime_end IS NULL)) OR | ||
((obstime_instant IS NULL) AND (obstime_start IS NOT NULL) AND (obstime_end IS NOT NULL)) | ||
); | ||
------- END support both single instant and interval for obs time --------- |