-
Notifications
You must be signed in to change notification settings - Fork 0
/
DB.sql
114 lines (83 loc) · 2.91 KB
/
DB.sql
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
-- DROP TABLE public.scooters;
CREATE TABLE IF NOT EXISTS public.scooters
(
uuid character varying(36) COLLATE pg_catalog."default" NOT NULL,
occupied boolean NOT NULL,
lat double precision NOT NULL,
lon double precision NOT NULL,
last_update timestamp without time zone NOT NULL,
CONSTRAINT scooters_pkey PRIMARY KEY (uuid)
)
TABLESPACE pg_default;
-- DROP INDEX public.lat;
CREATE INDEX lat
ON public.scooters USING btree
(lat ASC NULLS LAST)
TABLESPACE pg_default;
-- Index: lon
-- DROP INDEX public.lon;
CREATE INDEX lon
ON public.scooters USING btree
(lon ASC NULLS LAST)
TABLESPACE pg_default;
-- Index: occupied
-- DROP INDEX public.occupied;
CREATE INDEX occupied
ON public.scooters USING btree
(occupied ASC NULLS LAST)
TABLESPACE pg_default;
------------------------------------------
-- DROP TABLE public.trips;
CREATE TABLE IF NOT EXISTS public.trips
(
uuid character varying(36) COLLATE pg_catalog."default" NOT NULL,
scooter_uuid character varying(36) COLLATE pg_catalog."default" NOT NULL,
user_uuid character varying(36) COLLATE pg_catalog."default" NOT NULL,
start_lat double precision NOT NULL,
start_lon double precision NOT NULL,
start_time timestamp without time zone NOT NULL,
end_lat double precision,
end_lon double precision,
end_time timestamp without time zone,
CONSTRAINT trips_pkey PRIMARY KEY (uuid)
)
TABLESPACE pg_default;
-- DROP INDEX public.scooter_uuid;
CREATE INDEX scooter_uuid
ON public.trips USING btree
(scooter_uuid COLLATE pg_catalog."default" ASC NULLS LAST)
TABLESPACE pg_default;
-- Index: user_uuid
-- DROP INDEX public.user_uuid;
CREATE INDEX user_uuid
ON public.trips USING btree
(user_uuid COLLATE pg_catalog."default" ASC NULLS LAST)
TABLESPACE pg_default;
------------------------------------------
-- DROP TABLE public.clients;
CREATE TABLE IF NOT EXISTS public.clients
(
uuid character varying(36) COLLATE pg_catalog."default" NOT NULL,
name character varying(255) COLLATE pg_catalog."default" NOT NULL,
CONSTRAINT clients_pkey PRIMARY KEY (uuid)
)
TABLESPACE pg_default;
------------------------------------------
--DROP TABLE public.tracking;
CREATE TABLE IF NOT EXISTS public.tracking
(
row_id bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 9223372036854775807 CACHE 1 ),
scooter_uuid character varying(36) COLLATE pg_catalog."default" NOT NULL,
lat double precision NOT NULL,
lon double precision NOT NULL,
"time" timestamp without time zone NOT NULL,
CONSTRAINT tracking_pkey PRIMARY KEY (row_id)
)
TABLESPACE pg_default;
-- Index: scooter_uuid_indx
-- DROP INDEX public.scooter_uuid_indx;
CREATE INDEX scooter_uuid_indx
ON public.tracking USING btree
(scooter_uuid COLLATE pg_catalog."default" ASC NULLS LAST)
TABLESPACE pg_default;
------------------------------------------