forked from kartoza/osgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sql
More file actions
52 lines (37 loc) · 1.39 KB
/
setup.sql
File metadata and controls
52 lines (37 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
--
-- Setup API schema for push from ESP32 monitorinig device readings
--
-- psql -h localhost -p 15432 -U docker gis < setup.sql
--
CREATE SCHEMA api;
CREATE ROLE anon NOLOGIN;
GRANT USAGE ON SCHEMA api TO anon;
CREATE ROLE authenticator NOINHERIT LOGIN PASSWORD 'secret password';
GRANT anon TO authenticator;
ALTER SCHEMA api OWNER TO anon;
SELECT schema_name FROM information_schema.schemata;
-- In psql you can also liist schemas like this:
--\dn
create table api.monitoring (
id serial primary key,
device_id text not null,
reading_type text not null,
reading_unit text not null,
reading_value float not null,
reading_timestamp timestamptz default now()
);
ALTER TABLE api.monitoring OWNER TO anon;
insert into api.monitoring (device_id, reading_type, reading_unit, reading_value) values
('device0', 'temperature', 'celcius', 12.1),
('device1', 'temperature', 'celcius', 12.9)
;
grant usage on schema api to anon;
grant select on api.monitoring to anon;
grant usage on schema api to authenticator;
grant select on api.monitoring to authenticator;
-- Test with https://castelo.kartoza.com/api/monitoring
-- PG RASTER Support for all gdal drivers
-- See https://postgis.net/docs/postgis_gdal_enabled_drivers.html
ALTER DATABASE gis SET postgis.gdal_enabled_drivers TO 'ENABLE_ALL';
-- And support out of DB rasters
ALTER DATABASE gis SET postgis.enable_outdb_rasters = true;