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