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