-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgpx_tables.sql
330 lines (238 loc) · 9.44 KB
/
gpx_tables.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
--
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
CREATE TYPE user_status_enum AS ENUM (
'pending',
'active',
'confirmed',
'suspended',
'deleted'
);
CREATE TYPE gpx_visibility_enum AS ENUM (
'private',
'public',
'trackable',
'identifiable'
);
CREATE TABLE users (
id bigint NOT NULL,
display_name character varying(255) DEFAULT ''::character varying NOT NULL,
status user_status_enum DEFAULT 'pending'::user_status_enum NOT NULL
);
ALTER TABLE public.users OWNER TO openstreetmap;
ALTER TABLE ONLY users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
--
-- Name: gps_points; Type: TABLE; Schema: public; Owner: openstreetmap; Tablespace:
--
CREATE TABLE gps_points (
altitude double precision,
trackid integer NOT NULL,
latitude integer NOT NULL,
longitude integer NOT NULL,
gpx_id bigint NOT NULL,
"timestamp" timestamp without time zone,
tile bigint
);
--
-- Name: gpx_file_tags; Type: TABLE; Schema: public; Owner: openstreetmap; Tablespace:
--
CREATE TABLE gpx_file_tags (
gpx_id bigint DEFAULT 0 NOT NULL,
tag character varying(255) NOT NULL,
id bigint NOT NULL
);
ALTER TABLE public.gpx_file_tags OWNER TO openstreetmap;
--
-- Name: gpx_file_tags_id_seq; Type: SEQUENCE; Schema: public; Owner: openstreetmap
--
CREATE SEQUENCE gpx_file_tags_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.gpx_file_tags_id_seq OWNER TO openstreetmap;
--
-- Name: gpx_file_tags_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: openstreetmap
--
ALTER SEQUENCE gpx_file_tags_id_seq OWNED BY gpx_file_tags.id;
--
-- Name: gpx_files; Type: TABLE; Schema: public; Owner: openstreetmap; Tablespace:
--
CREATE TABLE gpx_files (
id bigint NOT NULL,
user_id bigint NOT NULL,
visible boolean DEFAULT true NOT NULL,
name character varying(255) DEFAULT ''::character varying NOT NULL,
size bigint,
latitude double precision,
longitude double precision,
"timestamp" timestamp without time zone NOT NULL,
description character varying(255) DEFAULT ''::character varying NOT NULL,
inserted boolean NOT NULL,
visibility gpx_visibility_enum DEFAULT 'public'::gpx_visibility_enum NOT NULL
);
ALTER TABLE public.gpx_files OWNER TO openstreetmap;
--
-- Name: gpx_files_id_seq; Type: SEQUENCE; Schema: public; Owner: openstreetmap
--
CREATE SEQUENCE gpx_files_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.gpx_files_id_seq OWNER TO openstreetmap;
--
-- Name: gpx_files_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: openstreetmap
--
ALTER SEQUENCE gpx_files_id_seq OWNED BY gpx_files.id;
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: openstreetmap
--
ALTER TABLE ONLY gpx_file_tags ALTER COLUMN id SET DEFAULT nextval('gpx_file_tags_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: openstreetmap
--
ALTER TABLE ONLY gpx_files ALTER COLUMN id SET DEFAULT nextval('gpx_files_id_seq'::regclass);
--
-- Name: gpx_file_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: openstreetmap; Tablespace:
--
ALTER TABLE ONLY gpx_file_tags
ADD CONSTRAINT gpx_file_tags_pkey PRIMARY KEY (id);
--
-- Name: gpx_files_pkey; Type: CONSTRAINT; Schema: public; Owner: openstreetmap; Tablespace:
--
ALTER TABLE ONLY gpx_files
ADD CONSTRAINT gpx_files_pkey PRIMARY KEY (id);
--
-- Name: gpx_file_tags_gpxid_idx; Type: INDEX; Schema: public; Owner: openstreetmap; Tablespace:
--
CREATE INDEX gpx_file_tags_gpxid_idx ON gpx_file_tags USING btree (gpx_id);
--
-- Name: gpx_file_tags_tag_idx; Type: INDEX; Schema: public; Owner: openstreetmap; Tablespace:
--
CREATE INDEX gpx_file_tags_tag_idx ON gpx_file_tags USING btree (tag);
--
-- Name: gpx_files_timestamp_idx; Type: INDEX; Schema: public; Owner: openstreetmap; Tablespace:
--
CREATE INDEX gpx_files_timestamp_idx ON gpx_files USING btree ("timestamp");
--
-- Name: gpx_files_user_id_idx; Type: INDEX; Schema: public; Owner: openstreetmap; Tablespace:
--
CREATE INDEX gpx_files_user_id_idx ON gpx_files USING btree (user_id);
--
-- Name: gpx_files_visible_visibility_idx; Type: INDEX; Schema: public; Owner: openstreetmap; Tablespace:
--
CREATE INDEX gpx_files_visible_visibility_idx ON gpx_files USING btree (visible, visibility);
--
-- Name: points_gpxid_idx; Type: INDEX; Schema: public; Owner: openstreetmap; Tablespace:
--
CREATE INDEX points_gpxid_idx ON gps_points USING btree (gpx_id);
--
-- Name: points_tile_idx; Type: INDEX; Schema: public; Owner: openstreetmap; Tablespace:
--
CREATE INDEX points_tile_idx ON gps_points USING btree (tile);
--
-- Name: gps_points_gpx_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: openstreetmap
--
ALTER TABLE ONLY gps_points
ADD CONSTRAINT gps_points_gpx_id_fkey FOREIGN KEY (gpx_id) REFERENCES gpx_files(id);
--
-- Name: gpx_file_tags_gpx_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: openstreetmap
--
ALTER TABLE ONLY gpx_file_tags
ADD CONSTRAINT gpx_file_tags_gpx_id_fkey FOREIGN KEY (gpx_id) REFERENCES gpx_files(id);
--
-- Name: gpx_files_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: openstreetmap
--
ALTER TABLE ONLY gpx_files
ADD CONSTRAINT gpx_files_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
--
-- Name: gps_points; Type: ACL; Schema: public; Owner: openstreetmap
--
REVOKE ALL ON TABLE gps_points FROM PUBLIC;
REVOKE ALL ON TABLE gps_points FROM openstreetmap;
GRANT ALL ON TABLE gps_points TO openstreetmap;
--
-- Name: gpx_file_tags; Type: ACL; Schema: public; Owner: openstreetmap
--
REVOKE ALL ON TABLE gpx_file_tags FROM PUBLIC;
REVOKE ALL ON TABLE gpx_file_tags FROM openstreetmap;
GRANT ALL ON TABLE gpx_file_tags TO openstreetmap;
--
-- Name: gpx_file_tags_id_seq; Type: ACL; Schema: public; Owner: openstreetmap
--
REVOKE ALL ON SEQUENCE gpx_file_tags_id_seq FROM PUBLIC;
REVOKE ALL ON SEQUENCE gpx_file_tags_id_seq FROM openstreetmap;
GRANT ALL ON SEQUENCE gpx_file_tags_id_seq TO openstreetmap;
--
-- Name: gpx_files; Type: ACL; Schema: public; Owner: openstreetmap
--
REVOKE ALL ON TABLE gpx_files FROM PUBLIC;
REVOKE ALL ON TABLE gpx_files FROM openstreetmap;
GRANT ALL ON TABLE gpx_files TO openstreetmap;
--
-- Name: gpx_files_id_seq; Type: ACL; Schema: public; Owner: openstreetmap
--
REVOKE ALL ON SEQUENCE gpx_files_id_seq FROM PUBLIC;
REVOKE ALL ON SEQUENCE gpx_files_id_seq FROM openstreetmap;
GRANT ALL ON SEQUENCE gpx_files_id_seq TO openstreetmap;
--
-- PostgreSQL database dump complete
--
--- Insert some test data.
INSERT INTO users (id, display_name, status) VALUES
(100, 'abcdefg', 'pending'),
(200, 'hijklmn', 'active'),
(300, 'opqrstu', 'confirmed'),
(400, 'vwxyz22', 'deleted'),
(500, 'überman', 'active');
INSERT INTO gpx_files (id,user_id,visible,name,size,latitude,longitude,"timestamp",description,inserted,visibility) VALUES
(10,100,true,'trace a',1500,45.0,-90.0,'2013-01-01T22:00:00Z','trace a desc',true,'public'),
(11,200,true,'trace b',1500,45.1,-90.1,'2013-01-02T23:30:00Z','trace b desc',true,'identifiable'),
(12,300,true,'trace c',1500,45.1,-90.1,'2013-01-02T21:30:00Z','trace c desc',true,'trackable'),
(13,400,true,'trace d',1500,45.1,-90.1,'2013-01-02T20:30:00Z','trace d desc',true,'private'),
(14,500,true,'trace å∫ç∂郩ü!',1500,45.1,-90.1,'2013-01-02T20:30:00Z','trace å∫ç∂郩ü!<>/',true,'trackable')
;
INSERT INTO gps_points (gpx_id,trackid,"timestamp",tile,latitude,longitude,altitude) VALUES
(10,1,'2013-01-01T22:00:00Z',0,451234567,-911234567,45.2),
(10,1,'2013-01-01T22:00:01Z',0,452234567,-912234567,45.6),
(10,2,'2013-01-01T22:00:00Z',0,461234567,-901234567,46.2),
(10,2,'2013-01-01T22:00:01Z',0,462234567,-902234567,46.5);
INSERT INTO gps_points (gpx_id,trackid,"timestamp",tile,latitude,longitude,altitude) VALUES
(11,1,'2013-01-01T22:00:00Z',0,451234567,-911234567,45.2),
(11,1,'2013-01-01T22:00:01Z',0,452234567,-912234567,45.6),
(11,2,'2013-01-01T22:00:00Z',0,461234567,-901234567,46.2),
(11,2,'2013-01-01T22:00:01Z',0,462234567,-902234567,46.5);
INSERT INTO gps_points (gpx_id,trackid,"timestamp",tile,latitude,longitude,altitude) VALUES
(12,1,'2013-01-01T22:00:00Z',0,451234567,-911234567,45.2),
(12,1,'2013-01-01T22:00:01Z',0,452234567,-912234567,45.6),
(12,2,'2013-01-01T22:00:00Z',0,461234567,-901234567,46.2),
(12,2,'2013-01-01T22:00:01Z',0,462234567,-902234567,46.5);
INSERT INTO gps_points (gpx_id,trackid,"timestamp",tile,latitude,longitude,altitude) VALUES
(13,1,'2013-01-01T22:00:00Z',0,451234567,-911234567,45.2),
(13,1,'2013-01-01T22:00:01Z',0,452234567,-912234567,45.6),
(13,2,'2013-01-01T22:00:00Z',0,461234567,-901234567,46.2),
(13,2,'2013-01-01T22:00:01Z',0,462234567,-902234567,46.5);
INSERT INTO gps_points (gpx_id,trackid,"timestamp",tile,latitude,longitude,altitude) VALUES
(14,1,'2013-01-01T22:00:00Z',0,451234567,-911234567,45.2),
(14,1,'2013-01-01T22:00:01Z',0,452234567,-912234567,45.6),
(14,2,'2013-01-01T22:00:00Z',0,461234567,-901234567,46.2),
(14,2,'2013-01-01T22:00:01Z',0,462234567,-902234567,46.5),
(14,3,'0036-11-04 15:12:36',0,462234567,-902234567,46.5),
(14,3,'40036-11-04 15:12:36',0,462234567,-902234567,46.5),
(14,3,'0001-11-04 15:51:23 BC',0,462234567,-902234567,46.5);
INSERT INTO gpx_file_tags (gpx_id,tag) VALUES
(10,'tag a'),
(11,'tag b'),
(14,'tag ü'||chr(19)||chr(19));