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