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