]> git.openstreetmap.org Git - rails.git/blob - db/structure.sql
eaf279f9c933cb72087bd688aee5a632e01e6dcd
[rails.git] / db / structure.sql
1 --
2 -- PostgreSQL database dump
3 --
4
5 SET statement_timeout = 0;
6 SET client_encoding = 'UTF8';
7 SET standard_conforming_strings = on;
8 SET check_function_bodies = false;
9 SET client_min_messages = warning;
10
11 --
12 -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
13 --
14
15 CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
16
17
18 --
19 -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -
20 --
21
22 COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
23
24
25 --
26 -- Name: btree_gist; Type: EXTENSION; Schema: -; Owner: -
27 --
28
29 CREATE EXTENSION IF NOT EXISTS btree_gist WITH SCHEMA public;
30
31
32 --
33 -- Name: EXTENSION btree_gist; Type: COMMENT; Schema: -; Owner: -
34 --
35
36 COMMENT ON EXTENSION btree_gist IS 'support for indexing common datatypes in GiST';
37
38
39 SET search_path = public, pg_catalog;
40
41 --
42 -- Name: format_enum; Type: TYPE; Schema: public; Owner: -
43 --
44
45 CREATE TYPE format_enum AS ENUM (
46     'html',
47     'markdown',
48     'text'
49 );
50
51
52 --
53 -- Name: gpx_visibility_enum; Type: TYPE; Schema: public; Owner: -
54 --
55
56 CREATE TYPE gpx_visibility_enum AS ENUM (
57     'private',
58     'public',
59     'trackable',
60     'identifiable'
61 );
62
63
64 --
65 -- Name: note_event_enum; Type: TYPE; Schema: public; Owner: -
66 --
67
68 CREATE TYPE note_event_enum AS ENUM (
69     'opened',
70     'closed',
71     'reopened',
72     'commented',
73     'hidden'
74 );
75
76
77 --
78 -- Name: note_status_enum; Type: TYPE; Schema: public; Owner: -
79 --
80
81 CREATE TYPE note_status_enum AS ENUM (
82     'open',
83     'closed',
84     'hidden'
85 );
86
87
88 --
89 -- Name: nwr_enum; Type: TYPE; Schema: public; Owner: -
90 --
91
92 CREATE TYPE nwr_enum AS ENUM (
93     'Node',
94     'Way',
95     'Relation'
96 );
97
98
99 --
100 -- Name: user_role_enum; Type: TYPE; Schema: public; Owner: -
101 --
102
103 CREATE TYPE user_role_enum AS ENUM (
104     'administrator',
105     'moderator'
106 );
107
108
109 --
110 -- Name: user_status_enum; Type: TYPE; Schema: public; Owner: -
111 --
112
113 CREATE TYPE user_status_enum AS ENUM (
114     'pending',
115     'active',
116     'confirmed',
117     'suspended',
118     'deleted'
119 );
120
121
122 --
123 -- Name: maptile_for_point(bigint, bigint, integer); Type: FUNCTION; Schema: public; Owner: -
124 --
125
126 CREATE FUNCTION maptile_for_point(bigint, bigint, integer) RETURNS integer
127     LANGUAGE c STRICT
128     AS '/srv/www/notes.osm.compton.nu/db/functions/libpgosm.so', 'maptile_for_point';
129
130
131 --
132 -- Name: tile_for_point(integer, integer); Type: FUNCTION; Schema: public; Owner: -
133 --
134
135 CREATE FUNCTION tile_for_point(integer, integer) RETURNS bigint
136     LANGUAGE c STRICT
137     AS '/srv/www/notes.osm.compton.nu/db/functions/libpgosm.so', 'tile_for_point';
138
139
140 --
141 -- Name: xid_to_int4(xid); Type: FUNCTION; Schema: public; Owner: -
142 --
143
144 CREATE FUNCTION xid_to_int4(xid) RETURNS integer
145     LANGUAGE c IMMUTABLE STRICT
146     AS '/srv/www/notes.osm.compton.nu/db/functions/libpgosm.so', 'xid_to_int4';
147
148
149 SET default_tablespace = '';
150
151 SET default_with_oids = false;
152
153 --
154 -- Name: acls; Type: TABLE; Schema: public; Owner: -; Tablespace: 
155 --
156
157 CREATE TABLE acls (
158     id integer NOT NULL,
159     address inet,
160     k character varying(255) NOT NULL,
161     v character varying(255),
162     domain character varying(255)
163 );
164
165
166 --
167 -- Name: acls_id_seq; Type: SEQUENCE; Schema: public; Owner: -
168 --
169
170 CREATE SEQUENCE acls_id_seq
171     START WITH 1
172     INCREMENT BY 1
173     NO MINVALUE
174     NO MAXVALUE
175     CACHE 1;
176
177
178 --
179 -- Name: acls_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
180 --
181
182 ALTER SEQUENCE acls_id_seq OWNED BY acls.id;
183
184
185 --
186 -- Name: changeset_tags; Type: TABLE; Schema: public; Owner: -; Tablespace: 
187 --
188
189 CREATE TABLE changeset_tags (
190     changeset_id bigint NOT NULL,
191     k character varying(255) DEFAULT ''::character varying NOT NULL,
192     v character varying(255) DEFAULT ''::character varying NOT NULL
193 );
194
195
196 --
197 -- Name: changesets; Type: TABLE; Schema: public; Owner: -; Tablespace: 
198 --
199
200 CREATE TABLE changesets (
201     id bigint NOT NULL,
202     user_id bigint NOT NULL,
203     created_at timestamp without time zone NOT NULL,
204     min_lat integer,
205     max_lat integer,
206     min_lon integer,
207     max_lon integer,
208     closed_at timestamp without time zone NOT NULL,
209     num_changes integer DEFAULT 0 NOT NULL
210 );
211
212
213 --
214 -- Name: changesets_id_seq; Type: SEQUENCE; Schema: public; Owner: -
215 --
216
217 CREATE SEQUENCE changesets_id_seq
218     START WITH 1
219     INCREMENT BY 1
220     NO MINVALUE
221     NO MAXVALUE
222     CACHE 1;
223
224
225 --
226 -- Name: changesets_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
227 --
228
229 ALTER SEQUENCE changesets_id_seq OWNED BY changesets.id;
230
231
232 --
233 -- Name: client_applications; Type: TABLE; Schema: public; Owner: -; Tablespace: 
234 --
235
236 CREATE TABLE client_applications (
237     id integer NOT NULL,
238     name character varying(255),
239     url character varying(255),
240     support_url character varying(255),
241     callback_url character varying(255),
242     key character varying(50),
243     secret character varying(50),
244     user_id integer,
245     created_at timestamp without time zone NOT NULL,
246     updated_at timestamp without time zone NOT NULL,
247     allow_read_prefs boolean DEFAULT false NOT NULL,
248     allow_write_prefs boolean DEFAULT false NOT NULL,
249     allow_write_diary boolean DEFAULT false NOT NULL,
250     allow_write_api boolean DEFAULT false NOT NULL,
251     allow_read_gpx boolean DEFAULT false NOT NULL,
252     allow_write_gpx boolean DEFAULT false NOT NULL
253 );
254
255
256 --
257 -- Name: client_applications_id_seq; Type: SEQUENCE; Schema: public; Owner: -
258 --
259
260 CREATE SEQUENCE client_applications_id_seq
261     START WITH 1
262     INCREMENT BY 1
263     NO MINVALUE
264     NO MAXVALUE
265     CACHE 1;
266
267
268 --
269 -- Name: client_applications_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
270 --
271
272 ALTER SEQUENCE client_applications_id_seq OWNED BY client_applications.id;
273
274
275 --
276 -- Name: countries; Type: TABLE; Schema: public; Owner: -; Tablespace: 
277 --
278
279 CREATE TABLE countries (
280     id integer NOT NULL,
281     code character varying(2) NOT NULL,
282     min_lat double precision NOT NULL,
283     max_lat double precision NOT NULL,
284     min_lon double precision NOT NULL,
285     max_lon double precision NOT NULL
286 );
287
288
289 --
290 -- Name: countries_id_seq; Type: SEQUENCE; Schema: public; Owner: -
291 --
292
293 CREATE SEQUENCE countries_id_seq
294     START WITH 1
295     INCREMENT BY 1
296     NO MINVALUE
297     NO MAXVALUE
298     CACHE 1;
299
300
301 --
302 -- Name: countries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
303 --
304
305 ALTER SEQUENCE countries_id_seq OWNED BY countries.id;
306
307
308 --
309 -- Name: current_node_tags; Type: TABLE; Schema: public; Owner: -; Tablespace: 
310 --
311
312 CREATE TABLE current_node_tags (
313     node_id bigint NOT NULL,
314     k character varying(255) DEFAULT ''::character varying NOT NULL,
315     v character varying(255) DEFAULT ''::character varying NOT NULL
316 );
317
318
319 --
320 -- Name: current_nodes; Type: TABLE; Schema: public; Owner: -; Tablespace: 
321 --
322
323 CREATE TABLE current_nodes (
324     id bigint NOT NULL,
325     latitude integer NOT NULL,
326     longitude integer NOT NULL,
327     changeset_id bigint NOT NULL,
328     visible boolean NOT NULL,
329     "timestamp" timestamp without time zone NOT NULL,
330     tile bigint NOT NULL,
331     version bigint NOT NULL
332 );
333
334
335 --
336 -- Name: current_nodes_id_seq; Type: SEQUENCE; Schema: public; Owner: -
337 --
338
339 CREATE SEQUENCE current_nodes_id_seq
340     START WITH 1
341     INCREMENT BY 1
342     NO MINVALUE
343     NO MAXVALUE
344     CACHE 1;
345
346
347 --
348 -- Name: current_nodes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
349 --
350
351 ALTER SEQUENCE current_nodes_id_seq OWNED BY current_nodes.id;
352
353
354 --
355 -- Name: current_relation_members; Type: TABLE; Schema: public; Owner: -; Tablespace: 
356 --
357
358 CREATE TABLE current_relation_members (
359     relation_id bigint NOT NULL,
360     member_type nwr_enum NOT NULL,
361     member_id bigint NOT NULL,
362     member_role character varying(255) NOT NULL,
363     sequence_id integer DEFAULT 0 NOT NULL
364 );
365
366
367 --
368 -- Name: current_relation_tags; Type: TABLE; Schema: public; Owner: -; Tablespace: 
369 --
370
371 CREATE TABLE current_relation_tags (
372     relation_id bigint NOT NULL,
373     k character varying(255) DEFAULT ''::character varying NOT NULL,
374     v character varying(255) DEFAULT ''::character varying NOT NULL
375 );
376
377
378 --
379 -- Name: current_relations; Type: TABLE; Schema: public; Owner: -; Tablespace: 
380 --
381
382 CREATE TABLE current_relations (
383     id bigint NOT NULL,
384     changeset_id bigint NOT NULL,
385     "timestamp" timestamp without time zone NOT NULL,
386     visible boolean NOT NULL,
387     version bigint NOT NULL
388 );
389
390
391 --
392 -- Name: current_relations_id_seq; Type: SEQUENCE; Schema: public; Owner: -
393 --
394
395 CREATE SEQUENCE current_relations_id_seq
396     START WITH 1
397     INCREMENT BY 1
398     NO MINVALUE
399     NO MAXVALUE
400     CACHE 1;
401
402
403 --
404 -- Name: current_relations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
405 --
406
407 ALTER SEQUENCE current_relations_id_seq OWNED BY current_relations.id;
408
409
410 --
411 -- Name: current_way_nodes; Type: TABLE; Schema: public; Owner: -; Tablespace: 
412 --
413
414 CREATE TABLE current_way_nodes (
415     way_id bigint NOT NULL,
416     node_id bigint NOT NULL,
417     sequence_id bigint NOT NULL
418 );
419
420
421 --
422 -- Name: current_way_tags; Type: TABLE; Schema: public; Owner: -; Tablespace: 
423 --
424
425 CREATE TABLE current_way_tags (
426     way_id bigint NOT NULL,
427     k character varying(255) DEFAULT ''::character varying NOT NULL,
428     v character varying(255) DEFAULT ''::character varying NOT NULL
429 );
430
431
432 --
433 -- Name: current_ways; Type: TABLE; Schema: public; Owner: -; Tablespace: 
434 --
435
436 CREATE TABLE current_ways (
437     id bigint NOT NULL,
438     changeset_id bigint NOT NULL,
439     "timestamp" timestamp without time zone NOT NULL,
440     visible boolean NOT NULL,
441     version bigint NOT NULL
442 );
443
444
445 --
446 -- Name: current_ways_id_seq; Type: SEQUENCE; Schema: public; Owner: -
447 --
448
449 CREATE SEQUENCE current_ways_id_seq
450     START WITH 1
451     INCREMENT BY 1
452     NO MINVALUE
453     NO MAXVALUE
454     CACHE 1;
455
456
457 --
458 -- Name: current_ways_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
459 --
460
461 ALTER SEQUENCE current_ways_id_seq OWNED BY current_ways.id;
462
463
464 --
465 -- Name: diary_comments; Type: TABLE; Schema: public; Owner: -; Tablespace: 
466 --
467
468 CREATE TABLE diary_comments (
469     id bigint NOT NULL,
470     diary_entry_id bigint NOT NULL,
471     user_id bigint NOT NULL,
472     body text NOT NULL,
473     created_at timestamp without time zone NOT NULL,
474     updated_at timestamp without time zone NOT NULL,
475     visible boolean DEFAULT true NOT NULL,
476     body_format format_enum DEFAULT 'html'::format_enum NOT NULL
477 );
478
479
480 --
481 -- Name: diary_comments_id_seq; Type: SEQUENCE; Schema: public; Owner: -
482 --
483
484 CREATE SEQUENCE diary_comments_id_seq
485     START WITH 1
486     INCREMENT BY 1
487     NO MINVALUE
488     NO MAXVALUE
489     CACHE 1;
490
491
492 --
493 -- Name: diary_comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
494 --
495
496 ALTER SEQUENCE diary_comments_id_seq OWNED BY diary_comments.id;
497
498
499 --
500 -- Name: diary_entries; Type: TABLE; Schema: public; Owner: -; Tablespace: 
501 --
502
503 CREATE TABLE diary_entries (
504     id bigint NOT NULL,
505     user_id bigint NOT NULL,
506     title character varying(255) NOT NULL,
507     body text NOT NULL,
508     created_at timestamp without time zone NOT NULL,
509     updated_at timestamp without time zone NOT NULL,
510     latitude double precision,
511     longitude double precision,
512     language_code character varying(255) DEFAULT 'en'::character varying NOT NULL,
513     visible boolean DEFAULT true NOT NULL,
514     body_format format_enum DEFAULT 'html'::format_enum NOT NULL
515 );
516
517
518 --
519 -- Name: diary_entries_id_seq; Type: SEQUENCE; Schema: public; Owner: -
520 --
521
522 CREATE SEQUENCE diary_entries_id_seq
523     START WITH 1
524     INCREMENT BY 1
525     NO MINVALUE
526     NO MAXVALUE
527     CACHE 1;
528
529
530 --
531 -- Name: diary_entries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
532 --
533
534 ALTER SEQUENCE diary_entries_id_seq OWNED BY diary_entries.id;
535
536
537 --
538 -- Name: friends; Type: TABLE; Schema: public; Owner: -; Tablespace: 
539 --
540
541 CREATE TABLE friends (
542     id bigint NOT NULL,
543     user_id bigint NOT NULL,
544     friend_user_id bigint NOT NULL
545 );
546
547
548 --
549 -- Name: friends_id_seq; Type: SEQUENCE; Schema: public; Owner: -
550 --
551
552 CREATE SEQUENCE friends_id_seq
553     START WITH 1
554     INCREMENT BY 1
555     NO MINVALUE
556     NO MAXVALUE
557     CACHE 1;
558
559
560 --
561 -- Name: friends_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
562 --
563
564 ALTER SEQUENCE friends_id_seq OWNED BY friends.id;
565
566
567 --
568 -- Name: gps_points; Type: TABLE; Schema: public; Owner: -; Tablespace: 
569 --
570
571 CREATE TABLE gps_points (
572     altitude double precision,
573     trackid integer NOT NULL,
574     latitude integer NOT NULL,
575     longitude integer NOT NULL,
576     gpx_id bigint NOT NULL,
577     "timestamp" timestamp without time zone,
578     tile bigint
579 );
580
581
582 --
583 -- Name: gpx_file_tags; Type: TABLE; Schema: public; Owner: -; Tablespace: 
584 --
585
586 CREATE TABLE gpx_file_tags (
587     gpx_id bigint DEFAULT 0 NOT NULL,
588     tag character varying(255) NOT NULL,
589     id bigint NOT NULL
590 );
591
592
593 --
594 -- Name: gpx_file_tags_id_seq; Type: SEQUENCE; Schema: public; Owner: -
595 --
596
597 CREATE SEQUENCE gpx_file_tags_id_seq
598     START WITH 1
599     INCREMENT BY 1
600     NO MINVALUE
601     NO MAXVALUE
602     CACHE 1;
603
604
605 --
606 -- Name: gpx_file_tags_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
607 --
608
609 ALTER SEQUENCE gpx_file_tags_id_seq OWNED BY gpx_file_tags.id;
610
611
612 --
613 -- Name: gpx_files; Type: TABLE; Schema: public; Owner: -; Tablespace: 
614 --
615
616 CREATE TABLE gpx_files (
617     id bigint NOT NULL,
618     user_id bigint NOT NULL,
619     visible boolean DEFAULT true NOT NULL,
620     name character varying(255) DEFAULT ''::character varying NOT NULL,
621     size bigint,
622     latitude double precision,
623     longitude double precision,
624     "timestamp" timestamp without time zone NOT NULL,
625     description character varying(255) DEFAULT ''::character varying NOT NULL,
626     inserted boolean NOT NULL,
627     visibility gpx_visibility_enum DEFAULT 'public'::gpx_visibility_enum NOT NULL
628 );
629
630
631 --
632 -- Name: gpx_files_id_seq; Type: SEQUENCE; Schema: public; Owner: -
633 --
634
635 CREATE SEQUENCE gpx_files_id_seq
636     START WITH 1
637     INCREMENT BY 1
638     NO MINVALUE
639     NO MAXVALUE
640     CACHE 1;
641
642
643 --
644 -- Name: gpx_files_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
645 --
646
647 ALTER SEQUENCE gpx_files_id_seq OWNED BY gpx_files.id;
648
649
650 --
651 -- Name: languages; Type: TABLE; Schema: public; Owner: -; Tablespace: 
652 --
653
654 CREATE TABLE languages (
655     code character varying(255) NOT NULL,
656     english_name character varying(255) NOT NULL,
657     native_name character varying(255)
658 );
659
660
661 --
662 -- Name: messages; Type: TABLE; Schema: public; Owner: -; Tablespace: 
663 --
664
665 CREATE TABLE messages (
666     id bigint NOT NULL,
667     from_user_id bigint NOT NULL,
668     title character varying(255) NOT NULL,
669     body text NOT NULL,
670     sent_on timestamp without time zone NOT NULL,
671     message_read boolean DEFAULT false NOT NULL,
672     to_user_id bigint NOT NULL,
673     to_user_visible boolean DEFAULT true NOT NULL,
674     from_user_visible boolean DEFAULT true NOT NULL,
675     body_format format_enum DEFAULT 'html'::format_enum NOT NULL
676 );
677
678
679 --
680 -- Name: messages_id_seq; Type: SEQUENCE; Schema: public; Owner: -
681 --
682
683 CREATE SEQUENCE messages_id_seq
684     START WITH 1
685     INCREMENT BY 1
686     NO MINVALUE
687     NO MAXVALUE
688     CACHE 1;
689
690
691 --
692 -- Name: messages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
693 --
694
695 ALTER SEQUENCE messages_id_seq OWNED BY messages.id;
696
697
698 --
699 -- Name: node_tags; Type: TABLE; Schema: public; Owner: -; Tablespace: 
700 --
701
702 CREATE TABLE node_tags (
703     node_id bigint NOT NULL,
704     version bigint NOT NULL,
705     k character varying(255) DEFAULT ''::character varying NOT NULL,
706     v character varying(255) DEFAULT ''::character varying NOT NULL
707 );
708
709
710 --
711 -- Name: nodes; Type: TABLE; Schema: public; Owner: -; Tablespace: 
712 --
713
714 CREATE TABLE nodes (
715     node_id bigint NOT NULL,
716     latitude integer NOT NULL,
717     longitude integer NOT NULL,
718     changeset_id bigint NOT NULL,
719     visible boolean NOT NULL,
720     "timestamp" timestamp without time zone NOT NULL,
721     tile bigint NOT NULL,
722     version bigint NOT NULL,
723     redaction_id integer
724 );
725
726
727 --
728 -- Name: note_comments; Type: TABLE; Schema: public; Owner: -; Tablespace: 
729 --
730
731 CREATE TABLE note_comments (
732     id integer NOT NULL,
733     note_id bigint NOT NULL,
734     visible boolean NOT NULL,
735     created_at timestamp without time zone NOT NULL,
736     author_ip character varying(255),
737     author_id bigint,
738     body text,
739     event note_event_enum
740 );
741
742
743 --
744 -- Name: note_comments_id_seq; Type: SEQUENCE; Schema: public; Owner: -
745 --
746
747 CREATE SEQUENCE note_comments_id_seq
748     START WITH 1
749     INCREMENT BY 1
750     NO MINVALUE
751     NO MAXVALUE
752     CACHE 1;
753
754
755 --
756 -- Name: note_comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
757 --
758
759 ALTER SEQUENCE note_comments_id_seq OWNED BY note_comments.id;
760
761
762 --
763 -- Name: notes; Type: TABLE; Schema: public; Owner: -; Tablespace: 
764 --
765
766 CREATE TABLE notes (
767     id integer NOT NULL,
768     latitude integer NOT NULL,
769     longitude integer NOT NULL,
770     tile bigint NOT NULL,
771     updated_at timestamp without time zone NOT NULL,
772     created_at timestamp without time zone NOT NULL,
773     status note_status_enum NOT NULL,
774     closed_at timestamp without time zone
775 );
776
777
778 --
779 -- Name: notes_id_seq; Type: SEQUENCE; Schema: public; Owner: -
780 --
781
782 CREATE SEQUENCE notes_id_seq
783     START WITH 1
784     INCREMENT BY 1
785     NO MINVALUE
786     NO MAXVALUE
787     CACHE 1;
788
789
790 --
791 -- Name: notes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
792 --
793
794 ALTER SEQUENCE notes_id_seq OWNED BY notes.id;
795
796
797 --
798 -- Name: oauth_nonces; Type: TABLE; Schema: public; Owner: -; Tablespace: 
799 --
800
801 CREATE TABLE oauth_nonces (
802     id integer NOT NULL,
803     nonce character varying(255),
804     "timestamp" integer,
805     created_at timestamp without time zone NOT NULL,
806     updated_at timestamp without time zone NOT NULL
807 );
808
809
810 --
811 -- Name: oauth_nonces_id_seq; Type: SEQUENCE; Schema: public; Owner: -
812 --
813
814 CREATE SEQUENCE oauth_nonces_id_seq
815     START WITH 1
816     INCREMENT BY 1
817     NO MINVALUE
818     NO MAXVALUE
819     CACHE 1;
820
821
822 --
823 -- Name: oauth_nonces_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
824 --
825
826 ALTER SEQUENCE oauth_nonces_id_seq OWNED BY oauth_nonces.id;
827
828
829 --
830 -- Name: oauth_tokens; Type: TABLE; Schema: public; Owner: -; Tablespace: 
831 --
832
833 CREATE TABLE oauth_tokens (
834     id integer NOT NULL,
835     user_id integer,
836     type character varying(20),
837     client_application_id integer,
838     token character varying(50),
839     secret character varying(50),
840     authorized_at timestamp without time zone,
841     invalidated_at timestamp without time zone,
842     created_at timestamp without time zone NOT NULL,
843     updated_at timestamp without time zone NOT NULL,
844     allow_read_prefs boolean DEFAULT false NOT NULL,
845     allow_write_prefs boolean DEFAULT false NOT NULL,
846     allow_write_diary boolean DEFAULT false NOT NULL,
847     allow_write_api boolean DEFAULT false NOT NULL,
848     allow_read_gpx boolean DEFAULT false NOT NULL,
849     allow_write_gpx boolean DEFAULT false NOT NULL,
850     callback_url character varying(255),
851     verifier character varying(20),
852     scope character varying(255),
853     valid_to timestamp without time zone
854 );
855
856
857 --
858 -- Name: oauth_tokens_id_seq; Type: SEQUENCE; Schema: public; Owner: -
859 --
860
861 CREATE SEQUENCE oauth_tokens_id_seq
862     START WITH 1
863     INCREMENT BY 1
864     NO MINVALUE
865     NO MAXVALUE
866     CACHE 1;
867
868
869 --
870 -- Name: oauth_tokens_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
871 --
872
873 ALTER SEQUENCE oauth_tokens_id_seq OWNED BY oauth_tokens.id;
874
875
876 --
877 -- Name: redactions; Type: TABLE; Schema: public; Owner: -; Tablespace: 
878 --
879
880 CREATE TABLE redactions (
881     id integer NOT NULL,
882     title character varying(255),
883     description text,
884     created_at timestamp without time zone NOT NULL,
885     updated_at timestamp without time zone NOT NULL,
886     user_id bigint NOT NULL,
887     description_format format_enum DEFAULT 'markdown'::format_enum NOT NULL
888 );
889
890
891 --
892 -- Name: redactions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
893 --
894
895 CREATE SEQUENCE redactions_id_seq
896     START WITH 1
897     INCREMENT BY 1
898     NO MINVALUE
899     NO MAXVALUE
900     CACHE 1;
901
902
903 --
904 -- Name: redactions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
905 --
906
907 ALTER SEQUENCE redactions_id_seq OWNED BY redactions.id;
908
909
910 --
911 -- Name: relation_members; Type: TABLE; Schema: public; Owner: -; Tablespace: 
912 --
913
914 CREATE TABLE relation_members (
915     relation_id bigint DEFAULT 0 NOT NULL,
916     member_type nwr_enum NOT NULL,
917     member_id bigint NOT NULL,
918     member_role character varying(255) NOT NULL,
919     version bigint DEFAULT 0 NOT NULL,
920     sequence_id integer DEFAULT 0 NOT NULL
921 );
922
923
924 --
925 -- Name: relation_tags; Type: TABLE; Schema: public; Owner: -; Tablespace: 
926 --
927
928 CREATE TABLE relation_tags (
929     relation_id bigint DEFAULT 0 NOT NULL,
930     k character varying(255) DEFAULT ''::character varying NOT NULL,
931     v character varying(255) DEFAULT ''::character varying NOT NULL,
932     version bigint NOT NULL
933 );
934
935
936 --
937 -- Name: relations; Type: TABLE; Schema: public; Owner: -; Tablespace: 
938 --
939
940 CREATE TABLE relations (
941     relation_id bigint DEFAULT 0 NOT NULL,
942     changeset_id bigint NOT NULL,
943     "timestamp" timestamp without time zone NOT NULL,
944     version bigint NOT NULL,
945     visible boolean DEFAULT true NOT NULL,
946     redaction_id integer
947 );
948
949
950 --
951 -- Name: schema_migrations; Type: TABLE; Schema: public; Owner: -; Tablespace: 
952 --
953
954 CREATE TABLE schema_migrations (
955     version character varying(255) NOT NULL
956 );
957
958
959 --
960 -- Name: user_blocks; Type: TABLE; Schema: public; Owner: -; Tablespace: 
961 --
962
963 CREATE TABLE user_blocks (
964     id integer NOT NULL,
965     user_id bigint NOT NULL,
966     creator_id bigint NOT NULL,
967     reason text NOT NULL,
968     ends_at timestamp without time zone NOT NULL,
969     needs_view boolean DEFAULT false NOT NULL,
970     revoker_id bigint,
971     created_at timestamp without time zone NOT NULL,
972     updated_at timestamp without time zone NOT NULL,
973     reason_format format_enum DEFAULT 'html'::format_enum NOT NULL
974 );
975
976
977 --
978 -- Name: user_blocks_id_seq; Type: SEQUENCE; Schema: public; Owner: -
979 --
980
981 CREATE SEQUENCE user_blocks_id_seq
982     START WITH 1
983     INCREMENT BY 1
984     NO MINVALUE
985     NO MAXVALUE
986     CACHE 1;
987
988
989 --
990 -- Name: user_blocks_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
991 --
992
993 ALTER SEQUENCE user_blocks_id_seq OWNED BY user_blocks.id;
994
995
996 --
997 -- Name: user_preferences; Type: TABLE; Schema: public; Owner: -; Tablespace: 
998 --
999
1000 CREATE TABLE user_preferences (
1001     user_id bigint NOT NULL,
1002     k character varying(255) NOT NULL,
1003     v character varying(255) NOT NULL
1004 );
1005
1006
1007 --
1008 -- Name: user_roles; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1009 --
1010
1011 CREATE TABLE user_roles (
1012     id integer NOT NULL,
1013     user_id bigint NOT NULL,
1014     created_at timestamp without time zone NOT NULL,
1015     updated_at timestamp without time zone NOT NULL,
1016     role user_role_enum NOT NULL,
1017     granter_id bigint NOT NULL
1018 );
1019
1020
1021 --
1022 -- Name: user_roles_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1023 --
1024
1025 CREATE SEQUENCE user_roles_id_seq
1026     START WITH 1
1027     INCREMENT BY 1
1028     NO MINVALUE
1029     NO MAXVALUE
1030     CACHE 1;
1031
1032
1033 --
1034 -- Name: user_roles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1035 --
1036
1037 ALTER SEQUENCE user_roles_id_seq OWNED BY user_roles.id;
1038
1039
1040 --
1041 -- Name: user_tokens; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1042 --
1043
1044 CREATE TABLE user_tokens (
1045     id bigint NOT NULL,
1046     user_id bigint NOT NULL,
1047     token character varying(255) NOT NULL,
1048     expiry timestamp without time zone NOT NULL,
1049     referer text
1050 );
1051
1052
1053 --
1054 -- Name: user_tokens_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1055 --
1056
1057 CREATE SEQUENCE user_tokens_id_seq
1058     START WITH 1
1059     INCREMENT BY 1
1060     NO MINVALUE
1061     NO MAXVALUE
1062     CACHE 1;
1063
1064
1065 --
1066 -- Name: user_tokens_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1067 --
1068
1069 ALTER SEQUENCE user_tokens_id_seq OWNED BY user_tokens.id;
1070
1071
1072 --
1073 -- Name: users; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1074 --
1075
1076 CREATE TABLE users (
1077     email character varying(255) NOT NULL,
1078     id bigint NOT NULL,
1079     pass_crypt character varying(255) NOT NULL,
1080     creation_time timestamp without time zone NOT NULL,
1081     display_name character varying(255) DEFAULT ''::character varying NOT NULL,
1082     data_public boolean DEFAULT false NOT NULL,
1083     description text DEFAULT ''::text NOT NULL,
1084     home_lat double precision,
1085     home_lon double precision,
1086     home_zoom smallint DEFAULT 3,
1087     nearby integer DEFAULT 50,
1088     pass_salt character varying(255),
1089     image_file_name text,
1090     email_valid boolean DEFAULT false NOT NULL,
1091     new_email character varying(255),
1092     creation_ip character varying(255),
1093     languages character varying(255),
1094     status user_status_enum DEFAULT 'pending'::user_status_enum NOT NULL,
1095     terms_agreed timestamp without time zone,
1096     consider_pd boolean DEFAULT false NOT NULL,
1097     openid_url character varying(255),
1098     preferred_editor character varying(255),
1099     terms_seen boolean DEFAULT false NOT NULL,
1100     description_format format_enum DEFAULT 'html'::format_enum NOT NULL,
1101     image_fingerprint character varying(255),
1102     changesets_count integer DEFAULT 0 NOT NULL,
1103     traces_count integer DEFAULT 0 NOT NULL,
1104     diary_entries_count integer DEFAULT 0 NOT NULL,
1105     image_use_gravatar boolean DEFAULT true NOT NULL
1106 );
1107
1108
1109 --
1110 -- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1111 --
1112
1113 CREATE SEQUENCE users_id_seq
1114     START WITH 1
1115     INCREMENT BY 1
1116     NO MINVALUE
1117     NO MAXVALUE
1118     CACHE 1;
1119
1120
1121 --
1122 -- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1123 --
1124
1125 ALTER SEQUENCE users_id_seq OWNED BY users.id;
1126
1127
1128 --
1129 -- Name: way_nodes; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1130 --
1131
1132 CREATE TABLE way_nodes (
1133     way_id bigint NOT NULL,
1134     node_id bigint NOT NULL,
1135     version bigint NOT NULL,
1136     sequence_id bigint NOT NULL
1137 );
1138
1139
1140 --
1141 -- Name: way_tags; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1142 --
1143
1144 CREATE TABLE way_tags (
1145     way_id bigint DEFAULT 0 NOT NULL,
1146     k character varying(255) NOT NULL,
1147     v character varying(255) NOT NULL,
1148     version bigint NOT NULL
1149 );
1150
1151
1152 --
1153 -- Name: ways; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1154 --
1155
1156 CREATE TABLE ways (
1157     way_id bigint DEFAULT 0 NOT NULL,
1158     changeset_id bigint NOT NULL,
1159     "timestamp" timestamp without time zone NOT NULL,
1160     version bigint NOT NULL,
1161     visible boolean DEFAULT true NOT NULL,
1162     redaction_id integer
1163 );
1164
1165
1166 --
1167 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1168 --
1169
1170 ALTER TABLE ONLY acls ALTER COLUMN id SET DEFAULT nextval('acls_id_seq'::regclass);
1171
1172
1173 --
1174 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1175 --
1176
1177 ALTER TABLE ONLY changesets ALTER COLUMN id SET DEFAULT nextval('changesets_id_seq'::regclass);
1178
1179
1180 --
1181 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1182 --
1183
1184 ALTER TABLE ONLY client_applications ALTER COLUMN id SET DEFAULT nextval('client_applications_id_seq'::regclass);
1185
1186
1187 --
1188 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1189 --
1190
1191 ALTER TABLE ONLY countries ALTER COLUMN id SET DEFAULT nextval('countries_id_seq'::regclass);
1192
1193
1194 --
1195 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1196 --
1197
1198 ALTER TABLE ONLY current_nodes ALTER COLUMN id SET DEFAULT nextval('current_nodes_id_seq'::regclass);
1199
1200
1201 --
1202 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1203 --
1204
1205 ALTER TABLE ONLY current_relations ALTER COLUMN id SET DEFAULT nextval('current_relations_id_seq'::regclass);
1206
1207
1208 --
1209 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1210 --
1211
1212 ALTER TABLE ONLY current_ways ALTER COLUMN id SET DEFAULT nextval('current_ways_id_seq'::regclass);
1213
1214
1215 --
1216 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1217 --
1218
1219 ALTER TABLE ONLY diary_comments ALTER COLUMN id SET DEFAULT nextval('diary_comments_id_seq'::regclass);
1220
1221
1222 --
1223 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1224 --
1225
1226 ALTER TABLE ONLY diary_entries ALTER COLUMN id SET DEFAULT nextval('diary_entries_id_seq'::regclass);
1227
1228
1229 --
1230 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1231 --
1232
1233 ALTER TABLE ONLY friends ALTER COLUMN id SET DEFAULT nextval('friends_id_seq'::regclass);
1234
1235
1236 --
1237 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1238 --
1239
1240 ALTER TABLE ONLY gpx_file_tags ALTER COLUMN id SET DEFAULT nextval('gpx_file_tags_id_seq'::regclass);
1241
1242
1243 --
1244 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1245 --
1246
1247 ALTER TABLE ONLY gpx_files ALTER COLUMN id SET DEFAULT nextval('gpx_files_id_seq'::regclass);
1248
1249
1250 --
1251 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1252 --
1253
1254 ALTER TABLE ONLY messages ALTER COLUMN id SET DEFAULT nextval('messages_id_seq'::regclass);
1255
1256
1257 --
1258 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1259 --
1260
1261 ALTER TABLE ONLY note_comments ALTER COLUMN id SET DEFAULT nextval('note_comments_id_seq'::regclass);
1262
1263
1264 --
1265 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1266 --
1267
1268 ALTER TABLE ONLY notes ALTER COLUMN id SET DEFAULT nextval('notes_id_seq'::regclass);
1269
1270
1271 --
1272 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1273 --
1274
1275 ALTER TABLE ONLY oauth_nonces ALTER COLUMN id SET DEFAULT nextval('oauth_nonces_id_seq'::regclass);
1276
1277
1278 --
1279 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1280 --
1281
1282 ALTER TABLE ONLY oauth_tokens ALTER COLUMN id SET DEFAULT nextval('oauth_tokens_id_seq'::regclass);
1283
1284
1285 --
1286 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1287 --
1288
1289 ALTER TABLE ONLY redactions ALTER COLUMN id SET DEFAULT nextval('redactions_id_seq'::regclass);
1290
1291
1292 --
1293 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1294 --
1295
1296 ALTER TABLE ONLY user_blocks ALTER COLUMN id SET DEFAULT nextval('user_blocks_id_seq'::regclass);
1297
1298
1299 --
1300 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1301 --
1302
1303 ALTER TABLE ONLY user_roles ALTER COLUMN id SET DEFAULT nextval('user_roles_id_seq'::regclass);
1304
1305
1306 --
1307 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1308 --
1309
1310 ALTER TABLE ONLY user_tokens ALTER COLUMN id SET DEFAULT nextval('user_tokens_id_seq'::regclass);
1311
1312
1313 --
1314 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1315 --
1316
1317 ALTER TABLE ONLY users ALTER COLUMN id SET DEFAULT nextval('users_id_seq'::regclass);
1318
1319
1320 --
1321 -- Name: acls_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1322 --
1323
1324 ALTER TABLE ONLY acls
1325     ADD CONSTRAINT acls_pkey PRIMARY KEY (id);
1326
1327
1328 --
1329 -- Name: changesets_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1330 --
1331
1332 ALTER TABLE ONLY changesets
1333     ADD CONSTRAINT changesets_pkey PRIMARY KEY (id);
1334
1335
1336 --
1337 -- Name: client_applications_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1338 --
1339
1340 ALTER TABLE ONLY client_applications
1341     ADD CONSTRAINT client_applications_pkey PRIMARY KEY (id);
1342
1343
1344 --
1345 -- Name: countries_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1346 --
1347
1348 ALTER TABLE ONLY countries
1349     ADD CONSTRAINT countries_pkey PRIMARY KEY (id);
1350
1351
1352 --
1353 -- Name: current_node_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1354 --
1355
1356 ALTER TABLE ONLY current_node_tags
1357     ADD CONSTRAINT current_node_tags_pkey PRIMARY KEY (node_id, k);
1358
1359
1360 --
1361 -- Name: current_nodes_pkey1; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1362 --
1363
1364 ALTER TABLE ONLY current_nodes
1365     ADD CONSTRAINT current_nodes_pkey1 PRIMARY KEY (id);
1366
1367
1368 --
1369 -- Name: current_relation_members_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1370 --
1371
1372 ALTER TABLE ONLY current_relation_members
1373     ADD CONSTRAINT current_relation_members_pkey PRIMARY KEY (relation_id, member_type, member_id, member_role, sequence_id);
1374
1375
1376 --
1377 -- Name: current_relation_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1378 --
1379
1380 ALTER TABLE ONLY current_relation_tags
1381     ADD CONSTRAINT current_relation_tags_pkey PRIMARY KEY (relation_id, k);
1382
1383
1384 --
1385 -- Name: current_relations_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1386 --
1387
1388 ALTER TABLE ONLY current_relations
1389     ADD CONSTRAINT current_relations_pkey PRIMARY KEY (id);
1390
1391
1392 --
1393 -- Name: current_way_nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1394 --
1395
1396 ALTER TABLE ONLY current_way_nodes
1397     ADD CONSTRAINT current_way_nodes_pkey PRIMARY KEY (way_id, sequence_id);
1398
1399
1400 --
1401 -- Name: current_way_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1402 --
1403
1404 ALTER TABLE ONLY current_way_tags
1405     ADD CONSTRAINT current_way_tags_pkey PRIMARY KEY (way_id, k);
1406
1407
1408 --
1409 -- Name: current_ways_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1410 --
1411
1412 ALTER TABLE ONLY current_ways
1413     ADD CONSTRAINT current_ways_pkey PRIMARY KEY (id);
1414
1415
1416 --
1417 -- Name: diary_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1418 --
1419
1420 ALTER TABLE ONLY diary_comments
1421     ADD CONSTRAINT diary_comments_pkey PRIMARY KEY (id);
1422
1423
1424 --
1425 -- Name: diary_entries_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1426 --
1427
1428 ALTER TABLE ONLY diary_entries
1429     ADD CONSTRAINT diary_entries_pkey PRIMARY KEY (id);
1430
1431
1432 --
1433 -- Name: friends_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1434 --
1435
1436 ALTER TABLE ONLY friends
1437     ADD CONSTRAINT friends_pkey PRIMARY KEY (id);
1438
1439
1440 --
1441 -- Name: gpx_file_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1442 --
1443
1444 ALTER TABLE ONLY gpx_file_tags
1445     ADD CONSTRAINT gpx_file_tags_pkey PRIMARY KEY (id);
1446
1447
1448 --
1449 -- Name: gpx_files_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1450 --
1451
1452 ALTER TABLE ONLY gpx_files
1453     ADD CONSTRAINT gpx_files_pkey PRIMARY KEY (id);
1454
1455
1456 --
1457 -- Name: languages_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1458 --
1459
1460 ALTER TABLE ONLY languages
1461     ADD CONSTRAINT languages_pkey PRIMARY KEY (code);
1462
1463
1464 --
1465 -- Name: messages_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1466 --
1467
1468 ALTER TABLE ONLY messages
1469     ADD CONSTRAINT messages_pkey PRIMARY KEY (id);
1470
1471
1472 --
1473 -- Name: node_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1474 --
1475
1476 ALTER TABLE ONLY node_tags
1477     ADD CONSTRAINT node_tags_pkey PRIMARY KEY (node_id, version, k);
1478
1479
1480 --
1481 -- Name: nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1482 --
1483
1484 ALTER TABLE ONLY nodes
1485     ADD CONSTRAINT nodes_pkey PRIMARY KEY (node_id, version);
1486
1487
1488 --
1489 -- Name: note_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1490 --
1491
1492 ALTER TABLE ONLY note_comments
1493     ADD CONSTRAINT note_comments_pkey PRIMARY KEY (id);
1494
1495
1496 --
1497 -- Name: notes_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1498 --
1499
1500 ALTER TABLE ONLY notes
1501     ADD CONSTRAINT notes_pkey PRIMARY KEY (id);
1502
1503
1504 --
1505 -- Name: oauth_nonces_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1506 --
1507
1508 ALTER TABLE ONLY oauth_nonces
1509     ADD CONSTRAINT oauth_nonces_pkey PRIMARY KEY (id);
1510
1511
1512 --
1513 -- Name: oauth_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1514 --
1515
1516 ALTER TABLE ONLY oauth_tokens
1517     ADD CONSTRAINT oauth_tokens_pkey PRIMARY KEY (id);
1518
1519
1520 --
1521 -- Name: redactions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1522 --
1523
1524 ALTER TABLE ONLY redactions
1525     ADD CONSTRAINT redactions_pkey PRIMARY KEY (id);
1526
1527
1528 --
1529 -- Name: relation_members_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1530 --
1531
1532 ALTER TABLE ONLY relation_members
1533     ADD CONSTRAINT relation_members_pkey PRIMARY KEY (relation_id, version, member_type, member_id, member_role, sequence_id);
1534
1535
1536 --
1537 -- Name: relation_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1538 --
1539
1540 ALTER TABLE ONLY relation_tags
1541     ADD CONSTRAINT relation_tags_pkey PRIMARY KEY (relation_id, version, k);
1542
1543
1544 --
1545 -- Name: relations_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1546 --
1547
1548 ALTER TABLE ONLY relations
1549     ADD CONSTRAINT relations_pkey PRIMARY KEY (relation_id, version);
1550
1551
1552 --
1553 -- Name: user_blocks_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1554 --
1555
1556 ALTER TABLE ONLY user_blocks
1557     ADD CONSTRAINT user_blocks_pkey PRIMARY KEY (id);
1558
1559
1560 --
1561 -- Name: user_preferences_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1562 --
1563
1564 ALTER TABLE ONLY user_preferences
1565     ADD CONSTRAINT user_preferences_pkey PRIMARY KEY (user_id, k);
1566
1567
1568 --
1569 -- Name: user_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1570 --
1571
1572 ALTER TABLE ONLY user_roles
1573     ADD CONSTRAINT user_roles_pkey PRIMARY KEY (id);
1574
1575
1576 --
1577 -- Name: user_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1578 --
1579
1580 ALTER TABLE ONLY user_tokens
1581     ADD CONSTRAINT user_tokens_pkey PRIMARY KEY (id);
1582
1583
1584 --
1585 -- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1586 --
1587
1588 ALTER TABLE ONLY users
1589     ADD CONSTRAINT users_pkey PRIMARY KEY (id);
1590
1591
1592 --
1593 -- Name: way_nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1594 --
1595
1596 ALTER TABLE ONLY way_nodes
1597     ADD CONSTRAINT way_nodes_pkey PRIMARY KEY (way_id, version, sequence_id);
1598
1599
1600 --
1601 -- Name: way_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1602 --
1603
1604 ALTER TABLE ONLY way_tags
1605     ADD CONSTRAINT way_tags_pkey PRIMARY KEY (way_id, version, k);
1606
1607
1608 --
1609 -- Name: ways_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1610 --
1611
1612 ALTER TABLE ONLY ways
1613     ADD CONSTRAINT ways_pkey PRIMARY KEY (way_id, version);
1614
1615
1616 --
1617 -- Name: acls_k_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1618 --
1619
1620 CREATE INDEX acls_k_idx ON acls USING btree (k);
1621
1622
1623 --
1624 -- Name: changeset_tags_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1625 --
1626
1627 CREATE INDEX changeset_tags_id_idx ON changeset_tags USING btree (changeset_id);
1628
1629
1630 --
1631 -- Name: changesets_bbox_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1632 --
1633
1634 CREATE INDEX changesets_bbox_idx ON changesets USING gist (min_lat, max_lat, min_lon, max_lon);
1635
1636
1637 --
1638 -- Name: changesets_closed_at_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1639 --
1640
1641 CREATE INDEX changesets_closed_at_idx ON changesets USING btree (closed_at);
1642
1643
1644 --
1645 -- Name: changesets_created_at_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1646 --
1647
1648 CREATE INDEX changesets_created_at_idx ON changesets USING btree (created_at);
1649
1650
1651 --
1652 -- Name: changesets_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1653 --
1654
1655 CREATE INDEX changesets_user_id_created_at_idx ON changesets USING btree (user_id, created_at);
1656
1657
1658 --
1659 -- Name: changesets_user_id_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1660 --
1661
1662 CREATE INDEX changesets_user_id_id_idx ON changesets USING btree (user_id, id);
1663
1664
1665 --
1666 -- Name: countries_code_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1667 --
1668
1669 CREATE UNIQUE INDEX countries_code_idx ON countries USING btree (code);
1670
1671
1672 --
1673 -- Name: current_nodes_tile_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1674 --
1675
1676 CREATE INDEX current_nodes_tile_idx ON current_nodes USING btree (tile);
1677
1678
1679 --
1680 -- Name: current_nodes_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1681 --
1682
1683 CREATE INDEX current_nodes_timestamp_idx ON current_nodes USING btree ("timestamp");
1684
1685
1686 --
1687 -- Name: current_relation_members_member_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1688 --
1689
1690 CREATE INDEX current_relation_members_member_idx ON current_relation_members USING btree (member_type, member_id);
1691
1692
1693 --
1694 -- Name: current_relations_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1695 --
1696
1697 CREATE INDEX current_relations_timestamp_idx ON current_relations USING btree ("timestamp");
1698
1699
1700 --
1701 -- Name: current_way_nodes_node_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1702 --
1703
1704 CREATE INDEX current_way_nodes_node_idx ON current_way_nodes USING btree (node_id);
1705
1706
1707 --
1708 -- Name: current_ways_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1709 --
1710
1711 CREATE INDEX current_ways_timestamp_idx ON current_ways USING btree ("timestamp");
1712
1713
1714 --
1715 -- Name: diary_comment_user_id_created_at_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1716 --
1717
1718 CREATE INDEX diary_comment_user_id_created_at_index ON diary_comments USING btree (user_id, created_at);
1719
1720
1721 --
1722 -- Name: diary_comments_entry_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1723 --
1724
1725 CREATE UNIQUE INDEX diary_comments_entry_id_idx ON diary_comments USING btree (diary_entry_id, id);
1726
1727
1728 --
1729 -- Name: diary_entry_created_at_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1730 --
1731
1732 CREATE INDEX diary_entry_created_at_index ON diary_entries USING btree (created_at);
1733
1734
1735 --
1736 -- Name: diary_entry_language_code_created_at_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1737 --
1738
1739 CREATE INDEX diary_entry_language_code_created_at_index ON diary_entries USING btree (language_code, created_at);
1740
1741
1742 --
1743 -- Name: diary_entry_user_id_created_at_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1744 --
1745
1746 CREATE INDEX diary_entry_user_id_created_at_index ON diary_entries USING btree (user_id, created_at);
1747
1748
1749 --
1750 -- Name: friends_user_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1751 --
1752
1753 CREATE INDEX friends_user_id_idx ON friends USING btree (user_id);
1754
1755
1756 --
1757 -- Name: gpx_file_tags_gpxid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1758 --
1759
1760 CREATE INDEX gpx_file_tags_gpxid_idx ON gpx_file_tags USING btree (gpx_id);
1761
1762
1763 --
1764 -- Name: gpx_file_tags_tag_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1765 --
1766
1767 CREATE INDEX gpx_file_tags_tag_idx ON gpx_file_tags USING btree (tag);
1768
1769
1770 --
1771 -- Name: gpx_files_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1772 --
1773
1774 CREATE INDEX gpx_files_timestamp_idx ON gpx_files USING btree ("timestamp");
1775
1776
1777 --
1778 -- Name: gpx_files_user_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1779 --
1780
1781 CREATE INDEX gpx_files_user_id_idx ON gpx_files USING btree (user_id);
1782
1783
1784 --
1785 -- Name: gpx_files_visible_visibility_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1786 --
1787
1788 CREATE INDEX gpx_files_visible_visibility_idx ON gpx_files USING btree (visible, visibility);
1789
1790
1791 --
1792 -- Name: index_client_applications_on_key; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1793 --
1794
1795 CREATE UNIQUE INDEX index_client_applications_on_key ON client_applications USING btree (key);
1796
1797
1798 --
1799 -- Name: index_oauth_nonces_on_nonce_and_timestamp; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1800 --
1801
1802 CREATE UNIQUE INDEX index_oauth_nonces_on_nonce_and_timestamp ON oauth_nonces USING btree (nonce, "timestamp");
1803
1804
1805 --
1806 -- Name: index_oauth_tokens_on_token; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1807 --
1808
1809 CREATE UNIQUE INDEX index_oauth_tokens_on_token ON oauth_tokens USING btree (token);
1810
1811
1812 --
1813 -- Name: index_user_blocks_on_user_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1814 --
1815
1816 CREATE INDEX index_user_blocks_on_user_id ON user_blocks USING btree (user_id);
1817
1818
1819 --
1820 -- Name: messages_from_user_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1821 --
1822
1823 CREATE INDEX messages_from_user_id_idx ON messages USING btree (from_user_id);
1824
1825
1826 --
1827 -- Name: messages_to_user_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1828 --
1829
1830 CREATE INDEX messages_to_user_id_idx ON messages USING btree (to_user_id);
1831
1832
1833 --
1834 -- Name: nodes_changeset_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1835 --
1836
1837 CREATE INDEX nodes_changeset_id_idx ON nodes USING btree (changeset_id);
1838
1839
1840 --
1841 -- Name: nodes_tile_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1842 --
1843
1844 CREATE INDEX nodes_tile_idx ON nodes USING btree (tile);
1845
1846
1847 --
1848 -- Name: nodes_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1849 --
1850
1851 CREATE INDEX nodes_timestamp_idx ON nodes USING btree ("timestamp");
1852
1853
1854 --
1855 -- Name: note_comments_note_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1856 --
1857
1858 CREATE INDEX note_comments_note_id_idx ON note_comments USING btree (note_id);
1859
1860
1861 --
1862 -- Name: notes_created_at_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1863 --
1864
1865 CREATE INDEX notes_created_at_idx ON notes USING btree (created_at);
1866
1867
1868 --
1869 -- Name: notes_tile_status_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1870 --
1871
1872 CREATE INDEX notes_tile_status_idx ON notes USING btree (tile, status);
1873
1874
1875 --
1876 -- Name: notes_updated_at_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1877 --
1878
1879 CREATE INDEX notes_updated_at_idx ON notes USING btree (updated_at);
1880
1881
1882 --
1883 -- Name: points_gpxid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1884 --
1885
1886 CREATE INDEX points_gpxid_idx ON gps_points USING btree (gpx_id);
1887
1888
1889 --
1890 -- Name: points_tile_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1891 --
1892
1893 CREATE INDEX points_tile_idx ON gps_points USING btree (tile);
1894
1895
1896 --
1897 -- Name: relation_members_member_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1898 --
1899
1900 CREATE INDEX relation_members_member_idx ON relation_members USING btree (member_type, member_id);
1901
1902
1903 --
1904 -- Name: relations_changeset_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1905 --
1906
1907 CREATE INDEX relations_changeset_id_idx ON relations USING btree (changeset_id);
1908
1909
1910 --
1911 -- Name: relations_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1912 --
1913
1914 CREATE INDEX relations_timestamp_idx ON relations USING btree ("timestamp");
1915
1916
1917 --
1918 -- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1919 --
1920
1921 CREATE UNIQUE INDEX unique_schema_migrations ON schema_migrations USING btree (version);
1922
1923
1924 --
1925 -- Name: user_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1926 --
1927
1928 CREATE INDEX user_id_idx ON friends USING btree (friend_user_id);
1929
1930
1931 --
1932 -- Name: user_openid_url_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1933 --
1934
1935 CREATE UNIQUE INDEX user_openid_url_idx ON users USING btree (openid_url);
1936
1937
1938 --
1939 -- Name: user_roles_id_role_unique; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1940 --
1941
1942 CREATE UNIQUE INDEX user_roles_id_role_unique ON user_roles USING btree (user_id, role);
1943
1944
1945 --
1946 -- Name: user_tokens_token_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1947 --
1948
1949 CREATE UNIQUE INDEX user_tokens_token_idx ON user_tokens USING btree (token);
1950
1951
1952 --
1953 -- Name: user_tokens_user_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1954 --
1955
1956 CREATE INDEX user_tokens_user_id_idx ON user_tokens USING btree (user_id);
1957
1958
1959 --
1960 -- Name: users_display_name_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1961 --
1962
1963 CREATE UNIQUE INDEX users_display_name_idx ON users USING btree (display_name);
1964
1965
1966 --
1967 -- Name: users_display_name_lower_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1968 --
1969
1970 CREATE INDEX users_display_name_lower_idx ON users USING btree (lower((display_name)::text));
1971
1972
1973 --
1974 -- Name: users_email_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1975 --
1976
1977 CREATE UNIQUE INDEX users_email_idx ON users USING btree (email);
1978
1979
1980 --
1981 -- Name: users_email_lower_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1982 --
1983
1984 CREATE INDEX users_email_lower_idx ON users USING btree (lower((email)::text));
1985
1986
1987 --
1988 -- Name: way_nodes_node_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1989 --
1990
1991 CREATE INDEX way_nodes_node_idx ON way_nodes USING btree (node_id);
1992
1993
1994 --
1995 -- Name: ways_changeset_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1996 --
1997
1998 CREATE INDEX ways_changeset_id_idx ON ways USING btree (changeset_id);
1999
2000
2001 --
2002 -- Name: ways_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
2003 --
2004
2005 CREATE INDEX ways_timestamp_idx ON ways USING btree ("timestamp");
2006
2007
2008 --
2009 -- Name: changeset_tags_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2010 --
2011
2012 ALTER TABLE ONLY changeset_tags
2013     ADD CONSTRAINT changeset_tags_id_fkey FOREIGN KEY (changeset_id) REFERENCES changesets(id);
2014
2015
2016 --
2017 -- Name: changesets_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2018 --
2019
2020 ALTER TABLE ONLY changesets
2021     ADD CONSTRAINT changesets_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
2022
2023
2024 --
2025 -- Name: client_applications_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2026 --
2027
2028 ALTER TABLE ONLY client_applications
2029     ADD CONSTRAINT client_applications_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
2030
2031
2032 --
2033 -- Name: current_node_tags_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2034 --
2035
2036 ALTER TABLE ONLY current_node_tags
2037     ADD CONSTRAINT current_node_tags_id_fkey FOREIGN KEY (node_id) REFERENCES current_nodes(id);
2038
2039
2040 --
2041 -- Name: current_nodes_changeset_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2042 --
2043
2044 ALTER TABLE ONLY current_nodes
2045     ADD CONSTRAINT current_nodes_changeset_id_fkey FOREIGN KEY (changeset_id) REFERENCES changesets(id);
2046
2047
2048 --
2049 -- Name: current_relation_members_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2050 --
2051
2052 ALTER TABLE ONLY current_relation_members
2053     ADD CONSTRAINT current_relation_members_id_fkey FOREIGN KEY (relation_id) REFERENCES current_relations(id);
2054
2055
2056 --
2057 -- Name: current_relation_tags_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2058 --
2059
2060 ALTER TABLE ONLY current_relation_tags
2061     ADD CONSTRAINT current_relation_tags_id_fkey FOREIGN KEY (relation_id) REFERENCES current_relations(id);
2062
2063
2064 --
2065 -- Name: current_relations_changeset_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2066 --
2067
2068 ALTER TABLE ONLY current_relations
2069     ADD CONSTRAINT current_relations_changeset_id_fkey FOREIGN KEY (changeset_id) REFERENCES changesets(id);
2070
2071
2072 --
2073 -- Name: current_way_nodes_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2074 --
2075
2076 ALTER TABLE ONLY current_way_nodes
2077     ADD CONSTRAINT current_way_nodes_id_fkey FOREIGN KEY (way_id) REFERENCES current_ways(id);
2078
2079
2080 --
2081 -- Name: current_way_nodes_node_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2082 --
2083
2084 ALTER TABLE ONLY current_way_nodes
2085     ADD CONSTRAINT current_way_nodes_node_id_fkey FOREIGN KEY (node_id) REFERENCES current_nodes(id);
2086
2087
2088 --
2089 -- Name: current_way_tags_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2090 --
2091
2092 ALTER TABLE ONLY current_way_tags
2093     ADD CONSTRAINT current_way_tags_id_fkey FOREIGN KEY (way_id) REFERENCES current_ways(id);
2094
2095
2096 --
2097 -- Name: current_ways_changeset_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2098 --
2099
2100 ALTER TABLE ONLY current_ways
2101     ADD CONSTRAINT current_ways_changeset_id_fkey FOREIGN KEY (changeset_id) REFERENCES changesets(id);
2102
2103
2104 --
2105 -- Name: diary_comments_diary_entry_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2106 --
2107
2108 ALTER TABLE ONLY diary_comments
2109     ADD CONSTRAINT diary_comments_diary_entry_id_fkey FOREIGN KEY (diary_entry_id) REFERENCES diary_entries(id);
2110
2111
2112 --
2113 -- Name: diary_comments_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2114 --
2115
2116 ALTER TABLE ONLY diary_comments
2117     ADD CONSTRAINT diary_comments_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
2118
2119
2120 --
2121 -- Name: diary_entries_language_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2122 --
2123
2124 ALTER TABLE ONLY diary_entries
2125     ADD CONSTRAINT diary_entries_language_code_fkey FOREIGN KEY (language_code) REFERENCES languages(code);
2126
2127
2128 --
2129 -- Name: diary_entries_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2130 --
2131
2132 ALTER TABLE ONLY diary_entries
2133     ADD CONSTRAINT diary_entries_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
2134
2135
2136 --
2137 -- Name: friends_friend_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2138 --
2139
2140 ALTER TABLE ONLY friends
2141     ADD CONSTRAINT friends_friend_user_id_fkey FOREIGN KEY (friend_user_id) REFERENCES users(id);
2142
2143
2144 --
2145 -- Name: friends_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2146 --
2147
2148 ALTER TABLE ONLY friends
2149     ADD CONSTRAINT friends_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
2150
2151
2152 --
2153 -- Name: gps_points_gpx_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2154 --
2155
2156 ALTER TABLE ONLY gps_points
2157     ADD CONSTRAINT gps_points_gpx_id_fkey FOREIGN KEY (gpx_id) REFERENCES gpx_files(id);
2158
2159
2160 --
2161 -- Name: gpx_file_tags_gpx_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2162 --
2163
2164 ALTER TABLE ONLY gpx_file_tags
2165     ADD CONSTRAINT gpx_file_tags_gpx_id_fkey FOREIGN KEY (gpx_id) REFERENCES gpx_files(id);
2166
2167
2168 --
2169 -- Name: gpx_files_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2170 --
2171
2172 ALTER TABLE ONLY gpx_files
2173     ADD CONSTRAINT gpx_files_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
2174
2175
2176 --
2177 -- Name: messages_from_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2178 --
2179
2180 ALTER TABLE ONLY messages
2181     ADD CONSTRAINT messages_from_user_id_fkey FOREIGN KEY (from_user_id) REFERENCES users(id);
2182
2183
2184 --
2185 -- Name: messages_to_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2186 --
2187
2188 ALTER TABLE ONLY messages
2189     ADD CONSTRAINT messages_to_user_id_fkey FOREIGN KEY (to_user_id) REFERENCES users(id);
2190
2191
2192 --
2193 -- Name: node_tags_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2194 --
2195
2196 ALTER TABLE ONLY node_tags
2197     ADD CONSTRAINT node_tags_id_fkey FOREIGN KEY (node_id, version) REFERENCES nodes(node_id, version);
2198
2199
2200 --
2201 -- Name: nodes_changeset_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2202 --
2203
2204 ALTER TABLE ONLY nodes
2205     ADD CONSTRAINT nodes_changeset_id_fkey FOREIGN KEY (changeset_id) REFERENCES changesets(id);
2206
2207
2208 --
2209 -- Name: nodes_redaction_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2210 --
2211
2212 ALTER TABLE ONLY nodes
2213     ADD CONSTRAINT nodes_redaction_id_fkey FOREIGN KEY (redaction_id) REFERENCES redactions(id);
2214
2215
2216 --
2217 -- Name: note_comments_author_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2218 --
2219
2220 ALTER TABLE ONLY note_comments
2221     ADD CONSTRAINT note_comments_author_id_fkey FOREIGN KEY (author_id) REFERENCES users(id);
2222
2223
2224 --
2225 -- Name: note_comments_note_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2226 --
2227
2228 ALTER TABLE ONLY note_comments
2229     ADD CONSTRAINT note_comments_note_id_fkey FOREIGN KEY (note_id) REFERENCES notes(id);
2230
2231
2232 --
2233 -- Name: oauth_tokens_client_application_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2234 --
2235
2236 ALTER TABLE ONLY oauth_tokens
2237     ADD CONSTRAINT oauth_tokens_client_application_id_fkey FOREIGN KEY (client_application_id) REFERENCES client_applications(id);
2238
2239
2240 --
2241 -- Name: oauth_tokens_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2242 --
2243
2244 ALTER TABLE ONLY oauth_tokens
2245     ADD CONSTRAINT oauth_tokens_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
2246
2247
2248 --
2249 -- Name: redactions_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2250 --
2251
2252 ALTER TABLE ONLY redactions
2253     ADD CONSTRAINT redactions_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
2254
2255
2256 --
2257 -- Name: relation_members_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2258 --
2259
2260 ALTER TABLE ONLY relation_members
2261     ADD CONSTRAINT relation_members_id_fkey FOREIGN KEY (relation_id, version) REFERENCES relations(relation_id, version);
2262
2263
2264 --
2265 -- Name: relation_tags_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2266 --
2267
2268 ALTER TABLE ONLY relation_tags
2269     ADD CONSTRAINT relation_tags_id_fkey FOREIGN KEY (relation_id, version) REFERENCES relations(relation_id, version);
2270
2271
2272 --
2273 -- Name: relations_changeset_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2274 --
2275
2276 ALTER TABLE ONLY relations
2277     ADD CONSTRAINT relations_changeset_id_fkey FOREIGN KEY (changeset_id) REFERENCES changesets(id);
2278
2279
2280 --
2281 -- Name: relations_redaction_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2282 --
2283
2284 ALTER TABLE ONLY relations
2285     ADD CONSTRAINT relations_redaction_id_fkey FOREIGN KEY (redaction_id) REFERENCES redactions(id);
2286
2287
2288 --
2289 -- Name: user_blocks_moderator_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2290 --
2291
2292 ALTER TABLE ONLY user_blocks
2293     ADD CONSTRAINT user_blocks_moderator_id_fkey FOREIGN KEY (creator_id) REFERENCES users(id);
2294
2295
2296 --
2297 -- Name: user_blocks_revoker_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2298 --
2299
2300 ALTER TABLE ONLY user_blocks
2301     ADD CONSTRAINT user_blocks_revoker_id_fkey FOREIGN KEY (revoker_id) REFERENCES users(id);
2302
2303
2304 --
2305 -- Name: user_blocks_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2306 --
2307
2308 ALTER TABLE ONLY user_blocks
2309     ADD CONSTRAINT user_blocks_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
2310
2311
2312 --
2313 -- Name: user_preferences_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2314 --
2315
2316 ALTER TABLE ONLY user_preferences
2317     ADD CONSTRAINT user_preferences_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
2318
2319
2320 --
2321 -- Name: user_roles_granter_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2322 --
2323
2324 ALTER TABLE ONLY user_roles
2325     ADD CONSTRAINT user_roles_granter_id_fkey FOREIGN KEY (granter_id) REFERENCES users(id);
2326
2327
2328 --
2329 -- Name: user_roles_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2330 --
2331
2332 ALTER TABLE ONLY user_roles
2333     ADD CONSTRAINT user_roles_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
2334
2335
2336 --
2337 -- Name: user_tokens_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2338 --
2339
2340 ALTER TABLE ONLY user_tokens
2341     ADD CONSTRAINT user_tokens_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
2342
2343
2344 --
2345 -- Name: way_nodes_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2346 --
2347
2348 ALTER TABLE ONLY way_nodes
2349     ADD CONSTRAINT way_nodes_id_fkey FOREIGN KEY (way_id, version) REFERENCES ways(way_id, version);
2350
2351
2352 --
2353 -- Name: way_tags_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2354 --
2355
2356 ALTER TABLE ONLY way_tags
2357     ADD CONSTRAINT way_tags_id_fkey FOREIGN KEY (way_id, version) REFERENCES ways(way_id, version);
2358
2359
2360 --
2361 -- Name: ways_changeset_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2362 --
2363
2364 ALTER TABLE ONLY ways
2365     ADD CONSTRAINT ways_changeset_id_fkey FOREIGN KEY (changeset_id) REFERENCES changesets(id);
2366
2367
2368 --
2369 -- Name: ways_redaction_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2370 --
2371
2372 ALTER TABLE ONLY ways
2373     ADD CONSTRAINT ways_redaction_id_fkey FOREIGN KEY (redaction_id) REFERENCES redactions(id);
2374
2375
2376 --
2377 -- PostgreSQL database dump complete
2378 --
2379
2380 INSERT INTO schema_migrations (version) VALUES ('1');
2381
2382 INSERT INTO schema_migrations (version) VALUES ('10');
2383
2384 INSERT INTO schema_migrations (version) VALUES ('11');
2385
2386 INSERT INTO schema_migrations (version) VALUES ('12');
2387
2388 INSERT INTO schema_migrations (version) VALUES ('13');
2389
2390 INSERT INTO schema_migrations (version) VALUES ('14');
2391
2392 INSERT INTO schema_migrations (version) VALUES ('15');
2393
2394 INSERT INTO schema_migrations (version) VALUES ('16');
2395
2396 INSERT INTO schema_migrations (version) VALUES ('17');
2397
2398 INSERT INTO schema_migrations (version) VALUES ('18');
2399
2400 INSERT INTO schema_migrations (version) VALUES ('19');
2401
2402 INSERT INTO schema_migrations (version) VALUES ('2');
2403
2404 INSERT INTO schema_migrations (version) VALUES ('20');
2405
2406 INSERT INTO schema_migrations (version) VALUES ('20100513171259');
2407
2408 INSERT INTO schema_migrations (version) VALUES ('20100516124737');
2409
2410 INSERT INTO schema_migrations (version) VALUES ('20100910084426');
2411
2412 INSERT INTO schema_migrations (version) VALUES ('20101114011429');
2413
2414 INSERT INTO schema_migrations (version) VALUES ('20110322001319');
2415
2416 INSERT INTO schema_migrations (version) VALUES ('20110508145337');
2417
2418 INSERT INTO schema_migrations (version) VALUES ('20110521142405');
2419
2420 INSERT INTO schema_migrations (version) VALUES ('20110925112722');
2421
2422 INSERT INTO schema_migrations (version) VALUES ('20111116184519');
2423
2424 INSERT INTO schema_migrations (version) VALUES ('20111212183945');
2425
2426 INSERT INTO schema_migrations (version) VALUES ('20120123184321');
2427
2428 INSERT INTO schema_migrations (version) VALUES ('20120208122334');
2429
2430 INSERT INTO schema_migrations (version) VALUES ('20120208194454');
2431
2432 INSERT INTO schema_migrations (version) VALUES ('20120214210114');
2433
2434 INSERT INTO schema_migrations (version) VALUES ('20120219161649');
2435
2436 INSERT INTO schema_migrations (version) VALUES ('20120318201948');
2437
2438 INSERT INTO schema_migrations (version) VALUES ('20120328090602');
2439
2440 INSERT INTO schema_migrations (version) VALUES ('20120404205604');
2441
2442 INSERT INTO schema_migrations (version) VALUES ('20120808231205');
2443
2444 INSERT INTO schema_migrations (version) VALUES ('20121005195010');
2445
2446 INSERT INTO schema_migrations (version) VALUES ('20121012044047');
2447
2448 INSERT INTO schema_migrations (version) VALUES ('20121119165817');
2449
2450 INSERT INTO schema_migrations (version) VALUES ('20121202155309');
2451
2452 INSERT INTO schema_migrations (version) VALUES ('21');
2453
2454 INSERT INTO schema_migrations (version) VALUES ('22');
2455
2456 INSERT INTO schema_migrations (version) VALUES ('23');
2457
2458 INSERT INTO schema_migrations (version) VALUES ('24');
2459
2460 INSERT INTO schema_migrations (version) VALUES ('25');
2461
2462 INSERT INTO schema_migrations (version) VALUES ('26');
2463
2464 INSERT INTO schema_migrations (version) VALUES ('27');
2465
2466 INSERT INTO schema_migrations (version) VALUES ('28');
2467
2468 INSERT INTO schema_migrations (version) VALUES ('29');
2469
2470 INSERT INTO schema_migrations (version) VALUES ('3');
2471
2472 INSERT INTO schema_migrations (version) VALUES ('30');
2473
2474 INSERT INTO schema_migrations (version) VALUES ('31');
2475
2476 INSERT INTO schema_migrations (version) VALUES ('32');
2477
2478 INSERT INTO schema_migrations (version) VALUES ('33');
2479
2480 INSERT INTO schema_migrations (version) VALUES ('34');
2481
2482 INSERT INTO schema_migrations (version) VALUES ('35');
2483
2484 INSERT INTO schema_migrations (version) VALUES ('36');
2485
2486 INSERT INTO schema_migrations (version) VALUES ('37');
2487
2488 INSERT INTO schema_migrations (version) VALUES ('38');
2489
2490 INSERT INTO schema_migrations (version) VALUES ('39');
2491
2492 INSERT INTO schema_migrations (version) VALUES ('4');
2493
2494 INSERT INTO schema_migrations (version) VALUES ('40');
2495
2496 INSERT INTO schema_migrations (version) VALUES ('41');
2497
2498 INSERT INTO schema_migrations (version) VALUES ('42');
2499
2500 INSERT INTO schema_migrations (version) VALUES ('43');
2501
2502 INSERT INTO schema_migrations (version) VALUES ('44');
2503
2504 INSERT INTO schema_migrations (version) VALUES ('45');
2505
2506 INSERT INTO schema_migrations (version) VALUES ('46');
2507
2508 INSERT INTO schema_migrations (version) VALUES ('47');
2509
2510 INSERT INTO schema_migrations (version) VALUES ('48');
2511
2512 INSERT INTO schema_migrations (version) VALUES ('49');
2513
2514 INSERT INTO schema_migrations (version) VALUES ('5');
2515
2516 INSERT INTO schema_migrations (version) VALUES ('50');
2517
2518 INSERT INTO schema_migrations (version) VALUES ('51');
2519
2520 INSERT INTO schema_migrations (version) VALUES ('52');
2521
2522 INSERT INTO schema_migrations (version) VALUES ('53');
2523
2524 INSERT INTO schema_migrations (version) VALUES ('54');
2525
2526 INSERT INTO schema_migrations (version) VALUES ('55');
2527
2528 INSERT INTO schema_migrations (version) VALUES ('56');
2529
2530 INSERT INTO schema_migrations (version) VALUES ('57');
2531
2532 INSERT INTO schema_migrations (version) VALUES ('6');
2533
2534 INSERT INTO schema_migrations (version) VALUES ('7');
2535
2536 INSERT INTO schema_migrations (version) VALUES ('8');
2537
2538 INSERT INTO schema_migrations (version) VALUES ('9');