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