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