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