-
-
Notifications
You must be signed in to change notification settings - Fork 278
/
Copy pathinitdb-mobilitydb.sh
62 lines (57 loc) · 2.25 KB
/
initdb-mobilitydb.sh
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
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
echo "shared_preload_libraries = 'postgis-3.so'" >> $PGDATA/postgresql.conf
set -e
# Create the 'mobilitydb' extension in the mobilitydb database
echo "Loading MobilityDB extension into mobilitydb"
psql --user="$POSTGRES_USER" --dbname="mobilitydb" <<- 'EOSQL'
CREATE EXTENSION IF NOT EXISTS PostGIS;
CREATE EXTENSION IF NOT EXISTS mobilitydb CASCADE;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- Table collection
CREATE TABLE public.collection (
collection_id uuid NOT NULL DEFAULT uuid_generate_v4(),
collection_property jsonb NULL,
PRIMARY KEY (collection_id)
);
-- Table MovingFeature
CREATE TABLE public.mfeature (
collection_id uuid NOT NULL,
mfeature_id uuid NOT NULL DEFAULT uuid_generate_v4(),
mf_geometry geometry NULL,
mf_property jsonb NULL,
lifespan tstzspan NULL,
PRIMARY KEY (collection_id, mfeature_id),
FOREIGN KEY (collection_id) REFERENCES collection(collection_id)
);
-- Table TemporalGeometry
CREATE TABLE public.tgeometry (
collection_id uuid NOT NULL,
mfeature_id uuid NOT NULL,
tgeometry_id uuid NOT NULL DEFAULT uuid_generate_v4(),
tgeometry_property tgeompoint NULL,
tgeog_property tgeompoint NULL,
PRIMARY KEY (collection_id, mfeature_id, tgeometry_id),
FOREIGN KEY (collection_id, mfeature_id) REFERENCES mfeature(collection_id, mfeature_id)
);
-- Table TemporalProperty
CREATE TABLE public.tproperties (
collection_id uuid NOT NULL,
mfeature_id uuid NOT NULL,
tproperties_name text NOT NULL,
tproperty jsonb NULL,
PRIMARY KEY (collection_id, mfeature_id, tproperties_name),
FOREIGN KEY (collection_id, mfeature_id) REFERENCES mfeature(collection_id, mfeature_id)
);
-- Table TemporalPropertyValue
CREATE TABLE public.tvalue (
collection_id uuid NOT NULL,
mfeature_id uuid NOT NULL,
tproperties_name text NOT NULL,
tvalue_id uuid NOT NULL DEFAULT uuid_generate_v4(),
datetime_group int4 NOT NULL,
pvalue_float tfloat NULL,
pvalue_text ttext NULL,
PRIMARY KEY (collection_id, mfeature_id, tproperties_name, tvalue_id),
FOREIGN KEY (collection_id, mfeature_id, tproperties_name) REFERENCES tproperties(collection_id, mfeature_id, tproperties_name)
);
EOSQL