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