Skip to content

Commit

Permalink
Update data.sql with unblurred_sites table and trigger to update geom
Browse files Browse the repository at this point in the history
  • Loading branch information
pclastre committed Aug 17, 2020
1 parent 6eceb5b commit cd2e5a2
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,47 @@ CREATE TABLE IF NOT EXISTS profile_specifications(
updatedAt timestamp
);

CREATE TABLE unblurred_sites
(
id integer NOT NULL,
userid integer NOT NULL,
x real NOT NULL,
y real NOT NULL,
geom geometry,
blurring_rule character(30) COLLATE pg_catalog."default" NOT NULL,
new_point boolean
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;

COMMENT ON TABLE unblurred_sites
IS 'Spatial table containing unblurred coordinates';

CREATE OR REPLACE FUNCTION add_geom_from_x_y()
RETURNS TRIGGER
LANGUAGE PLPGSQL
AS $add_geom_from_x_y$
BEGIN
IF NEW.new_point=true THEN
UPDATE unblurred_sites SET
new_point=false,
geom = ST_SetSRID(ST_MakePoint(NEW.x, NEW.y), 4326)
WHERE id=NEW.id;
END IF;
RETURN NEW;
END;
$add_geom_from_x_y$ ;

DROP TRIGGER IF EXISTS tr_add_geom on unblurred_sites;
CREATE TRIGGER tr_add_geom
AFTER INSERT
ON unblurred_sites
FOR EACH ROW
EXECUTE PROCEDURE add_geom_from_x_y();


\connect keycloak

update REALM set ssl_required = 'NONE' where id = 'master';
Expand Down

0 comments on commit cd2e5a2

Please sign in to comment.