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