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