]> git.openstreetmap.org Git - rails.git/blob - db/structure.sql
Replace the country table with a static XML countries file
[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 );
1077
1078
1079 --
1080 -- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1081 --
1082
1083 CREATE SEQUENCE users_id_seq
1084     START WITH 1
1085     INCREMENT BY 1
1086     NO MINVALUE
1087     NO MAXVALUE
1088     CACHE 1;
1089
1090
1091 --
1092 -- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1093 --
1094
1095 ALTER SEQUENCE users_id_seq OWNED BY users.id;
1096
1097
1098 --
1099 -- Name: way_nodes; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1100 --
1101
1102 CREATE TABLE way_nodes (
1103     way_id bigint NOT NULL,
1104     node_id bigint NOT NULL,
1105     version bigint NOT NULL,
1106     sequence_id bigint NOT NULL
1107 );
1108
1109
1110 --
1111 -- Name: way_tags; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1112 --
1113
1114 CREATE TABLE way_tags (
1115     way_id bigint DEFAULT 0 NOT NULL,
1116     k character varying(255) NOT NULL,
1117     v character varying(255) NOT NULL,
1118     version bigint NOT NULL
1119 );
1120
1121
1122 --
1123 -- Name: ways; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1124 --
1125
1126 CREATE TABLE ways (
1127     way_id bigint DEFAULT 0 NOT NULL,
1128     changeset_id bigint NOT NULL,
1129     "timestamp" timestamp without time zone NOT NULL,
1130     version bigint NOT NULL,
1131     visible boolean DEFAULT true NOT NULL,
1132     redaction_id integer
1133 );
1134
1135
1136 --
1137 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1138 --
1139
1140 ALTER TABLE ONLY acls ALTER COLUMN id SET DEFAULT nextval('acls_id_seq'::regclass);
1141
1142
1143 --
1144 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1145 --
1146
1147 ALTER TABLE ONLY changesets ALTER COLUMN id SET DEFAULT nextval('changesets_id_seq'::regclass);
1148
1149
1150 --
1151 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1152 --
1153
1154 ALTER TABLE ONLY client_applications ALTER COLUMN id SET DEFAULT nextval('client_applications_id_seq'::regclass);
1155
1156
1157 --
1158 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1159 --
1160
1161 ALTER TABLE ONLY current_nodes ALTER COLUMN id SET DEFAULT nextval('current_nodes_id_seq'::regclass);
1162
1163
1164 --
1165 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1166 --
1167
1168 ALTER TABLE ONLY current_relations ALTER COLUMN id SET DEFAULT nextval('current_relations_id_seq'::regclass);
1169
1170
1171 --
1172 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1173 --
1174
1175 ALTER TABLE ONLY current_ways ALTER COLUMN id SET DEFAULT nextval('current_ways_id_seq'::regclass);
1176
1177
1178 --
1179 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1180 --
1181
1182 ALTER TABLE ONLY diary_comments ALTER COLUMN id SET DEFAULT nextval('diary_comments_id_seq'::regclass);
1183
1184
1185 --
1186 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1187 --
1188
1189 ALTER TABLE ONLY diary_entries ALTER COLUMN id SET DEFAULT nextval('diary_entries_id_seq'::regclass);
1190
1191
1192 --
1193 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1194 --
1195
1196 ALTER TABLE ONLY friends ALTER COLUMN id SET DEFAULT nextval('friends_id_seq'::regclass);
1197
1198
1199 --
1200 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1201 --
1202
1203 ALTER TABLE ONLY gpx_file_tags ALTER COLUMN id SET DEFAULT nextval('gpx_file_tags_id_seq'::regclass);
1204
1205
1206 --
1207 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1208 --
1209
1210 ALTER TABLE ONLY gpx_files ALTER COLUMN id SET DEFAULT nextval('gpx_files_id_seq'::regclass);
1211
1212
1213 --
1214 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1215 --
1216
1217 ALTER TABLE ONLY messages ALTER COLUMN id SET DEFAULT nextval('messages_id_seq'::regclass);
1218
1219
1220 --
1221 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1222 --
1223
1224 ALTER TABLE ONLY note_comments ALTER COLUMN id SET DEFAULT nextval('note_comments_id_seq'::regclass);
1225
1226
1227 --
1228 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1229 --
1230
1231 ALTER TABLE ONLY notes ALTER COLUMN id SET DEFAULT nextval('notes_id_seq'::regclass);
1232
1233
1234 --
1235 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1236 --
1237
1238 ALTER TABLE ONLY oauth_nonces ALTER COLUMN id SET DEFAULT nextval('oauth_nonces_id_seq'::regclass);
1239
1240
1241 --
1242 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1243 --
1244
1245 ALTER TABLE ONLY oauth_tokens ALTER COLUMN id SET DEFAULT nextval('oauth_tokens_id_seq'::regclass);
1246
1247
1248 --
1249 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1250 --
1251
1252 ALTER TABLE ONLY redactions ALTER COLUMN id SET DEFAULT nextval('redactions_id_seq'::regclass);
1253
1254
1255 --
1256 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1257 --
1258
1259 ALTER TABLE ONLY user_blocks ALTER COLUMN id SET DEFAULT nextval('user_blocks_id_seq'::regclass);
1260
1261
1262 --
1263 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1264 --
1265
1266 ALTER TABLE ONLY user_roles ALTER COLUMN id SET DEFAULT nextval('user_roles_id_seq'::regclass);
1267
1268
1269 --
1270 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1271 --
1272
1273 ALTER TABLE ONLY user_tokens ALTER COLUMN id SET DEFAULT nextval('user_tokens_id_seq'::regclass);
1274
1275
1276 --
1277 -- Name: id; Type: DEFAULT; Schema: public; Owner: -
1278 --
1279
1280 ALTER TABLE ONLY users ALTER COLUMN id SET DEFAULT nextval('users_id_seq'::regclass);
1281
1282
1283 --
1284 -- Name: acls_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1285 --
1286
1287 ALTER TABLE ONLY acls
1288     ADD CONSTRAINT acls_pkey PRIMARY KEY (id);
1289
1290
1291 --
1292 -- Name: changesets_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1293 --
1294
1295 ALTER TABLE ONLY changesets
1296     ADD CONSTRAINT changesets_pkey PRIMARY KEY (id);
1297
1298
1299 --
1300 -- Name: client_applications_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1301 --
1302
1303 ALTER TABLE ONLY client_applications
1304     ADD CONSTRAINT client_applications_pkey PRIMARY KEY (id);
1305
1306
1307 --
1308 -- Name: current_node_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1309 --
1310
1311 ALTER TABLE ONLY current_node_tags
1312     ADD CONSTRAINT current_node_tags_pkey PRIMARY KEY (node_id, k);
1313
1314
1315 --
1316 -- Name: current_nodes_pkey1; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1317 --
1318
1319 ALTER TABLE ONLY current_nodes
1320     ADD CONSTRAINT current_nodes_pkey1 PRIMARY KEY (id);
1321
1322
1323 --
1324 -- Name: current_relation_members_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1325 --
1326
1327 ALTER TABLE ONLY current_relation_members
1328     ADD CONSTRAINT current_relation_members_pkey PRIMARY KEY (relation_id, member_type, member_id, member_role, sequence_id);
1329
1330
1331 --
1332 -- Name: current_relation_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1333 --
1334
1335 ALTER TABLE ONLY current_relation_tags
1336     ADD CONSTRAINT current_relation_tags_pkey PRIMARY KEY (relation_id, k);
1337
1338
1339 --
1340 -- Name: current_relations_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1341 --
1342
1343 ALTER TABLE ONLY current_relations
1344     ADD CONSTRAINT current_relations_pkey PRIMARY KEY (id);
1345
1346
1347 --
1348 -- Name: current_way_nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1349 --
1350
1351 ALTER TABLE ONLY current_way_nodes
1352     ADD CONSTRAINT current_way_nodes_pkey PRIMARY KEY (way_id, sequence_id);
1353
1354
1355 --
1356 -- Name: current_way_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1357 --
1358
1359 ALTER TABLE ONLY current_way_tags
1360     ADD CONSTRAINT current_way_tags_pkey PRIMARY KEY (way_id, k);
1361
1362
1363 --
1364 -- Name: current_ways_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1365 --
1366
1367 ALTER TABLE ONLY current_ways
1368     ADD CONSTRAINT current_ways_pkey PRIMARY KEY (id);
1369
1370
1371 --
1372 -- Name: diary_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1373 --
1374
1375 ALTER TABLE ONLY diary_comments
1376     ADD CONSTRAINT diary_comments_pkey PRIMARY KEY (id);
1377
1378
1379 --
1380 -- Name: diary_entries_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1381 --
1382
1383 ALTER TABLE ONLY diary_entries
1384     ADD CONSTRAINT diary_entries_pkey PRIMARY KEY (id);
1385
1386
1387 --
1388 -- Name: friends_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1389 --
1390
1391 ALTER TABLE ONLY friends
1392     ADD CONSTRAINT friends_pkey PRIMARY KEY (id);
1393
1394
1395 --
1396 -- Name: gpx_file_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1397 --
1398
1399 ALTER TABLE ONLY gpx_file_tags
1400     ADD CONSTRAINT gpx_file_tags_pkey PRIMARY KEY (id);
1401
1402
1403 --
1404 -- Name: gpx_files_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1405 --
1406
1407 ALTER TABLE ONLY gpx_files
1408     ADD CONSTRAINT gpx_files_pkey PRIMARY KEY (id);
1409
1410
1411 --
1412 -- Name: languages_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1413 --
1414
1415 ALTER TABLE ONLY languages
1416     ADD CONSTRAINT languages_pkey PRIMARY KEY (code);
1417
1418
1419 --
1420 -- Name: messages_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1421 --
1422
1423 ALTER TABLE ONLY messages
1424     ADD CONSTRAINT messages_pkey PRIMARY KEY (id);
1425
1426
1427 --
1428 -- Name: node_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1429 --
1430
1431 ALTER TABLE ONLY node_tags
1432     ADD CONSTRAINT node_tags_pkey PRIMARY KEY (node_id, version, k);
1433
1434
1435 --
1436 -- Name: nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1437 --
1438
1439 ALTER TABLE ONLY nodes
1440     ADD CONSTRAINT nodes_pkey PRIMARY KEY (node_id, version);
1441
1442
1443 --
1444 -- Name: note_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1445 --
1446
1447 ALTER TABLE ONLY note_comments
1448     ADD CONSTRAINT note_comments_pkey PRIMARY KEY (id);
1449
1450
1451 --
1452 -- Name: notes_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1453 --
1454
1455 ALTER TABLE ONLY notes
1456     ADD CONSTRAINT notes_pkey PRIMARY KEY (id);
1457
1458
1459 --
1460 -- Name: oauth_nonces_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1461 --
1462
1463 ALTER TABLE ONLY oauth_nonces
1464     ADD CONSTRAINT oauth_nonces_pkey PRIMARY KEY (id);
1465
1466
1467 --
1468 -- Name: oauth_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1469 --
1470
1471 ALTER TABLE ONLY oauth_tokens
1472     ADD CONSTRAINT oauth_tokens_pkey PRIMARY KEY (id);
1473
1474
1475 --
1476 -- Name: redactions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1477 --
1478
1479 ALTER TABLE ONLY redactions
1480     ADD CONSTRAINT redactions_pkey PRIMARY KEY (id);
1481
1482
1483 --
1484 -- Name: relation_members_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1485 --
1486
1487 ALTER TABLE ONLY relation_members
1488     ADD CONSTRAINT relation_members_pkey PRIMARY KEY (relation_id, version, member_type, member_id, member_role, sequence_id);
1489
1490
1491 --
1492 -- Name: relation_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1493 --
1494
1495 ALTER TABLE ONLY relation_tags
1496     ADD CONSTRAINT relation_tags_pkey PRIMARY KEY (relation_id, version, k);
1497
1498
1499 --
1500 -- Name: relations_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1501 --
1502
1503 ALTER TABLE ONLY relations
1504     ADD CONSTRAINT relations_pkey PRIMARY KEY (relation_id, version);
1505
1506
1507 --
1508 -- Name: user_blocks_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1509 --
1510
1511 ALTER TABLE ONLY user_blocks
1512     ADD CONSTRAINT user_blocks_pkey PRIMARY KEY (id);
1513
1514
1515 --
1516 -- Name: user_preferences_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1517 --
1518
1519 ALTER TABLE ONLY user_preferences
1520     ADD CONSTRAINT user_preferences_pkey PRIMARY KEY (user_id, k);
1521
1522
1523 --
1524 -- Name: user_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1525 --
1526
1527 ALTER TABLE ONLY user_roles
1528     ADD CONSTRAINT user_roles_pkey PRIMARY KEY (id);
1529
1530
1531 --
1532 -- Name: user_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1533 --
1534
1535 ALTER TABLE ONLY user_tokens
1536     ADD CONSTRAINT user_tokens_pkey PRIMARY KEY (id);
1537
1538
1539 --
1540 -- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1541 --
1542
1543 ALTER TABLE ONLY users
1544     ADD CONSTRAINT users_pkey PRIMARY KEY (id);
1545
1546
1547 --
1548 -- Name: way_nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1549 --
1550
1551 ALTER TABLE ONLY way_nodes
1552     ADD CONSTRAINT way_nodes_pkey PRIMARY KEY (way_id, version, sequence_id);
1553
1554
1555 --
1556 -- Name: way_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1557 --
1558
1559 ALTER TABLE ONLY way_tags
1560     ADD CONSTRAINT way_tags_pkey PRIMARY KEY (way_id, version, k);
1561
1562
1563 --
1564 -- Name: ways_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
1565 --
1566
1567 ALTER TABLE ONLY ways
1568     ADD CONSTRAINT ways_pkey PRIMARY KEY (way_id, version);
1569
1570
1571 --
1572 -- Name: acls_k_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1573 --
1574
1575 CREATE INDEX acls_k_idx ON acls USING btree (k);
1576
1577
1578 --
1579 -- Name: changeset_tags_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1580 --
1581
1582 CREATE INDEX changeset_tags_id_idx ON changeset_tags USING btree (changeset_id);
1583
1584
1585 --
1586 -- Name: changesets_bbox_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1587 --
1588
1589 CREATE INDEX changesets_bbox_idx ON changesets USING gist (min_lat, max_lat, min_lon, max_lon);
1590
1591
1592 --
1593 -- Name: changesets_closed_at_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1594 --
1595
1596 CREATE INDEX changesets_closed_at_idx ON changesets USING btree (closed_at);
1597
1598
1599 --
1600 -- Name: changesets_created_at_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1601 --
1602
1603 CREATE INDEX changesets_created_at_idx ON changesets USING btree (created_at);
1604
1605
1606 --
1607 -- Name: changesets_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1608 --
1609
1610 CREATE INDEX changesets_user_id_created_at_idx ON changesets USING btree (user_id, created_at);
1611
1612
1613 --
1614 -- Name: changesets_user_id_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1615 --
1616
1617 CREATE INDEX changesets_user_id_id_idx ON changesets USING btree (user_id, id);
1618
1619
1620 --
1621 -- Name: current_nodes_tile_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1622 --
1623
1624 CREATE INDEX current_nodes_tile_idx ON current_nodes USING btree (tile);
1625
1626
1627 --
1628 -- Name: current_nodes_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1629 --
1630
1631 CREATE INDEX current_nodes_timestamp_idx ON current_nodes USING btree ("timestamp");
1632
1633
1634 --
1635 -- Name: current_relation_members_member_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1636 --
1637
1638 CREATE INDEX current_relation_members_member_idx ON current_relation_members USING btree (member_type, member_id);
1639
1640
1641 --
1642 -- Name: current_relations_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1643 --
1644
1645 CREATE INDEX current_relations_timestamp_idx ON current_relations USING btree ("timestamp");
1646
1647
1648 --
1649 -- Name: current_way_nodes_node_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1650 --
1651
1652 CREATE INDEX current_way_nodes_node_idx ON current_way_nodes USING btree (node_id);
1653
1654
1655 --
1656 -- Name: current_ways_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1657 --
1658
1659 CREATE INDEX current_ways_timestamp_idx ON current_ways USING btree ("timestamp");
1660
1661
1662 --
1663 -- Name: diary_comment_user_id_created_at_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1664 --
1665
1666 CREATE INDEX diary_comment_user_id_created_at_index ON diary_comments USING btree (user_id, created_at);
1667
1668
1669 --
1670 -- Name: diary_comments_entry_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1671 --
1672
1673 CREATE UNIQUE INDEX diary_comments_entry_id_idx ON diary_comments USING btree (diary_entry_id, id);
1674
1675
1676 --
1677 -- Name: diary_entry_created_at_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1678 --
1679
1680 CREATE INDEX diary_entry_created_at_index ON diary_entries USING btree (created_at);
1681
1682
1683 --
1684 -- Name: diary_entry_language_code_created_at_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1685 --
1686
1687 CREATE INDEX diary_entry_language_code_created_at_index ON diary_entries USING btree (language_code, created_at);
1688
1689
1690 --
1691 -- Name: diary_entry_user_id_created_at_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1692 --
1693
1694 CREATE INDEX diary_entry_user_id_created_at_index ON diary_entries USING btree (user_id, created_at);
1695
1696
1697 --
1698 -- Name: friends_user_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1699 --
1700
1701 CREATE INDEX friends_user_id_idx ON friends USING btree (user_id);
1702
1703
1704 --
1705 -- Name: gpx_file_tags_gpxid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1706 --
1707
1708 CREATE INDEX gpx_file_tags_gpxid_idx ON gpx_file_tags USING btree (gpx_id);
1709
1710
1711 --
1712 -- Name: gpx_file_tags_tag_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1713 --
1714
1715 CREATE INDEX gpx_file_tags_tag_idx ON gpx_file_tags USING btree (tag);
1716
1717
1718 --
1719 -- Name: gpx_files_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1720 --
1721
1722 CREATE INDEX gpx_files_timestamp_idx ON gpx_files USING btree ("timestamp");
1723
1724
1725 --
1726 -- Name: gpx_files_user_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1727 --
1728
1729 CREATE INDEX gpx_files_user_id_idx ON gpx_files USING btree (user_id);
1730
1731
1732 --
1733 -- Name: gpx_files_visible_visibility_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1734 --
1735
1736 CREATE INDEX gpx_files_visible_visibility_idx ON gpx_files USING btree (visible, visibility);
1737
1738
1739 --
1740 -- Name: index_client_applications_on_key; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1741 --
1742
1743 CREATE UNIQUE INDEX index_client_applications_on_key ON client_applications USING btree (key);
1744
1745
1746 --
1747 -- Name: index_note_comments_on_body; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1748 --
1749
1750 CREATE INDEX index_note_comments_on_body ON note_comments USING gin (to_tsvector('english'::regconfig, body));
1751
1752
1753 --
1754 -- Name: index_note_comments_on_created_at; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1755 --
1756
1757 CREATE INDEX index_note_comments_on_created_at ON note_comments USING btree (created_at);
1758
1759
1760 --
1761 -- Name: index_oauth_nonces_on_nonce_and_timestamp; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1762 --
1763
1764 CREATE UNIQUE INDEX index_oauth_nonces_on_nonce_and_timestamp ON oauth_nonces USING btree (nonce, "timestamp");
1765
1766
1767 --
1768 -- Name: index_oauth_tokens_on_token; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1769 --
1770
1771 CREATE UNIQUE INDEX index_oauth_tokens_on_token ON oauth_tokens USING btree (token);
1772
1773
1774 --
1775 -- Name: index_user_blocks_on_user_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1776 --
1777
1778 CREATE INDEX index_user_blocks_on_user_id ON user_blocks USING btree (user_id);
1779
1780
1781 --
1782 -- Name: messages_from_user_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1783 --
1784
1785 CREATE INDEX messages_from_user_id_idx ON messages USING btree (from_user_id);
1786
1787
1788 --
1789 -- Name: messages_to_user_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1790 --
1791
1792 CREATE INDEX messages_to_user_id_idx ON messages USING btree (to_user_id);
1793
1794
1795 --
1796 -- Name: nodes_changeset_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1797 --
1798
1799 CREATE INDEX nodes_changeset_id_idx ON nodes USING btree (changeset_id);
1800
1801
1802 --
1803 -- Name: nodes_tile_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1804 --
1805
1806 CREATE INDEX nodes_tile_idx ON nodes USING btree (tile);
1807
1808
1809 --
1810 -- Name: nodes_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1811 --
1812
1813 CREATE INDEX nodes_timestamp_idx ON nodes USING btree ("timestamp");
1814
1815
1816 --
1817 -- Name: note_comments_note_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1818 --
1819
1820 CREATE INDEX note_comments_note_id_idx ON note_comments USING btree (note_id);
1821
1822
1823 --
1824 -- Name: notes_created_at_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1825 --
1826
1827 CREATE INDEX notes_created_at_idx ON notes USING btree (created_at);
1828
1829
1830 --
1831 -- Name: notes_tile_status_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1832 --
1833
1834 CREATE INDEX notes_tile_status_idx ON notes USING btree (tile, status);
1835
1836
1837 --
1838 -- Name: notes_updated_at_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1839 --
1840
1841 CREATE INDEX notes_updated_at_idx ON notes USING btree (updated_at);
1842
1843
1844 --
1845 -- Name: points_gpxid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1846 --
1847
1848 CREATE INDEX points_gpxid_idx ON gps_points USING btree (gpx_id);
1849
1850
1851 --
1852 -- Name: points_tile_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1853 --
1854
1855 CREATE INDEX points_tile_idx ON gps_points USING btree (tile);
1856
1857
1858 --
1859 -- Name: relation_members_member_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1860 --
1861
1862 CREATE INDEX relation_members_member_idx ON relation_members USING btree (member_type, member_id);
1863
1864
1865 --
1866 -- Name: relations_changeset_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1867 --
1868
1869 CREATE INDEX relations_changeset_id_idx ON relations USING btree (changeset_id);
1870
1871
1872 --
1873 -- Name: relations_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1874 --
1875
1876 CREATE INDEX relations_timestamp_idx ON relations USING btree ("timestamp");
1877
1878
1879 --
1880 -- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1881 --
1882
1883 CREATE UNIQUE INDEX unique_schema_migrations ON schema_migrations USING btree (version);
1884
1885
1886 --
1887 -- Name: user_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1888 --
1889
1890 CREATE INDEX user_id_idx ON friends USING btree (friend_user_id);
1891
1892
1893 --
1894 -- Name: user_openid_url_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1895 --
1896
1897 CREATE UNIQUE INDEX user_openid_url_idx ON users USING btree (openid_url);
1898
1899
1900 --
1901 -- Name: user_roles_id_role_unique; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1902 --
1903
1904 CREATE UNIQUE INDEX user_roles_id_role_unique ON user_roles USING btree (user_id, role);
1905
1906
1907 --
1908 -- Name: user_tokens_token_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1909 --
1910
1911 CREATE UNIQUE INDEX user_tokens_token_idx ON user_tokens USING btree (token);
1912
1913
1914 --
1915 -- Name: user_tokens_user_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1916 --
1917
1918 CREATE INDEX user_tokens_user_id_idx ON user_tokens USING btree (user_id);
1919
1920
1921 --
1922 -- Name: users_display_name_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1923 --
1924
1925 CREATE UNIQUE INDEX users_display_name_idx ON users USING btree (display_name);
1926
1927
1928 --
1929 -- Name: users_display_name_lower_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1930 --
1931
1932 CREATE INDEX users_display_name_lower_idx ON users USING btree (lower((display_name)::text));
1933
1934
1935 --
1936 -- Name: users_email_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1937 --
1938
1939 CREATE UNIQUE INDEX users_email_idx ON users USING btree (email);
1940
1941
1942 --
1943 -- Name: users_email_lower_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1944 --
1945
1946 CREATE INDEX users_email_lower_idx ON users USING btree (lower((email)::text));
1947
1948
1949 --
1950 -- Name: way_nodes_node_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1951 --
1952
1953 CREATE INDEX way_nodes_node_idx ON way_nodes USING btree (node_id);
1954
1955
1956 --
1957 -- Name: ways_changeset_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1958 --
1959
1960 CREATE INDEX ways_changeset_id_idx ON ways USING btree (changeset_id);
1961
1962
1963 --
1964 -- Name: ways_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
1965 --
1966
1967 CREATE INDEX ways_timestamp_idx ON ways USING btree ("timestamp");
1968
1969
1970 --
1971 -- Name: changeset_tags_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
1972 --
1973
1974 ALTER TABLE ONLY changeset_tags
1975     ADD CONSTRAINT changeset_tags_id_fkey FOREIGN KEY (changeset_id) REFERENCES changesets(id);
1976
1977
1978 --
1979 -- Name: changesets_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
1980 --
1981
1982 ALTER TABLE ONLY changesets
1983     ADD CONSTRAINT changesets_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
1984
1985
1986 --
1987 -- Name: client_applications_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
1988 --
1989
1990 ALTER TABLE ONLY client_applications
1991     ADD CONSTRAINT client_applications_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
1992
1993
1994 --
1995 -- Name: current_node_tags_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
1996 --
1997
1998 ALTER TABLE ONLY current_node_tags
1999     ADD CONSTRAINT current_node_tags_id_fkey FOREIGN KEY (node_id) REFERENCES current_nodes(id);
2000
2001
2002 --
2003 -- Name: current_nodes_changeset_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2004 --
2005
2006 ALTER TABLE ONLY current_nodes
2007     ADD CONSTRAINT current_nodes_changeset_id_fkey FOREIGN KEY (changeset_id) REFERENCES changesets(id);
2008
2009
2010 --
2011 -- Name: current_relation_members_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2012 --
2013
2014 ALTER TABLE ONLY current_relation_members
2015     ADD CONSTRAINT current_relation_members_id_fkey FOREIGN KEY (relation_id) REFERENCES current_relations(id);
2016
2017
2018 --
2019 -- Name: current_relation_tags_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2020 --
2021
2022 ALTER TABLE ONLY current_relation_tags
2023     ADD CONSTRAINT current_relation_tags_id_fkey FOREIGN KEY (relation_id) REFERENCES current_relations(id);
2024
2025
2026 --
2027 -- Name: current_relations_changeset_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2028 --
2029
2030 ALTER TABLE ONLY current_relations
2031     ADD CONSTRAINT current_relations_changeset_id_fkey FOREIGN KEY (changeset_id) REFERENCES changesets(id);
2032
2033
2034 --
2035 -- Name: current_way_nodes_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2036 --
2037
2038 ALTER TABLE ONLY current_way_nodes
2039     ADD CONSTRAINT current_way_nodes_id_fkey FOREIGN KEY (way_id) REFERENCES current_ways(id);
2040
2041
2042 --
2043 -- Name: current_way_nodes_node_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2044 --
2045
2046 ALTER TABLE ONLY current_way_nodes
2047     ADD CONSTRAINT current_way_nodes_node_id_fkey FOREIGN KEY (node_id) REFERENCES current_nodes(id);
2048
2049
2050 --
2051 -- Name: current_way_tags_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2052 --
2053
2054 ALTER TABLE ONLY current_way_tags
2055     ADD CONSTRAINT current_way_tags_id_fkey FOREIGN KEY (way_id) REFERENCES current_ways(id);
2056
2057
2058 --
2059 -- Name: current_ways_changeset_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2060 --
2061
2062 ALTER TABLE ONLY current_ways
2063     ADD CONSTRAINT current_ways_changeset_id_fkey FOREIGN KEY (changeset_id) REFERENCES changesets(id);
2064
2065
2066 --
2067 -- Name: diary_comments_diary_entry_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2068 --
2069
2070 ALTER TABLE ONLY diary_comments
2071     ADD CONSTRAINT diary_comments_diary_entry_id_fkey FOREIGN KEY (diary_entry_id) REFERENCES diary_entries(id);
2072
2073
2074 --
2075 -- Name: diary_comments_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2076 --
2077
2078 ALTER TABLE ONLY diary_comments
2079     ADD CONSTRAINT diary_comments_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
2080
2081
2082 --
2083 -- Name: diary_entries_language_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2084 --
2085
2086 ALTER TABLE ONLY diary_entries
2087     ADD CONSTRAINT diary_entries_language_code_fkey FOREIGN KEY (language_code) REFERENCES languages(code);
2088
2089
2090 --
2091 -- Name: diary_entries_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2092 --
2093
2094 ALTER TABLE ONLY diary_entries
2095     ADD CONSTRAINT diary_entries_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
2096
2097
2098 --
2099 -- Name: friends_friend_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2100 --
2101
2102 ALTER TABLE ONLY friends
2103     ADD CONSTRAINT friends_friend_user_id_fkey FOREIGN KEY (friend_user_id) REFERENCES users(id);
2104
2105
2106 --
2107 -- Name: friends_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2108 --
2109
2110 ALTER TABLE ONLY friends
2111     ADD CONSTRAINT friends_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
2112
2113
2114 --
2115 -- Name: gps_points_gpx_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2116 --
2117
2118 ALTER TABLE ONLY gps_points
2119     ADD CONSTRAINT gps_points_gpx_id_fkey FOREIGN KEY (gpx_id) REFERENCES gpx_files(id);
2120
2121
2122 --
2123 -- Name: gpx_file_tags_gpx_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2124 --
2125
2126 ALTER TABLE ONLY gpx_file_tags
2127     ADD CONSTRAINT gpx_file_tags_gpx_id_fkey FOREIGN KEY (gpx_id) REFERENCES gpx_files(id);
2128
2129
2130 --
2131 -- Name: gpx_files_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2132 --
2133
2134 ALTER TABLE ONLY gpx_files
2135     ADD CONSTRAINT gpx_files_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
2136
2137
2138 --
2139 -- Name: messages_from_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2140 --
2141
2142 ALTER TABLE ONLY messages
2143     ADD CONSTRAINT messages_from_user_id_fkey FOREIGN KEY (from_user_id) REFERENCES users(id);
2144
2145
2146 --
2147 -- Name: messages_to_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2148 --
2149
2150 ALTER TABLE ONLY messages
2151     ADD CONSTRAINT messages_to_user_id_fkey FOREIGN KEY (to_user_id) REFERENCES users(id);
2152
2153
2154 --
2155 -- Name: node_tags_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2156 --
2157
2158 ALTER TABLE ONLY node_tags
2159     ADD CONSTRAINT node_tags_id_fkey FOREIGN KEY (node_id, version) REFERENCES nodes(node_id, version);
2160
2161
2162 --
2163 -- Name: nodes_changeset_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2164 --
2165
2166 ALTER TABLE ONLY nodes
2167     ADD CONSTRAINT nodes_changeset_id_fkey FOREIGN KEY (changeset_id) REFERENCES changesets(id);
2168
2169
2170 --
2171 -- Name: nodes_redaction_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2172 --
2173
2174 ALTER TABLE ONLY nodes
2175     ADD CONSTRAINT nodes_redaction_id_fkey FOREIGN KEY (redaction_id) REFERENCES redactions(id);
2176
2177
2178 --
2179 -- Name: note_comments_author_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2180 --
2181
2182 ALTER TABLE ONLY note_comments
2183     ADD CONSTRAINT note_comments_author_id_fkey FOREIGN KEY (author_id) REFERENCES users(id);
2184
2185
2186 --
2187 -- Name: note_comments_note_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2188 --
2189
2190 ALTER TABLE ONLY note_comments
2191     ADD CONSTRAINT note_comments_note_id_fkey FOREIGN KEY (note_id) REFERENCES notes(id);
2192
2193
2194 --
2195 -- Name: oauth_tokens_client_application_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2196 --
2197
2198 ALTER TABLE ONLY oauth_tokens
2199     ADD CONSTRAINT oauth_tokens_client_application_id_fkey FOREIGN KEY (client_application_id) REFERENCES client_applications(id);
2200
2201
2202 --
2203 -- Name: oauth_tokens_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2204 --
2205
2206 ALTER TABLE ONLY oauth_tokens
2207     ADD CONSTRAINT oauth_tokens_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
2208
2209
2210 --
2211 -- Name: redactions_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2212 --
2213
2214 ALTER TABLE ONLY redactions
2215     ADD CONSTRAINT redactions_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
2216
2217
2218 --
2219 -- Name: relation_members_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2220 --
2221
2222 ALTER TABLE ONLY relation_members
2223     ADD CONSTRAINT relation_members_id_fkey FOREIGN KEY (relation_id, version) REFERENCES relations(relation_id, version);
2224
2225
2226 --
2227 -- Name: relation_tags_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2228 --
2229
2230 ALTER TABLE ONLY relation_tags
2231     ADD CONSTRAINT relation_tags_id_fkey FOREIGN KEY (relation_id, version) REFERENCES relations(relation_id, version);
2232
2233
2234 --
2235 -- Name: relations_changeset_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2236 --
2237
2238 ALTER TABLE ONLY relations
2239     ADD CONSTRAINT relations_changeset_id_fkey FOREIGN KEY (changeset_id) REFERENCES changesets(id);
2240
2241
2242 --
2243 -- Name: relations_redaction_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2244 --
2245
2246 ALTER TABLE ONLY relations
2247     ADD CONSTRAINT relations_redaction_id_fkey FOREIGN KEY (redaction_id) REFERENCES redactions(id);
2248
2249
2250 --
2251 -- Name: user_blocks_moderator_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2252 --
2253
2254 ALTER TABLE ONLY user_blocks
2255     ADD CONSTRAINT user_blocks_moderator_id_fkey FOREIGN KEY (creator_id) REFERENCES users(id);
2256
2257
2258 --
2259 -- Name: user_blocks_revoker_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2260 --
2261
2262 ALTER TABLE ONLY user_blocks
2263     ADD CONSTRAINT user_blocks_revoker_id_fkey FOREIGN KEY (revoker_id) REFERENCES users(id);
2264
2265
2266 --
2267 -- Name: user_blocks_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2268 --
2269
2270 ALTER TABLE ONLY user_blocks
2271     ADD CONSTRAINT user_blocks_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
2272
2273
2274 --
2275 -- Name: user_preferences_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2276 --
2277
2278 ALTER TABLE ONLY user_preferences
2279     ADD CONSTRAINT user_preferences_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
2280
2281
2282 --
2283 -- Name: user_roles_granter_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2284 --
2285
2286 ALTER TABLE ONLY user_roles
2287     ADD CONSTRAINT user_roles_granter_id_fkey FOREIGN KEY (granter_id) REFERENCES users(id);
2288
2289
2290 --
2291 -- Name: user_roles_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2292 --
2293
2294 ALTER TABLE ONLY user_roles
2295     ADD CONSTRAINT user_roles_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
2296
2297
2298 --
2299 -- Name: user_tokens_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2300 --
2301
2302 ALTER TABLE ONLY user_tokens
2303     ADD CONSTRAINT user_tokens_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
2304
2305
2306 --
2307 -- Name: way_nodes_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2308 --
2309
2310 ALTER TABLE ONLY way_nodes
2311     ADD CONSTRAINT way_nodes_id_fkey FOREIGN KEY (way_id, version) REFERENCES ways(way_id, version);
2312
2313
2314 --
2315 -- Name: way_tags_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2316 --
2317
2318 ALTER TABLE ONLY way_tags
2319     ADD CONSTRAINT way_tags_id_fkey FOREIGN KEY (way_id, version) REFERENCES ways(way_id, version);
2320
2321
2322 --
2323 -- Name: ways_changeset_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2324 --
2325
2326 ALTER TABLE ONLY ways
2327     ADD CONSTRAINT ways_changeset_id_fkey FOREIGN KEY (changeset_id) REFERENCES changesets(id);
2328
2329
2330 --
2331 -- Name: ways_redaction_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2332 --
2333
2334 ALTER TABLE ONLY ways
2335     ADD CONSTRAINT ways_redaction_id_fkey FOREIGN KEY (redaction_id) REFERENCES redactions(id);
2336
2337
2338 --
2339 -- PostgreSQL database dump complete
2340 --
2341
2342 SET search_path TO "$user",public;
2343
2344 INSERT INTO schema_migrations (version) VALUES ('1');
2345
2346 INSERT INTO schema_migrations (version) VALUES ('10');
2347
2348 INSERT INTO schema_migrations (version) VALUES ('11');
2349
2350 INSERT INTO schema_migrations (version) VALUES ('12');
2351
2352 INSERT INTO schema_migrations (version) VALUES ('13');
2353
2354 INSERT INTO schema_migrations (version) VALUES ('14');
2355
2356 INSERT INTO schema_migrations (version) VALUES ('15');
2357
2358 INSERT INTO schema_migrations (version) VALUES ('16');
2359
2360 INSERT INTO schema_migrations (version) VALUES ('17');
2361
2362 INSERT INTO schema_migrations (version) VALUES ('18');
2363
2364 INSERT INTO schema_migrations (version) VALUES ('19');
2365
2366 INSERT INTO schema_migrations (version) VALUES ('2');
2367
2368 INSERT INTO schema_migrations (version) VALUES ('20');
2369
2370 INSERT INTO schema_migrations (version) VALUES ('20100513171259');
2371
2372 INSERT INTO schema_migrations (version) VALUES ('20100516124737');
2373
2374 INSERT INTO schema_migrations (version) VALUES ('20100910084426');
2375
2376 INSERT INTO schema_migrations (version) VALUES ('20101114011429');
2377
2378 INSERT INTO schema_migrations (version) VALUES ('20110322001319');
2379
2380 INSERT INTO schema_migrations (version) VALUES ('20110508145337');
2381
2382 INSERT INTO schema_migrations (version) VALUES ('20110521142405');
2383
2384 INSERT INTO schema_migrations (version) VALUES ('20110925112722');
2385
2386 INSERT INTO schema_migrations (version) VALUES ('20111116184519');
2387
2388 INSERT INTO schema_migrations (version) VALUES ('20111212183945');
2389
2390 INSERT INTO schema_migrations (version) VALUES ('20120123184321');
2391
2392 INSERT INTO schema_migrations (version) VALUES ('20120208122334');
2393
2394 INSERT INTO schema_migrations (version) VALUES ('20120208194454');
2395
2396 INSERT INTO schema_migrations (version) VALUES ('20120214210114');
2397
2398 INSERT INTO schema_migrations (version) VALUES ('20120219161649');
2399
2400 INSERT INTO schema_migrations (version) VALUES ('20120318201948');
2401
2402 INSERT INTO schema_migrations (version) VALUES ('20120328090602');
2403
2404 INSERT INTO schema_migrations (version) VALUES ('20120404205604');
2405
2406 INSERT INTO schema_migrations (version) VALUES ('20120808231205');
2407
2408 INSERT INTO schema_migrations (version) VALUES ('20121005195010');
2409
2410 INSERT INTO schema_migrations (version) VALUES ('20121012044047');
2411
2412 INSERT INTO schema_migrations (version) VALUES ('20121119165817');
2413
2414 INSERT INTO schema_migrations (version) VALUES ('20121202155309');
2415
2416 INSERT INTO schema_migrations (version) VALUES ('20121203124841');
2417
2418 INSERT INTO schema_migrations (version) VALUES ('20130328184137');
2419
2420 INSERT INTO schema_migrations (version) VALUES ('20131212124700');
2421
2422 INSERT INTO schema_migrations (version) VALUES ('20140115192822');
2423
2424 INSERT INTO schema_migrations (version) VALUES ('20140117185510');
2425
2426 INSERT INTO schema_migrations (version) VALUES ('21');
2427
2428 INSERT INTO schema_migrations (version) VALUES ('22');
2429
2430 INSERT INTO schema_migrations (version) VALUES ('23');
2431
2432 INSERT INTO schema_migrations (version) VALUES ('24');
2433
2434 INSERT INTO schema_migrations (version) VALUES ('25');
2435
2436 INSERT INTO schema_migrations (version) VALUES ('26');
2437
2438 INSERT INTO schema_migrations (version) VALUES ('27');
2439
2440 INSERT INTO schema_migrations (version) VALUES ('28');
2441
2442 INSERT INTO schema_migrations (version) VALUES ('29');
2443
2444 INSERT INTO schema_migrations (version) VALUES ('3');
2445
2446 INSERT INTO schema_migrations (version) VALUES ('30');
2447
2448 INSERT INTO schema_migrations (version) VALUES ('31');
2449
2450 INSERT INTO schema_migrations (version) VALUES ('32');
2451
2452 INSERT INTO schema_migrations (version) VALUES ('33');
2453
2454 INSERT INTO schema_migrations (version) VALUES ('34');
2455
2456 INSERT INTO schema_migrations (version) VALUES ('35');
2457
2458 INSERT INTO schema_migrations (version) VALUES ('36');
2459
2460 INSERT INTO schema_migrations (version) VALUES ('37');
2461
2462 INSERT INTO schema_migrations (version) VALUES ('38');
2463
2464 INSERT INTO schema_migrations (version) VALUES ('39');
2465
2466 INSERT INTO schema_migrations (version) VALUES ('4');
2467
2468 INSERT INTO schema_migrations (version) VALUES ('40');
2469
2470 INSERT INTO schema_migrations (version) VALUES ('41');
2471
2472 INSERT INTO schema_migrations (version) VALUES ('42');
2473
2474 INSERT INTO schema_migrations (version) VALUES ('43');
2475
2476 INSERT INTO schema_migrations (version) VALUES ('44');
2477
2478 INSERT INTO schema_migrations (version) VALUES ('45');
2479
2480 INSERT INTO schema_migrations (version) VALUES ('46');
2481
2482 INSERT INTO schema_migrations (version) VALUES ('47');
2483
2484 INSERT INTO schema_migrations (version) VALUES ('48');
2485
2486 INSERT INTO schema_migrations (version) VALUES ('49');
2487
2488 INSERT INTO schema_migrations (version) VALUES ('5');
2489
2490 INSERT INTO schema_migrations (version) VALUES ('50');
2491
2492 INSERT INTO schema_migrations (version) VALUES ('51');
2493
2494 INSERT INTO schema_migrations (version) VALUES ('52');
2495
2496 INSERT INTO schema_migrations (version) VALUES ('53');
2497
2498 INSERT INTO schema_migrations (version) VALUES ('54');
2499
2500 INSERT INTO schema_migrations (version) VALUES ('55');
2501
2502 INSERT INTO schema_migrations (version) VALUES ('56');
2503
2504 INSERT INTO schema_migrations (version) VALUES ('57');
2505
2506 INSERT INTO schema_migrations (version) VALUES ('6');
2507
2508 INSERT INTO schema_migrations (version) VALUES ('7');
2509
2510 INSERT INTO schema_migrations (version) VALUES ('8');
2511
2512 INSERT INTO schema_migrations (version) VALUES ('9');