Add location to signal
This commit is contained in:
parent
fdab54a775
commit
c7c1c45008
3 changed files with 122 additions and 9 deletions
13
db/migrations/00120_signal_location.sql
Normal file
13
db/migrations/00120_signal_location.sql
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
-- +goose Up
|
||||
DELETE FROM signal;
|
||||
ALTER TABLE signal ADD COLUMN location Geometry(Geometry, 4326) NOT NULL;
|
||||
ALTER TABLE signal ADD COLUMN location_type TEXT GENERATED ALWAYS AS (GeometryType(location)) STORED;
|
||||
ALTER TABLE signal ADD CONSTRAINT valid_location_types
|
||||
CHECK (location_type IN ('POINT', 'POLYGON', 'MULTIPOLYGON'));
|
||||
CREATE INDEX idx_signal_location ON signal USING GIST(location);
|
||||
CREATE INDEX idx_signal_location_type ON signal(location_type);
|
||||
-- +goose Down
|
||||
ALTER TABLE signal DROP INDEX idx_signal_location_type;
|
||||
ALTER TABLE signal DROP INDEX idx_signal_location;
|
||||
ALTER TABLE signal DROP COLUMN location_type;
|
||||
ALTER TABLE signal DROP COLUMN location;
|
||||
Loading…
Add table
Add a link
Reference in a new issue