]> git.openstreetmap.org Git - rails.git/blob - db/structure.sql
Merge remote-tracking branch 'upstream/pull/5957'
[rails.git] / db / structure.sql
1 SET statement_timeout = 0;
2 SET lock_timeout = 0;
3 SET idle_in_transaction_session_timeout = 0;
4 SET client_encoding = 'UTF8';
5 SET standard_conforming_strings = on;
6 SELECT pg_catalog.set_config('search_path', '', false);
7 SET check_function_bodies = false;
8 SET xmloption = content;
9 SET client_min_messages = warning;
10 SET row_security = off;
11
12 --
13 -- Name: public; Type: SCHEMA; Schema: -; Owner: -
14 --
15
16 -- *not* creating schema, since initdb creates it
17
18
19 --
20 -- Name: btree_gist; Type: EXTENSION; Schema: -; Owner: -
21 --
22
23 CREATE EXTENSION IF NOT EXISTS btree_gist WITH SCHEMA public;
24
25
26 --
27 -- Name: EXTENSION btree_gist; Type: COMMENT; Schema: -; Owner: -
28 --
29
30 COMMENT ON EXTENSION btree_gist IS 'support for indexing common datatypes in GiST';
31
32
33 --
34 -- Name: format_enum; Type: TYPE; Schema: public; Owner: -
35 --
36
37 CREATE TYPE public.format_enum AS ENUM (
38     'html',
39     'markdown',
40     'text'
41 );
42
43
44 --
45 -- Name: gpx_visibility_enum; Type: TYPE; Schema: public; Owner: -
46 --
47
48 CREATE TYPE public.gpx_visibility_enum AS ENUM (
49     'private',
50     'public',
51     'trackable',
52     'identifiable'
53 );
54
55
56 --
57 -- Name: issue_status_enum; Type: TYPE; Schema: public; Owner: -
58 --
59
60 CREATE TYPE public.issue_status_enum AS ENUM (
61     'open',
62     'ignored',
63     'resolved'
64 );
65
66
67 --
68 -- Name: note_event_enum; Type: TYPE; Schema: public; Owner: -
69 --
70
71 CREATE TYPE public.note_event_enum AS ENUM (
72     'opened',
73     'closed',
74     'reopened',
75     'commented',
76     'hidden'
77 );
78
79
80 --
81 -- Name: note_status_enum; Type: TYPE; Schema: public; Owner: -
82 --
83
84 CREATE TYPE public.note_status_enum AS ENUM (
85     'open',
86     'closed',
87     'hidden'
88 );
89
90
91 --
92 -- Name: nwr_enum; Type: TYPE; Schema: public; Owner: -
93 --
94
95 CREATE TYPE public.nwr_enum AS ENUM (
96     'Node',
97     'Way',
98     'Relation'
99 );
100
101
102 --
103 -- Name: user_role_enum; Type: TYPE; Schema: public; Owner: -
104 --
105
106 CREATE TYPE public.user_role_enum AS ENUM (
107     'administrator',
108     'moderator',
109     'importer'
110 );
111
112
113 --
114 -- Name: user_status_enum; Type: TYPE; Schema: public; Owner: -
115 --
116
117 CREATE TYPE public.user_status_enum AS ENUM (
118     'pending',
119     'active',
120     'confirmed',
121     'suspended',
122     'deleted'
123 );
124
125
126 --
127 -- Name: api_rate_limit(bigint); Type: FUNCTION; Schema: public; Owner: -
128 --
129
130 CREATE FUNCTION public.api_rate_limit(user_id bigint) RETURNS integer
131     LANGUAGE plpgsql STABLE
132     AS $$
133     DECLARE
134       min_changes_per_hour int4 := 100;
135       initial_changes_per_hour int4 := 1000;
136       max_changes_per_hour int4 := 100000;
137       days_to_max_changes int4 := 7;
138       importer_changes_per_hour int4 := 1000000;
139       moderator_changes_per_hour int4 := 1000000;
140       roles text[];
141       last_block timestamp without time zone;
142       first_change timestamp without time zone;
143       active_reports int4;
144       time_since_first_change double precision;
145       max_changes double precision;
146       recent_changes int4;
147     BEGIN
148       SELECT ARRAY_AGG(user_roles.role) INTO STRICT roles FROM user_roles WHERE user_roles.user_id = api_rate_limit.user_id;
149
150       IF 'moderator' = ANY(roles) THEN
151         max_changes := moderator_changes_per_hour;
152       ELSIF 'importer' = ANY(roles) THEN
153         max_changes := importer_changes_per_hour;
154       ELSE
155         SELECT user_blocks.created_at INTO last_block FROM user_blocks WHERE user_blocks.user_id = api_rate_limit.user_id ORDER BY user_blocks.created_at DESC LIMIT 1;
156
157         IF FOUND THEN
158           SELECT changesets.created_at INTO first_change FROM changesets WHERE changesets.user_id = api_rate_limit.user_id AND changesets.created_at > last_block ORDER BY changesets.created_at LIMIT 1;
159         ELSE
160           SELECT changesets.created_at INTO first_change FROM changesets WHERE changesets.user_id = api_rate_limit.user_id ORDER BY changesets.created_at LIMIT 1;
161         END IF;
162
163         IF NOT FOUND THEN
164           first_change := CURRENT_TIMESTAMP AT TIME ZONE 'UTC';
165         END IF;
166
167         SELECT COUNT(*) INTO STRICT active_reports
168         FROM issues INNER JOIN reports ON reports.issue_id = issues.id
169         WHERE issues.reported_user_id = api_rate_limit.user_id AND issues.status = 'open' AND reports.updated_at >= COALESCE(issues.resolved_at, '1970-01-01');
170
171         time_since_first_change := EXTRACT(EPOCH FROM CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - first_change);
172
173         max_changes := max_changes_per_hour * POWER(time_since_first_change, 2) / POWER(days_to_max_changes * 24 * 60 * 60, 2);
174         max_changes := GREATEST(initial_changes_per_hour, LEAST(max_changes_per_hour, FLOOR(max_changes)));
175         max_changes := max_changes / POWER(2, active_reports);
176         max_changes := GREATEST(min_changes_per_hour, LEAST(max_changes_per_hour, max_changes));
177       END IF;
178
179       SELECT COALESCE(SUM(changesets.num_changes), 0) INTO STRICT recent_changes FROM changesets WHERE changesets.user_id = api_rate_limit.user_id AND changesets.created_at >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - '1 hour'::interval;
180
181       RETURN max_changes - recent_changes;
182     END;
183     $$;
184
185
186 --
187 -- Name: api_size_limit(bigint); Type: FUNCTION; Schema: public; Owner: -
188 --
189
190 CREATE FUNCTION public.api_size_limit(user_id bigint) RETURNS bigint
191     LANGUAGE plpgsql STABLE
192     AS $$
193     DECLARE
194       min_size_limit int8 := 10000000;
195       initial_size_limit int8 := 30000000;
196       max_size_limit int8 := 5400000000;
197       days_to_max_size_limit int4 := 28;
198       importer_size_limit int8 := 5400000000;
199       moderator_size_limit int8 := 5400000000;
200       roles text[];
201       last_block timestamp without time zone;
202       first_change timestamp without time zone;
203       active_reports int4;
204       time_since_first_change double precision;
205       size_limit int8;
206     BEGIN
207       SELECT ARRAY_AGG(user_roles.role) INTO STRICT roles FROM user_roles WHERE user_roles.user_id = api_size_limit.user_id;
208
209       IF 'moderator' = ANY(roles) THEN
210         size_limit := moderator_size_limit;
211       ELSIF 'importer' = ANY(roles) THEN
212         size_limit := importer_size_limit;
213       ELSE
214         SELECT user_blocks.created_at INTO last_block FROM user_blocks WHERE user_blocks.user_id = api_size_limit.user_id ORDER BY user_blocks.created_at DESC LIMIT 1;
215
216         IF FOUND THEN
217           SELECT changesets.created_at INTO first_change FROM changesets WHERE changesets.user_id = api_size_limit.user_id AND changesets.created_at > last_block ORDER BY changesets.created_at LIMIT 1;
218         ELSE
219           SELECT changesets.created_at INTO first_change FROM changesets WHERE changesets.user_id = api_size_limit.user_id ORDER BY changesets.created_at LIMIT 1;
220         END IF;
221
222         IF NOT FOUND THEN
223           first_change := CURRENT_TIMESTAMP AT TIME ZONE 'UTC';
224         END IF;
225
226         SELECT COUNT(*) INTO STRICT active_reports
227         FROM issues INNER JOIN reports ON reports.issue_id = issues.id
228         WHERE issues.reported_user_id = api_size_limit.user_id AND issues.status = 'open' AND reports.updated_at >= COALESCE(issues.resolved_at, '1970-01-01');
229
230         time_since_first_change := EXTRACT(EPOCH FROM CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - first_change);
231
232         size_limit := max_size_limit * POWER(time_since_first_change, 2) / POWER(days_to_max_size_limit * 24 * 60 * 60, 2);
233         size_limit := GREATEST(initial_size_limit, LEAST(max_size_limit, FLOOR(size_limit)));
234         size_limit := size_limit / POWER(2, active_reports);
235         size_limit := GREATEST(min_size_limit, LEAST(max_size_limit, size_limit));
236       END IF;
237
238       RETURN size_limit;
239     END;
240     $$;
241
242
243 SET default_tablespace = '';
244
245 SET default_table_access_method = heap;
246
247 --
248 -- Name: acls; Type: TABLE; Schema: public; Owner: -
249 --
250
251 CREATE TABLE public.acls (
252     id bigint NOT NULL,
253     address inet,
254     k character varying NOT NULL,
255     v character varying,
256     domain character varying,
257     mx character varying
258 );
259
260
261 --
262 -- Name: acls_id_seq; Type: SEQUENCE; Schema: public; Owner: -
263 --
264
265 CREATE SEQUENCE public.acls_id_seq
266     START WITH 1
267     INCREMENT BY 1
268     NO MINVALUE
269     NO MAXVALUE
270     CACHE 1;
271
272
273 --
274 -- Name: acls_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
275 --
276
277 ALTER SEQUENCE public.acls_id_seq OWNED BY public.acls.id;
278
279
280 --
281 -- Name: active_storage_attachments; Type: TABLE; Schema: public; Owner: -
282 --
283
284 CREATE TABLE public.active_storage_attachments (
285     id bigint NOT NULL,
286     name character varying NOT NULL,
287     record_type character varying NOT NULL,
288     record_id bigint NOT NULL,
289     blob_id bigint NOT NULL,
290     created_at timestamp without time zone NOT NULL
291 );
292
293
294 --
295 -- Name: active_storage_attachments_id_seq; Type: SEQUENCE; Schema: public; Owner: -
296 --
297
298 CREATE SEQUENCE public.active_storage_attachments_id_seq
299     START WITH 1
300     INCREMENT BY 1
301     NO MINVALUE
302     NO MAXVALUE
303     CACHE 1;
304
305
306 --
307 -- Name: active_storage_attachments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
308 --
309
310 ALTER SEQUENCE public.active_storage_attachments_id_seq OWNED BY public.active_storage_attachments.id;
311
312
313 --
314 -- Name: active_storage_blobs; Type: TABLE; Schema: public; Owner: -
315 --
316
317 CREATE TABLE public.active_storage_blobs (
318     id bigint NOT NULL,
319     key character varying NOT NULL,
320     filename character varying NOT NULL,
321     content_type character varying,
322     metadata text,
323     byte_size bigint NOT NULL,
324     checksum character varying,
325     created_at timestamp without time zone NOT NULL,
326     service_name character varying NOT NULL
327 );
328
329
330 --
331 -- Name: active_storage_blobs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
332 --
333
334 CREATE SEQUENCE public.active_storage_blobs_id_seq
335     START WITH 1
336     INCREMENT BY 1
337     NO MINVALUE
338     NO MAXVALUE
339     CACHE 1;
340
341
342 --
343 -- Name: active_storage_blobs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
344 --
345
346 ALTER SEQUENCE public.active_storage_blobs_id_seq OWNED BY public.active_storage_blobs.id;
347
348
349 --
350 -- Name: active_storage_variant_records; Type: TABLE; Schema: public; Owner: -
351 --
352
353 CREATE TABLE public.active_storage_variant_records (
354     id bigint NOT NULL,
355     blob_id bigint NOT NULL,
356     variation_digest character varying NOT NULL
357 );
358
359
360 --
361 -- Name: active_storage_variant_records_id_seq; Type: SEQUENCE; Schema: public; Owner: -
362 --
363
364 CREATE SEQUENCE public.active_storage_variant_records_id_seq
365     START WITH 1
366     INCREMENT BY 1
367     NO MINVALUE
368     NO MAXVALUE
369     CACHE 1;
370
371
372 --
373 -- Name: active_storage_variant_records_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
374 --
375
376 ALTER SEQUENCE public.active_storage_variant_records_id_seq OWNED BY public.active_storage_variant_records.id;
377
378
379 --
380 -- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: -
381 --
382
383 CREATE TABLE public.ar_internal_metadata (
384     key character varying NOT NULL,
385     value character varying,
386     created_at timestamp(6) without time zone NOT NULL,
387     updated_at timestamp(6) without time zone NOT NULL
388 );
389
390
391 --
392 -- Name: changeset_comments; Type: TABLE; Schema: public; Owner: -
393 --
394
395 CREATE TABLE public.changeset_comments (
396     id integer NOT NULL,
397     changeset_id bigint NOT NULL,
398     author_id bigint NOT NULL,
399     body text NOT NULL,
400     created_at timestamp without time zone NOT NULL,
401     visible boolean NOT NULL
402 );
403
404
405 --
406 -- Name: changeset_comments_id_seq; Type: SEQUENCE; Schema: public; Owner: -
407 --
408
409 CREATE SEQUENCE public.changeset_comments_id_seq
410     AS integer
411     START WITH 1
412     INCREMENT BY 1
413     NO MINVALUE
414     NO MAXVALUE
415     CACHE 1;
416
417
418 --
419 -- Name: changeset_comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
420 --
421
422 ALTER SEQUENCE public.changeset_comments_id_seq OWNED BY public.changeset_comments.id;
423
424
425 --
426 -- Name: changeset_tags; Type: TABLE; Schema: public; Owner: -
427 --
428
429 CREATE TABLE public.changeset_tags (
430     changeset_id bigint NOT NULL,
431     k character varying DEFAULT ''::character varying NOT NULL,
432     v character varying DEFAULT ''::character varying NOT NULL
433 );
434
435
436 --
437 -- Name: changesets; Type: TABLE; Schema: public; Owner: -
438 --
439
440 CREATE TABLE public.changesets (
441     id bigint NOT NULL,
442     user_id bigint NOT NULL,
443     created_at timestamp without time zone NOT NULL,
444     min_lat integer,
445     max_lat integer,
446     min_lon integer,
447     max_lon integer,
448     closed_at timestamp without time zone NOT NULL,
449     num_changes integer DEFAULT 0 NOT NULL
450 );
451
452
453 --
454 -- Name: changesets_id_seq; Type: SEQUENCE; Schema: public; Owner: -
455 --
456
457 CREATE SEQUENCE public.changesets_id_seq
458     START WITH 1
459     INCREMENT BY 1
460     NO MINVALUE
461     NO MAXVALUE
462     CACHE 1;
463
464
465 --
466 -- Name: changesets_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
467 --
468
469 ALTER SEQUENCE public.changesets_id_seq OWNED BY public.changesets.id;
470
471
472 --
473 -- Name: changesets_subscribers; Type: TABLE; Schema: public; Owner: -
474 --
475
476 CREATE TABLE public.changesets_subscribers (
477     subscriber_id bigint NOT NULL,
478     changeset_id bigint NOT NULL
479 );
480
481
482 --
483 -- Name: current_node_tags; Type: TABLE; Schema: public; Owner: -
484 --
485
486 CREATE TABLE public.current_node_tags (
487     node_id bigint NOT NULL,
488     k character varying DEFAULT ''::character varying NOT NULL,
489     v character varying DEFAULT ''::character varying NOT NULL
490 );
491
492
493 --
494 -- Name: current_nodes; Type: TABLE; Schema: public; Owner: -
495 --
496
497 CREATE TABLE public.current_nodes (
498     id bigint NOT NULL,
499     latitude integer NOT NULL,
500     longitude integer NOT NULL,
501     changeset_id bigint NOT NULL,
502     visible boolean NOT NULL,
503     "timestamp" timestamp without time zone NOT NULL,
504     tile bigint NOT NULL,
505     version bigint NOT NULL
506 );
507
508
509 --
510 -- Name: current_nodes_id_seq; Type: SEQUENCE; Schema: public; Owner: -
511 --
512
513 CREATE SEQUENCE public.current_nodes_id_seq
514     START WITH 1
515     INCREMENT BY 1
516     NO MINVALUE
517     NO MAXVALUE
518     CACHE 1;
519
520
521 --
522 -- Name: current_nodes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
523 --
524
525 ALTER SEQUENCE public.current_nodes_id_seq OWNED BY public.current_nodes.id;
526
527
528 --
529 -- Name: current_relation_members; Type: TABLE; Schema: public; Owner: -
530 --
531
532 CREATE TABLE public.current_relation_members (
533     relation_id bigint NOT NULL,
534     member_type public.nwr_enum NOT NULL,
535     member_id bigint NOT NULL,
536     member_role character varying NOT NULL,
537     sequence_id integer DEFAULT 0 NOT NULL
538 );
539
540
541 --
542 -- Name: current_relation_tags; Type: TABLE; Schema: public; Owner: -
543 --
544
545 CREATE TABLE public.current_relation_tags (
546     relation_id bigint NOT NULL,
547     k character varying DEFAULT ''::character varying NOT NULL,
548     v character varying DEFAULT ''::character varying NOT NULL
549 );
550
551
552 --
553 -- Name: current_relations; Type: TABLE; Schema: public; Owner: -
554 --
555
556 CREATE TABLE public.current_relations (
557     id bigint NOT NULL,
558     changeset_id bigint NOT NULL,
559     "timestamp" timestamp without time zone NOT NULL,
560     visible boolean NOT NULL,
561     version bigint NOT NULL
562 );
563
564
565 --
566 -- Name: current_relations_id_seq; Type: SEQUENCE; Schema: public; Owner: -
567 --
568
569 CREATE SEQUENCE public.current_relations_id_seq
570     START WITH 1
571     INCREMENT BY 1
572     NO MINVALUE
573     NO MAXVALUE
574     CACHE 1;
575
576
577 --
578 -- Name: current_relations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
579 --
580
581 ALTER SEQUENCE public.current_relations_id_seq OWNED BY public.current_relations.id;
582
583
584 --
585 -- Name: current_way_nodes; Type: TABLE; Schema: public; Owner: -
586 --
587
588 CREATE TABLE public.current_way_nodes (
589     way_id bigint NOT NULL,
590     node_id bigint NOT NULL,
591     sequence_id bigint NOT NULL
592 );
593
594
595 --
596 -- Name: current_way_tags; Type: TABLE; Schema: public; Owner: -
597 --
598
599 CREATE TABLE public.current_way_tags (
600     way_id bigint NOT NULL,
601     k character varying DEFAULT ''::character varying NOT NULL,
602     v character varying DEFAULT ''::character varying NOT NULL
603 );
604
605
606 --
607 -- Name: current_ways; Type: TABLE; Schema: public; Owner: -
608 --
609
610 CREATE TABLE public.current_ways (
611     id bigint NOT NULL,
612     changeset_id bigint NOT NULL,
613     "timestamp" timestamp without time zone NOT NULL,
614     visible boolean NOT NULL,
615     version bigint NOT NULL
616 );
617
618
619 --
620 -- Name: current_ways_id_seq; Type: SEQUENCE; Schema: public; Owner: -
621 --
622
623 CREATE SEQUENCE public.current_ways_id_seq
624     START WITH 1
625     INCREMENT BY 1
626     NO MINVALUE
627     NO MAXVALUE
628     CACHE 1;
629
630
631 --
632 -- Name: current_ways_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
633 --
634
635 ALTER SEQUENCE public.current_ways_id_seq OWNED BY public.current_ways.id;
636
637
638 --
639 -- Name: delayed_jobs; Type: TABLE; Schema: public; Owner: -
640 --
641
642 CREATE TABLE public.delayed_jobs (
643     id bigint NOT NULL,
644     priority integer DEFAULT 0 NOT NULL,
645     attempts integer DEFAULT 0 NOT NULL,
646     handler text NOT NULL,
647     last_error text,
648     run_at timestamp without time zone,
649     locked_at timestamp without time zone,
650     failed_at timestamp without time zone,
651     locked_by character varying,
652     queue character varying,
653     created_at timestamp without time zone,
654     updated_at timestamp without time zone
655 );
656
657
658 --
659 -- Name: delayed_jobs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
660 --
661
662 CREATE SEQUENCE public.delayed_jobs_id_seq
663     START WITH 1
664     INCREMENT BY 1
665     NO MINVALUE
666     NO MAXVALUE
667     CACHE 1;
668
669
670 --
671 -- Name: delayed_jobs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
672 --
673
674 ALTER SEQUENCE public.delayed_jobs_id_seq OWNED BY public.delayed_jobs.id;
675
676
677 --
678 -- Name: diary_comments; Type: TABLE; Schema: public; Owner: -
679 --
680
681 CREATE TABLE public.diary_comments (
682     id bigint NOT NULL,
683     diary_entry_id bigint NOT NULL,
684     user_id bigint NOT NULL,
685     body text NOT NULL,
686     created_at timestamp without time zone NOT NULL,
687     updated_at timestamp without time zone NOT NULL,
688     visible boolean DEFAULT true NOT NULL,
689     body_format public.format_enum DEFAULT 'markdown'::public.format_enum NOT NULL
690 );
691
692
693 --
694 -- Name: diary_comments_id_seq; Type: SEQUENCE; Schema: public; Owner: -
695 --
696
697 CREATE SEQUENCE public.diary_comments_id_seq
698     START WITH 1
699     INCREMENT BY 1
700     NO MINVALUE
701     NO MAXVALUE
702     CACHE 1;
703
704
705 --
706 -- Name: diary_comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
707 --
708
709 ALTER SEQUENCE public.diary_comments_id_seq OWNED BY public.diary_comments.id;
710
711
712 --
713 -- Name: diary_entries; Type: TABLE; Schema: public; Owner: -
714 --
715
716 CREATE TABLE public.diary_entries (
717     id bigint NOT NULL,
718     user_id bigint NOT NULL,
719     title character varying NOT NULL,
720     body text NOT NULL,
721     created_at timestamp without time zone NOT NULL,
722     updated_at timestamp without time zone NOT NULL,
723     latitude double precision,
724     longitude double precision,
725     language_code character varying DEFAULT 'en'::character varying NOT NULL,
726     visible boolean DEFAULT true NOT NULL,
727     body_format public.format_enum DEFAULT 'markdown'::public.format_enum NOT NULL
728 );
729
730
731 --
732 -- Name: diary_entries_id_seq; Type: SEQUENCE; Schema: public; Owner: -
733 --
734
735 CREATE SEQUENCE public.diary_entries_id_seq
736     START WITH 1
737     INCREMENT BY 1
738     NO MINVALUE
739     NO MAXVALUE
740     CACHE 1;
741
742
743 --
744 -- Name: diary_entries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
745 --
746
747 ALTER SEQUENCE public.diary_entries_id_seq OWNED BY public.diary_entries.id;
748
749
750 --
751 -- Name: diary_entry_subscriptions; Type: TABLE; Schema: public; Owner: -
752 --
753
754 CREATE TABLE public.diary_entry_subscriptions (
755     user_id bigint NOT NULL,
756     diary_entry_id bigint NOT NULL
757 );
758
759
760 --
761 -- Name: friends; Type: TABLE; Schema: public; Owner: -
762 --
763
764 CREATE TABLE public.friends (
765     id bigint NOT NULL,
766     user_id bigint NOT NULL,
767     friend_user_id bigint NOT NULL,
768     created_at timestamp without time zone
769 );
770
771
772 --
773 -- Name: friends_id_seq; Type: SEQUENCE; Schema: public; Owner: -
774 --
775
776 CREATE SEQUENCE public.friends_id_seq
777     START WITH 1
778     INCREMENT BY 1
779     NO MINVALUE
780     NO MAXVALUE
781     CACHE 1;
782
783
784 --
785 -- Name: friends_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
786 --
787
788 ALTER SEQUENCE public.friends_id_seq OWNED BY public.friends.id;
789
790
791 --
792 -- Name: gps_points; Type: TABLE; Schema: public; Owner: -
793 --
794
795 CREATE TABLE public.gps_points (
796     altitude double precision,
797     trackid integer NOT NULL,
798     latitude integer NOT NULL,
799     longitude integer NOT NULL,
800     gpx_id bigint NOT NULL,
801     "timestamp" timestamp without time zone,
802     tile bigint
803 );
804
805
806 --
807 -- Name: gpx_file_tags; Type: TABLE; Schema: public; Owner: -
808 --
809
810 CREATE TABLE public.gpx_file_tags (
811     gpx_id bigint NOT NULL,
812     tag character varying NOT NULL,
813     id bigint NOT NULL
814 );
815
816
817 --
818 -- Name: gpx_file_tags_id_seq; Type: SEQUENCE; Schema: public; Owner: -
819 --
820
821 CREATE SEQUENCE public.gpx_file_tags_id_seq
822     START WITH 1
823     INCREMENT BY 1
824     NO MINVALUE
825     NO MAXVALUE
826     CACHE 1;
827
828
829 --
830 -- Name: gpx_file_tags_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
831 --
832
833 ALTER SEQUENCE public.gpx_file_tags_id_seq OWNED BY public.gpx_file_tags.id;
834
835
836 --
837 -- Name: gpx_files; Type: TABLE; Schema: public; Owner: -
838 --
839
840 CREATE TABLE public.gpx_files (
841     id bigint NOT NULL,
842     user_id bigint NOT NULL,
843     visible boolean DEFAULT true NOT NULL,
844     name character varying DEFAULT ''::character varying NOT NULL,
845     size bigint,
846     latitude double precision,
847     longitude double precision,
848     "timestamp" timestamp without time zone NOT NULL,
849     description character varying DEFAULT ''::character varying NOT NULL,
850     inserted boolean NOT NULL,
851     visibility public.gpx_visibility_enum DEFAULT 'public'::public.gpx_visibility_enum NOT NULL
852 );
853
854
855 --
856 -- Name: gpx_files_id_seq; Type: SEQUENCE; Schema: public; Owner: -
857 --
858
859 CREATE SEQUENCE public.gpx_files_id_seq
860     START WITH 1
861     INCREMENT BY 1
862     NO MINVALUE
863     NO MAXVALUE
864     CACHE 1;
865
866
867 --
868 -- Name: gpx_files_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
869 --
870
871 ALTER SEQUENCE public.gpx_files_id_seq OWNED BY public.gpx_files.id;
872
873
874 --
875 -- Name: issue_comments; Type: TABLE; Schema: public; Owner: -
876 --
877
878 CREATE TABLE public.issue_comments (
879     id integer NOT NULL,
880     issue_id integer NOT NULL,
881     user_id integer NOT NULL,
882     body text NOT NULL,
883     created_at timestamp without time zone NOT NULL,
884     updated_at timestamp without time zone NOT NULL
885 );
886
887
888 --
889 -- Name: issue_comments_id_seq; Type: SEQUENCE; Schema: public; Owner: -
890 --
891
892 CREATE SEQUENCE public.issue_comments_id_seq
893     AS integer
894     START WITH 1
895     INCREMENT BY 1
896     NO MINVALUE
897     NO MAXVALUE
898     CACHE 1;
899
900
901 --
902 -- Name: issue_comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
903 --
904
905 ALTER SEQUENCE public.issue_comments_id_seq OWNED BY public.issue_comments.id;
906
907
908 --
909 -- Name: issues; Type: TABLE; Schema: public; Owner: -
910 --
911
912 CREATE TABLE public.issues (
913     id integer NOT NULL,
914     reportable_type character varying NOT NULL,
915     reportable_id integer NOT NULL,
916     reported_user_id integer,
917     status public.issue_status_enum DEFAULT 'open'::public.issue_status_enum NOT NULL,
918     assigned_role public.user_role_enum NOT NULL,
919     resolved_at timestamp without time zone,
920     resolved_by integer,
921     updated_by integer,
922     reports_count integer DEFAULT 0,
923     created_at timestamp without time zone NOT NULL,
924     updated_at timestamp without time zone NOT NULL
925 );
926
927
928 --
929 -- Name: issues_id_seq; Type: SEQUENCE; Schema: public; Owner: -
930 --
931
932 CREATE SEQUENCE public.issues_id_seq
933     AS integer
934     START WITH 1
935     INCREMENT BY 1
936     NO MINVALUE
937     NO MAXVALUE
938     CACHE 1;
939
940
941 --
942 -- Name: issues_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
943 --
944
945 ALTER SEQUENCE public.issues_id_seq OWNED BY public.issues.id;
946
947
948 --
949 -- Name: languages; Type: TABLE; Schema: public; Owner: -
950 --
951
952 CREATE TABLE public.languages (
953     code character varying NOT NULL,
954     english_name character varying NOT NULL,
955     native_name character varying
956 );
957
958
959 --
960 -- Name: messages; Type: TABLE; Schema: public; Owner: -
961 --
962
963 CREATE TABLE public.messages (
964     id bigint NOT NULL,
965     from_user_id bigint NOT NULL,
966     title character varying NOT NULL,
967     body text NOT NULL,
968     sent_on timestamp without time zone NOT NULL,
969     message_read boolean DEFAULT false NOT NULL,
970     to_user_id bigint NOT NULL,
971     to_user_visible boolean DEFAULT true NOT NULL,
972     from_user_visible boolean DEFAULT true NOT NULL,
973     body_format public.format_enum DEFAULT 'markdown'::public.format_enum NOT NULL,
974     muted boolean DEFAULT false NOT NULL
975 );
976
977
978 --
979 -- Name: messages_id_seq; Type: SEQUENCE; Schema: public; Owner: -
980 --
981
982 CREATE SEQUENCE public.messages_id_seq
983     START WITH 1
984     INCREMENT BY 1
985     NO MINVALUE
986     NO MAXVALUE
987     CACHE 1;
988
989
990 --
991 -- Name: messages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
992 --
993
994 ALTER SEQUENCE public.messages_id_seq OWNED BY public.messages.id;
995
996
997 --
998 -- Name: node_tags; Type: TABLE; Schema: public; Owner: -
999 --
1000
1001 CREATE TABLE public.node_tags (
1002     node_id bigint NOT NULL,
1003     version bigint NOT NULL,
1004     k character varying DEFAULT ''::character varying NOT NULL,
1005     v character varying DEFAULT ''::character varying NOT NULL
1006 );
1007
1008
1009 --
1010 -- Name: nodes; Type: TABLE; Schema: public; Owner: -
1011 --
1012
1013 CREATE TABLE public.nodes (
1014     node_id bigint NOT NULL,
1015     latitude integer NOT NULL,
1016     longitude integer NOT NULL,
1017     changeset_id bigint NOT NULL,
1018     visible boolean NOT NULL,
1019     "timestamp" timestamp without time zone NOT NULL,
1020     tile bigint NOT NULL,
1021     version bigint NOT NULL,
1022     redaction_id integer
1023 );
1024
1025
1026 --
1027 -- Name: note_comments; Type: TABLE; Schema: public; Owner: -
1028 --
1029
1030 CREATE TABLE public.note_comments (
1031     id bigint NOT NULL,
1032     note_id bigint NOT NULL,
1033     visible boolean NOT NULL,
1034     created_at timestamp without time zone NOT NULL,
1035     author_ip inet,
1036     author_id bigint,
1037     body text,
1038     event public.note_event_enum
1039 );
1040
1041
1042 --
1043 -- Name: note_comments_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1044 --
1045
1046 CREATE SEQUENCE public.note_comments_id_seq
1047     START WITH 1
1048     INCREMENT BY 1
1049     NO MINVALUE
1050     NO MAXVALUE
1051     CACHE 1;
1052
1053
1054 --
1055 -- Name: note_comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1056 --
1057
1058 ALTER SEQUENCE public.note_comments_id_seq OWNED BY public.note_comments.id;
1059
1060
1061 --
1062 -- Name: note_subscriptions; Type: TABLE; Schema: public; Owner: -
1063 --
1064
1065 CREATE TABLE public.note_subscriptions (
1066     user_id bigint NOT NULL,
1067     note_id bigint NOT NULL
1068 );
1069
1070
1071 --
1072 -- Name: notes; Type: TABLE; Schema: public; Owner: -
1073 --
1074
1075 CREATE TABLE public.notes (
1076     id bigint NOT NULL,
1077     latitude integer NOT NULL,
1078     longitude integer NOT NULL,
1079     tile bigint NOT NULL,
1080     updated_at timestamp without time zone NOT NULL,
1081     created_at timestamp without time zone NOT NULL,
1082     status public.note_status_enum NOT NULL,
1083     closed_at timestamp without time zone,
1084     description text DEFAULT ''::text NOT NULL,
1085     user_id bigint,
1086     user_ip inet
1087 );
1088
1089
1090 --
1091 -- Name: notes_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1092 --
1093
1094 CREATE SEQUENCE public.notes_id_seq
1095     START WITH 1
1096     INCREMENT BY 1
1097     NO MINVALUE
1098     NO MAXVALUE
1099     CACHE 1;
1100
1101
1102 --
1103 -- Name: notes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1104 --
1105
1106 ALTER SEQUENCE public.notes_id_seq OWNED BY public.notes.id;
1107
1108
1109 --
1110 -- Name: oauth_access_grants; Type: TABLE; Schema: public; Owner: -
1111 --
1112
1113 CREATE TABLE public.oauth_access_grants (
1114     id bigint NOT NULL,
1115     resource_owner_id bigint NOT NULL,
1116     application_id bigint NOT NULL,
1117     token character varying NOT NULL,
1118     expires_in integer NOT NULL,
1119     redirect_uri text NOT NULL,
1120     created_at timestamp without time zone NOT NULL,
1121     revoked_at timestamp without time zone,
1122     scopes character varying DEFAULT ''::character varying NOT NULL,
1123     code_challenge character varying,
1124     code_challenge_method character varying
1125 );
1126
1127
1128 --
1129 -- Name: oauth_access_grants_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1130 --
1131
1132 CREATE SEQUENCE public.oauth_access_grants_id_seq
1133     START WITH 1
1134     INCREMENT BY 1
1135     NO MINVALUE
1136     NO MAXVALUE
1137     CACHE 1;
1138
1139
1140 --
1141 -- Name: oauth_access_grants_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1142 --
1143
1144 ALTER SEQUENCE public.oauth_access_grants_id_seq OWNED BY public.oauth_access_grants.id;
1145
1146
1147 --
1148 -- Name: oauth_access_tokens; Type: TABLE; Schema: public; Owner: -
1149 --
1150
1151 CREATE TABLE public.oauth_access_tokens (
1152     id bigint NOT NULL,
1153     resource_owner_id bigint,
1154     application_id bigint NOT NULL,
1155     token character varying NOT NULL,
1156     refresh_token character varying,
1157     expires_in integer,
1158     revoked_at timestamp without time zone,
1159     created_at timestamp without time zone NOT NULL,
1160     scopes character varying,
1161     previous_refresh_token character varying DEFAULT ''::character varying NOT NULL
1162 );
1163
1164
1165 --
1166 -- Name: oauth_access_tokens_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1167 --
1168
1169 CREATE SEQUENCE public.oauth_access_tokens_id_seq
1170     START WITH 1
1171     INCREMENT BY 1
1172     NO MINVALUE
1173     NO MAXVALUE
1174     CACHE 1;
1175
1176
1177 --
1178 -- Name: oauth_access_tokens_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1179 --
1180
1181 ALTER SEQUENCE public.oauth_access_tokens_id_seq OWNED BY public.oauth_access_tokens.id;
1182
1183
1184 --
1185 -- Name: oauth_applications; Type: TABLE; Schema: public; Owner: -
1186 --
1187
1188 CREATE TABLE public.oauth_applications (
1189     id bigint NOT NULL,
1190     owner_type character varying NOT NULL,
1191     owner_id bigint NOT NULL,
1192     name character varying NOT NULL,
1193     uid character varying NOT NULL,
1194     secret character varying NOT NULL,
1195     redirect_uri text NOT NULL,
1196     scopes character varying DEFAULT ''::character varying NOT NULL,
1197     confidential boolean DEFAULT true NOT NULL,
1198     created_at timestamp(6) without time zone NOT NULL,
1199     updated_at timestamp(6) without time zone NOT NULL
1200 );
1201
1202
1203 --
1204 -- Name: oauth_applications_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1205 --
1206
1207 CREATE SEQUENCE public.oauth_applications_id_seq
1208     START WITH 1
1209     INCREMENT BY 1
1210     NO MINVALUE
1211     NO MAXVALUE
1212     CACHE 1;
1213
1214
1215 --
1216 -- Name: oauth_applications_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1217 --
1218
1219 ALTER SEQUENCE public.oauth_applications_id_seq OWNED BY public.oauth_applications.id;
1220
1221
1222 --
1223 -- Name: oauth_openid_requests; Type: TABLE; Schema: public; Owner: -
1224 --
1225
1226 CREATE TABLE public.oauth_openid_requests (
1227     id bigint NOT NULL,
1228     access_grant_id bigint NOT NULL,
1229     nonce character varying NOT NULL
1230 );
1231
1232
1233 --
1234 -- Name: oauth_openid_requests_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1235 --
1236
1237 CREATE SEQUENCE public.oauth_openid_requests_id_seq
1238     START WITH 1
1239     INCREMENT BY 1
1240     NO MINVALUE
1241     NO MAXVALUE
1242     CACHE 1;
1243
1244
1245 --
1246 -- Name: oauth_openid_requests_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1247 --
1248
1249 ALTER SEQUENCE public.oauth_openid_requests_id_seq OWNED BY public.oauth_openid_requests.id;
1250
1251
1252 --
1253 -- Name: redactions; Type: TABLE; Schema: public; Owner: -
1254 --
1255
1256 CREATE TABLE public.redactions (
1257     id integer NOT NULL,
1258     title character varying NOT NULL,
1259     description text NOT NULL,
1260     created_at timestamp without time zone,
1261     updated_at timestamp without time zone,
1262     user_id bigint NOT NULL,
1263     description_format public.format_enum DEFAULT 'markdown'::public.format_enum NOT NULL
1264 );
1265
1266
1267 --
1268 -- Name: redactions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1269 --
1270
1271 CREATE SEQUENCE public.redactions_id_seq
1272     AS integer
1273     START WITH 1
1274     INCREMENT BY 1
1275     NO MINVALUE
1276     NO MAXVALUE
1277     CACHE 1;
1278
1279
1280 --
1281 -- Name: redactions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1282 --
1283
1284 ALTER SEQUENCE public.redactions_id_seq OWNED BY public.redactions.id;
1285
1286
1287 --
1288 -- Name: relation_members; Type: TABLE; Schema: public; Owner: -
1289 --
1290
1291 CREATE TABLE public.relation_members (
1292     relation_id bigint NOT NULL,
1293     member_type public.nwr_enum NOT NULL,
1294     member_id bigint NOT NULL,
1295     member_role character varying NOT NULL,
1296     version bigint DEFAULT 0 NOT NULL,
1297     sequence_id integer DEFAULT 0 NOT NULL
1298 );
1299
1300
1301 --
1302 -- Name: relation_tags; Type: TABLE; Schema: public; Owner: -
1303 --
1304
1305 CREATE TABLE public.relation_tags (
1306     relation_id bigint NOT NULL,
1307     k character varying DEFAULT ''::character varying NOT NULL,
1308     v character varying DEFAULT ''::character varying NOT NULL,
1309     version bigint NOT NULL
1310 );
1311
1312
1313 --
1314 -- Name: relations; Type: TABLE; Schema: public; Owner: -
1315 --
1316
1317 CREATE TABLE public.relations (
1318     relation_id bigint NOT NULL,
1319     changeset_id bigint NOT NULL,
1320     "timestamp" timestamp without time zone NOT NULL,
1321     version bigint NOT NULL,
1322     visible boolean DEFAULT true NOT NULL,
1323     redaction_id integer
1324 );
1325
1326
1327 --
1328 -- Name: reports; Type: TABLE; Schema: public; Owner: -
1329 --
1330
1331 CREATE TABLE public.reports (
1332     id integer NOT NULL,
1333     issue_id integer NOT NULL,
1334     user_id integer NOT NULL,
1335     details text NOT NULL,
1336     category character varying NOT NULL,
1337     created_at timestamp without time zone NOT NULL,
1338     updated_at timestamp without time zone NOT NULL
1339 );
1340
1341
1342 --
1343 -- Name: reports_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1344 --
1345
1346 CREATE SEQUENCE public.reports_id_seq
1347     AS integer
1348     START WITH 1
1349     INCREMENT BY 1
1350     NO MINVALUE
1351     NO MAXVALUE
1352     CACHE 1;
1353
1354
1355 --
1356 -- Name: reports_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1357 --
1358
1359 ALTER SEQUENCE public.reports_id_seq OWNED BY public.reports.id;
1360
1361
1362 --
1363 -- Name: schema_migrations; Type: TABLE; Schema: public; Owner: -
1364 --
1365
1366 CREATE TABLE public.schema_migrations (
1367     version character varying NOT NULL
1368 );
1369
1370
1371 --
1372 -- Name: user_blocks; Type: TABLE; Schema: public; Owner: -
1373 --
1374
1375 CREATE TABLE public.user_blocks (
1376     id integer NOT NULL,
1377     user_id bigint NOT NULL,
1378     creator_id bigint NOT NULL,
1379     reason text NOT NULL,
1380     ends_at timestamp without time zone NOT NULL,
1381     needs_view boolean DEFAULT false NOT NULL,
1382     revoker_id bigint,
1383     created_at timestamp without time zone,
1384     updated_at timestamp without time zone,
1385     reason_format public.format_enum DEFAULT 'markdown'::public.format_enum NOT NULL,
1386     deactivates_at timestamp without time zone
1387 );
1388
1389
1390 --
1391 -- Name: user_blocks_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1392 --
1393
1394 CREATE SEQUENCE public.user_blocks_id_seq
1395     AS integer
1396     START WITH 1
1397     INCREMENT BY 1
1398     NO MINVALUE
1399     NO MAXVALUE
1400     CACHE 1;
1401
1402
1403 --
1404 -- Name: user_blocks_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1405 --
1406
1407 ALTER SEQUENCE public.user_blocks_id_seq OWNED BY public.user_blocks.id;
1408
1409
1410 --
1411 -- Name: user_mutes; Type: TABLE; Schema: public; Owner: -
1412 --
1413
1414 CREATE TABLE public.user_mutes (
1415     id bigint NOT NULL,
1416     owner_id bigint NOT NULL,
1417     subject_id bigint NOT NULL,
1418     created_at timestamp(6) without time zone NOT NULL,
1419     updated_at timestamp(6) without time zone NOT NULL
1420 );
1421
1422
1423 --
1424 -- Name: user_mutes_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1425 --
1426
1427 CREATE SEQUENCE public.user_mutes_id_seq
1428     START WITH 1
1429     INCREMENT BY 1
1430     NO MINVALUE
1431     NO MAXVALUE
1432     CACHE 1;
1433
1434
1435 --
1436 -- Name: user_mutes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1437 --
1438
1439 ALTER SEQUENCE public.user_mutes_id_seq OWNED BY public.user_mutes.id;
1440
1441
1442 --
1443 -- Name: user_preferences; Type: TABLE; Schema: public; Owner: -
1444 --
1445
1446 CREATE TABLE public.user_preferences (
1447     user_id bigint NOT NULL,
1448     k character varying NOT NULL,
1449     v character varying NOT NULL
1450 );
1451
1452
1453 --
1454 -- Name: user_roles; Type: TABLE; Schema: public; Owner: -
1455 --
1456
1457 CREATE TABLE public.user_roles (
1458     id integer NOT NULL,
1459     user_id bigint NOT NULL,
1460     role public.user_role_enum NOT NULL,
1461     created_at timestamp without time zone,
1462     updated_at timestamp without time zone,
1463     granter_id bigint NOT NULL
1464 );
1465
1466
1467 --
1468 -- Name: user_roles_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1469 --
1470
1471 CREATE SEQUENCE public.user_roles_id_seq
1472     AS integer
1473     START WITH 1
1474     INCREMENT BY 1
1475     NO MINVALUE
1476     NO MAXVALUE
1477     CACHE 1;
1478
1479
1480 --
1481 -- Name: user_roles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1482 --
1483
1484 ALTER SEQUENCE public.user_roles_id_seq OWNED BY public.user_roles.id;
1485
1486
1487 --
1488 -- Name: users; Type: TABLE; Schema: public; Owner: -
1489 --
1490
1491 CREATE TABLE public.users (
1492     email character varying NOT NULL,
1493     id bigint NOT NULL,
1494     pass_crypt character varying NOT NULL,
1495     creation_time timestamp without time zone NOT NULL,
1496     display_name character varying DEFAULT ''::character varying NOT NULL,
1497     data_public boolean DEFAULT false NOT NULL,
1498     description text DEFAULT ''::text NOT NULL,
1499     home_lat double precision,
1500     home_lon double precision,
1501     home_zoom smallint DEFAULT 3,
1502     pass_salt character varying,
1503     email_valid boolean DEFAULT false NOT NULL,
1504     new_email character varying,
1505     languages character varying,
1506     status public.user_status_enum DEFAULT 'pending'::public.user_status_enum NOT NULL,
1507     terms_agreed timestamp without time zone,
1508     consider_pd boolean DEFAULT false NOT NULL,
1509     auth_uid character varying,
1510     preferred_editor character varying,
1511     terms_seen boolean DEFAULT false NOT NULL,
1512     description_format public.format_enum DEFAULT 'markdown'::public.format_enum NOT NULL,
1513     changesets_count integer DEFAULT 0 NOT NULL,
1514     traces_count integer DEFAULT 0 NOT NULL,
1515     diary_entries_count integer DEFAULT 0 NOT NULL,
1516     image_use_gravatar boolean DEFAULT false NOT NULL,
1517     auth_provider character varying,
1518     home_tile bigint,
1519     tou_agreed timestamp without time zone,
1520     diary_comments_count integer DEFAULT 0,
1521     note_comments_count integer DEFAULT 0,
1522     creation_address inet,
1523     home_location_name character varying
1524 );
1525
1526
1527 --
1528 -- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1529 --
1530
1531 CREATE SEQUENCE public.users_id_seq
1532     START WITH 1
1533     INCREMENT BY 1
1534     NO MINVALUE
1535     NO MAXVALUE
1536     CACHE 1;
1537
1538
1539 --
1540 -- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1541 --
1542
1543 ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
1544
1545
1546 --
1547 -- Name: way_nodes; Type: TABLE; Schema: public; Owner: -
1548 --
1549
1550 CREATE TABLE public.way_nodes (
1551     way_id bigint NOT NULL,
1552     node_id bigint NOT NULL,
1553     version bigint NOT NULL,
1554     sequence_id bigint NOT NULL
1555 );
1556
1557
1558 --
1559 -- Name: way_tags; Type: TABLE; Schema: public; Owner: -
1560 --
1561
1562 CREATE TABLE public.way_tags (
1563     way_id bigint NOT NULL,
1564     k character varying NOT NULL,
1565     v character varying NOT NULL,
1566     version bigint NOT NULL
1567 );
1568
1569
1570 --
1571 -- Name: ways; Type: TABLE; Schema: public; Owner: -
1572 --
1573
1574 CREATE TABLE public.ways (
1575     way_id bigint NOT NULL,
1576     changeset_id bigint NOT NULL,
1577     "timestamp" timestamp without time zone NOT NULL,
1578     version bigint NOT NULL,
1579     visible boolean DEFAULT true NOT NULL,
1580     redaction_id integer
1581 );
1582
1583
1584 --
1585 -- Name: acls id; Type: DEFAULT; Schema: public; Owner: -
1586 --
1587
1588 ALTER TABLE ONLY public.acls ALTER COLUMN id SET DEFAULT nextval('public.acls_id_seq'::regclass);
1589
1590
1591 --
1592 -- Name: active_storage_attachments id; Type: DEFAULT; Schema: public; Owner: -
1593 --
1594
1595 ALTER TABLE ONLY public.active_storage_attachments ALTER COLUMN id SET DEFAULT nextval('public.active_storage_attachments_id_seq'::regclass);
1596
1597
1598 --
1599 -- Name: active_storage_blobs id; Type: DEFAULT; Schema: public; Owner: -
1600 --
1601
1602 ALTER TABLE ONLY public.active_storage_blobs ALTER COLUMN id SET DEFAULT nextval('public.active_storage_blobs_id_seq'::regclass);
1603
1604
1605 --
1606 -- Name: active_storage_variant_records id; Type: DEFAULT; Schema: public; Owner: -
1607 --
1608
1609 ALTER TABLE ONLY public.active_storage_variant_records ALTER COLUMN id SET DEFAULT nextval('public.active_storage_variant_records_id_seq'::regclass);
1610
1611
1612 --
1613 -- Name: changeset_comments id; Type: DEFAULT; Schema: public; Owner: -
1614 --
1615
1616 ALTER TABLE ONLY public.changeset_comments ALTER COLUMN id SET DEFAULT nextval('public.changeset_comments_id_seq'::regclass);
1617
1618
1619 --
1620 -- Name: changesets id; Type: DEFAULT; Schema: public; Owner: -
1621 --
1622
1623 ALTER TABLE ONLY public.changesets ALTER COLUMN id SET DEFAULT nextval('public.changesets_id_seq'::regclass);
1624
1625
1626 --
1627 -- Name: current_nodes id; Type: DEFAULT; Schema: public; Owner: -
1628 --
1629
1630 ALTER TABLE ONLY public.current_nodes ALTER COLUMN id SET DEFAULT nextval('public.current_nodes_id_seq'::regclass);
1631
1632
1633 --
1634 -- Name: current_relations id; Type: DEFAULT; Schema: public; Owner: -
1635 --
1636
1637 ALTER TABLE ONLY public.current_relations ALTER COLUMN id SET DEFAULT nextval('public.current_relations_id_seq'::regclass);
1638
1639
1640 --
1641 -- Name: current_ways id; Type: DEFAULT; Schema: public; Owner: -
1642 --
1643
1644 ALTER TABLE ONLY public.current_ways ALTER COLUMN id SET DEFAULT nextval('public.current_ways_id_seq'::regclass);
1645
1646
1647 --
1648 -- Name: delayed_jobs id; Type: DEFAULT; Schema: public; Owner: -
1649 --
1650
1651 ALTER TABLE ONLY public.delayed_jobs ALTER COLUMN id SET DEFAULT nextval('public.delayed_jobs_id_seq'::regclass);
1652
1653
1654 --
1655 -- Name: diary_comments id; Type: DEFAULT; Schema: public; Owner: -
1656 --
1657
1658 ALTER TABLE ONLY public.diary_comments ALTER COLUMN id SET DEFAULT nextval('public.diary_comments_id_seq'::regclass);
1659
1660
1661 --
1662 -- Name: diary_entries id; Type: DEFAULT; Schema: public; Owner: -
1663 --
1664
1665 ALTER TABLE ONLY public.diary_entries ALTER COLUMN id SET DEFAULT nextval('public.diary_entries_id_seq'::regclass);
1666
1667
1668 --
1669 -- Name: friends id; Type: DEFAULT; Schema: public; Owner: -
1670 --
1671
1672 ALTER TABLE ONLY public.friends ALTER COLUMN id SET DEFAULT nextval('public.friends_id_seq'::regclass);
1673
1674
1675 --
1676 -- Name: gpx_file_tags id; Type: DEFAULT; Schema: public; Owner: -
1677 --
1678
1679 ALTER TABLE ONLY public.gpx_file_tags ALTER COLUMN id SET DEFAULT nextval('public.gpx_file_tags_id_seq'::regclass);
1680
1681
1682 --
1683 -- Name: gpx_files id; Type: DEFAULT; Schema: public; Owner: -
1684 --
1685
1686 ALTER TABLE ONLY public.gpx_files ALTER COLUMN id SET DEFAULT nextval('public.gpx_files_id_seq'::regclass);
1687
1688
1689 --
1690 -- Name: issue_comments id; Type: DEFAULT; Schema: public; Owner: -
1691 --
1692
1693 ALTER TABLE ONLY public.issue_comments ALTER COLUMN id SET DEFAULT nextval('public.issue_comments_id_seq'::regclass);
1694
1695
1696 --
1697 -- Name: issues id; Type: DEFAULT; Schema: public; Owner: -
1698 --
1699
1700 ALTER TABLE ONLY public.issues ALTER COLUMN id SET DEFAULT nextval('public.issues_id_seq'::regclass);
1701
1702
1703 --
1704 -- Name: messages id; Type: DEFAULT; Schema: public; Owner: -
1705 --
1706
1707 ALTER TABLE ONLY public.messages ALTER COLUMN id SET DEFAULT nextval('public.messages_id_seq'::regclass);
1708
1709
1710 --
1711 -- Name: note_comments id; Type: DEFAULT; Schema: public; Owner: -
1712 --
1713
1714 ALTER TABLE ONLY public.note_comments ALTER COLUMN id SET DEFAULT nextval('public.note_comments_id_seq'::regclass);
1715
1716
1717 --
1718 -- Name: notes id; Type: DEFAULT; Schema: public; Owner: -
1719 --
1720
1721 ALTER TABLE ONLY public.notes ALTER COLUMN id SET DEFAULT nextval('public.notes_id_seq'::regclass);
1722
1723
1724 --
1725 -- Name: oauth_access_grants id; Type: DEFAULT; Schema: public; Owner: -
1726 --
1727
1728 ALTER TABLE ONLY public.oauth_access_grants ALTER COLUMN id SET DEFAULT nextval('public.oauth_access_grants_id_seq'::regclass);
1729
1730
1731 --
1732 -- Name: oauth_access_tokens id; Type: DEFAULT; Schema: public; Owner: -
1733 --
1734
1735 ALTER TABLE ONLY public.oauth_access_tokens ALTER COLUMN id SET DEFAULT nextval('public.oauth_access_tokens_id_seq'::regclass);
1736
1737
1738 --
1739 -- Name: oauth_applications id; Type: DEFAULT; Schema: public; Owner: -
1740 --
1741
1742 ALTER TABLE ONLY public.oauth_applications ALTER COLUMN id SET DEFAULT nextval('public.oauth_applications_id_seq'::regclass);
1743
1744
1745 --
1746 -- Name: oauth_openid_requests id; Type: DEFAULT; Schema: public; Owner: -
1747 --
1748
1749 ALTER TABLE ONLY public.oauth_openid_requests ALTER COLUMN id SET DEFAULT nextval('public.oauth_openid_requests_id_seq'::regclass);
1750
1751
1752 --
1753 -- Name: redactions id; Type: DEFAULT; Schema: public; Owner: -
1754 --
1755
1756 ALTER TABLE ONLY public.redactions ALTER COLUMN id SET DEFAULT nextval('public.redactions_id_seq'::regclass);
1757
1758
1759 --
1760 -- Name: reports id; Type: DEFAULT; Schema: public; Owner: -
1761 --
1762
1763 ALTER TABLE ONLY public.reports ALTER COLUMN id SET DEFAULT nextval('public.reports_id_seq'::regclass);
1764
1765
1766 --
1767 -- Name: user_blocks id; Type: DEFAULT; Schema: public; Owner: -
1768 --
1769
1770 ALTER TABLE ONLY public.user_blocks ALTER COLUMN id SET DEFAULT nextval('public.user_blocks_id_seq'::regclass);
1771
1772
1773 --
1774 -- Name: user_mutes id; Type: DEFAULT; Schema: public; Owner: -
1775 --
1776
1777 ALTER TABLE ONLY public.user_mutes ALTER COLUMN id SET DEFAULT nextval('public.user_mutes_id_seq'::regclass);
1778
1779
1780 --
1781 -- Name: user_roles id; Type: DEFAULT; Schema: public; Owner: -
1782 --
1783
1784 ALTER TABLE ONLY public.user_roles ALTER COLUMN id SET DEFAULT nextval('public.user_roles_id_seq'::regclass);
1785
1786
1787 --
1788 -- Name: users id; Type: DEFAULT; Schema: public; Owner: -
1789 --
1790
1791 ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
1792
1793
1794 --
1795 -- Name: acls acls_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1796 --
1797
1798 ALTER TABLE ONLY public.acls
1799     ADD CONSTRAINT acls_pkey PRIMARY KEY (id);
1800
1801
1802 --
1803 -- Name: active_storage_attachments active_storage_attachments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1804 --
1805
1806 ALTER TABLE ONLY public.active_storage_attachments
1807     ADD CONSTRAINT active_storage_attachments_pkey PRIMARY KEY (id);
1808
1809
1810 --
1811 -- Name: active_storage_blobs active_storage_blobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1812 --
1813
1814 ALTER TABLE ONLY public.active_storage_blobs
1815     ADD CONSTRAINT active_storage_blobs_pkey PRIMARY KEY (id);
1816
1817
1818 --
1819 -- Name: active_storage_variant_records active_storage_variant_records_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1820 --
1821
1822 ALTER TABLE ONLY public.active_storage_variant_records
1823     ADD CONSTRAINT active_storage_variant_records_pkey PRIMARY KEY (id);
1824
1825
1826 --
1827 -- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1828 --
1829
1830 ALTER TABLE ONLY public.ar_internal_metadata
1831     ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key);
1832
1833
1834 --
1835 -- Name: changeset_comments changeset_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1836 --
1837
1838 ALTER TABLE ONLY public.changeset_comments
1839     ADD CONSTRAINT changeset_comments_pkey PRIMARY KEY (id);
1840
1841
1842 --
1843 -- Name: changeset_tags changeset_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1844 --
1845
1846 ALTER TABLE ONLY public.changeset_tags
1847     ADD CONSTRAINT changeset_tags_pkey PRIMARY KEY (changeset_id, k);
1848
1849
1850 --
1851 -- Name: changesets changesets_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1852 --
1853
1854 ALTER TABLE ONLY public.changesets
1855     ADD CONSTRAINT changesets_pkey PRIMARY KEY (id);
1856
1857
1858 --
1859 -- Name: current_node_tags current_node_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1860 --
1861
1862 ALTER TABLE ONLY public.current_node_tags
1863     ADD CONSTRAINT current_node_tags_pkey PRIMARY KEY (node_id, k);
1864
1865
1866 --
1867 -- Name: current_nodes current_nodes_pkey1; Type: CONSTRAINT; Schema: public; Owner: -
1868 --
1869
1870 ALTER TABLE ONLY public.current_nodes
1871     ADD CONSTRAINT current_nodes_pkey1 PRIMARY KEY (id);
1872
1873
1874 --
1875 -- Name: current_relation_members current_relation_members_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1876 --
1877
1878 ALTER TABLE ONLY public.current_relation_members
1879     ADD CONSTRAINT current_relation_members_pkey PRIMARY KEY (relation_id, sequence_id);
1880
1881
1882 --
1883 -- Name: current_relation_tags current_relation_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1884 --
1885
1886 ALTER TABLE ONLY public.current_relation_tags
1887     ADD CONSTRAINT current_relation_tags_pkey PRIMARY KEY (relation_id, k);
1888
1889
1890 --
1891 -- Name: current_relations current_relations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1892 --
1893
1894 ALTER TABLE ONLY public.current_relations
1895     ADD CONSTRAINT current_relations_pkey PRIMARY KEY (id);
1896
1897
1898 --
1899 -- Name: current_way_nodes current_way_nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1900 --
1901
1902 ALTER TABLE ONLY public.current_way_nodes
1903     ADD CONSTRAINT current_way_nodes_pkey PRIMARY KEY (way_id, sequence_id);
1904
1905
1906 --
1907 -- Name: current_way_tags current_way_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1908 --
1909
1910 ALTER TABLE ONLY public.current_way_tags
1911     ADD CONSTRAINT current_way_tags_pkey PRIMARY KEY (way_id, k);
1912
1913
1914 --
1915 -- Name: current_ways current_ways_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1916 --
1917
1918 ALTER TABLE ONLY public.current_ways
1919     ADD CONSTRAINT current_ways_pkey PRIMARY KEY (id);
1920
1921
1922 --
1923 -- Name: delayed_jobs delayed_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1924 --
1925
1926 ALTER TABLE ONLY public.delayed_jobs
1927     ADD CONSTRAINT delayed_jobs_pkey PRIMARY KEY (id);
1928
1929
1930 --
1931 -- Name: diary_comments diary_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1932 --
1933
1934 ALTER TABLE ONLY public.diary_comments
1935     ADD CONSTRAINT diary_comments_pkey PRIMARY KEY (id);
1936
1937
1938 --
1939 -- Name: diary_entries diary_entries_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1940 --
1941
1942 ALTER TABLE ONLY public.diary_entries
1943     ADD CONSTRAINT diary_entries_pkey PRIMARY KEY (id);
1944
1945
1946 --
1947 -- Name: diary_entry_subscriptions diary_entry_subscriptions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1948 --
1949
1950 ALTER TABLE ONLY public.diary_entry_subscriptions
1951     ADD CONSTRAINT diary_entry_subscriptions_pkey PRIMARY KEY (user_id, diary_entry_id);
1952
1953
1954 --
1955 -- Name: friends friends_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1956 --
1957
1958 ALTER TABLE ONLY public.friends
1959     ADD CONSTRAINT friends_pkey PRIMARY KEY (id);
1960
1961
1962 --
1963 -- Name: gpx_file_tags gpx_file_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1964 --
1965
1966 ALTER TABLE ONLY public.gpx_file_tags
1967     ADD CONSTRAINT gpx_file_tags_pkey PRIMARY KEY (id);
1968
1969
1970 --
1971 -- Name: gpx_files gpx_files_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1972 --
1973
1974 ALTER TABLE ONLY public.gpx_files
1975     ADD CONSTRAINT gpx_files_pkey PRIMARY KEY (id);
1976
1977
1978 --
1979 -- Name: issue_comments issue_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1980 --
1981
1982 ALTER TABLE ONLY public.issue_comments
1983     ADD CONSTRAINT issue_comments_pkey PRIMARY KEY (id);
1984
1985
1986 --
1987 -- Name: issues issues_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1988 --
1989
1990 ALTER TABLE ONLY public.issues
1991     ADD CONSTRAINT issues_pkey PRIMARY KEY (id);
1992
1993
1994 --
1995 -- Name: languages languages_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1996 --
1997
1998 ALTER TABLE ONLY public.languages
1999     ADD CONSTRAINT languages_pkey PRIMARY KEY (code);
2000
2001
2002 --
2003 -- Name: messages messages_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2004 --
2005
2006 ALTER TABLE ONLY public.messages
2007     ADD CONSTRAINT messages_pkey PRIMARY KEY (id);
2008
2009
2010 --
2011 -- Name: node_tags node_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2012 --
2013
2014 ALTER TABLE ONLY public.node_tags
2015     ADD CONSTRAINT node_tags_pkey PRIMARY KEY (node_id, version, k);
2016
2017
2018 --
2019 -- Name: nodes nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2020 --
2021
2022 ALTER TABLE ONLY public.nodes
2023     ADD CONSTRAINT nodes_pkey PRIMARY KEY (node_id, version);
2024
2025
2026 --
2027 -- Name: note_comments note_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2028 --
2029
2030 ALTER TABLE ONLY public.note_comments
2031     ADD CONSTRAINT note_comments_pkey PRIMARY KEY (id);
2032
2033
2034 --
2035 -- Name: note_subscriptions note_subscriptions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2036 --
2037
2038 ALTER TABLE ONLY public.note_subscriptions
2039     ADD CONSTRAINT note_subscriptions_pkey PRIMARY KEY (user_id, note_id);
2040
2041
2042 --
2043 -- Name: notes notes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2044 --
2045
2046 ALTER TABLE ONLY public.notes
2047     ADD CONSTRAINT notes_pkey PRIMARY KEY (id);
2048
2049
2050 --
2051 -- Name: oauth_access_grants oauth_access_grants_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2052 --
2053
2054 ALTER TABLE ONLY public.oauth_access_grants
2055     ADD CONSTRAINT oauth_access_grants_pkey PRIMARY KEY (id);
2056
2057
2058 --
2059 -- Name: oauth_access_tokens oauth_access_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2060 --
2061
2062 ALTER TABLE ONLY public.oauth_access_tokens
2063     ADD CONSTRAINT oauth_access_tokens_pkey PRIMARY KEY (id);
2064
2065
2066 --
2067 -- Name: oauth_applications oauth_applications_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2068 --
2069
2070 ALTER TABLE ONLY public.oauth_applications
2071     ADD CONSTRAINT oauth_applications_pkey PRIMARY KEY (id);
2072
2073
2074 --
2075 -- Name: oauth_openid_requests oauth_openid_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2076 --
2077
2078 ALTER TABLE ONLY public.oauth_openid_requests
2079     ADD CONSTRAINT oauth_openid_requests_pkey PRIMARY KEY (id);
2080
2081
2082 --
2083 -- Name: redactions redactions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2084 --
2085
2086 ALTER TABLE ONLY public.redactions
2087     ADD CONSTRAINT redactions_pkey PRIMARY KEY (id);
2088
2089
2090 --
2091 -- Name: relation_members relation_members_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2092 --
2093
2094 ALTER TABLE ONLY public.relation_members
2095     ADD CONSTRAINT relation_members_pkey PRIMARY KEY (relation_id, version, sequence_id);
2096
2097
2098 --
2099 -- Name: relation_tags relation_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2100 --
2101
2102 ALTER TABLE ONLY public.relation_tags
2103     ADD CONSTRAINT relation_tags_pkey PRIMARY KEY (relation_id, version, k);
2104
2105
2106 --
2107 -- Name: relations relations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2108 --
2109
2110 ALTER TABLE ONLY public.relations
2111     ADD CONSTRAINT relations_pkey PRIMARY KEY (relation_id, version);
2112
2113
2114 --
2115 -- Name: reports reports_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2116 --
2117
2118 ALTER TABLE ONLY public.reports
2119     ADD CONSTRAINT reports_pkey PRIMARY KEY (id);
2120
2121
2122 --
2123 -- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2124 --
2125
2126 ALTER TABLE ONLY public.schema_migrations
2127     ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
2128
2129
2130 --
2131 -- Name: user_blocks user_blocks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2132 --
2133
2134 ALTER TABLE ONLY public.user_blocks
2135     ADD CONSTRAINT user_blocks_pkey PRIMARY KEY (id);
2136
2137
2138 --
2139 -- Name: user_mutes user_mutes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2140 --
2141
2142 ALTER TABLE ONLY public.user_mutes
2143     ADD CONSTRAINT user_mutes_pkey PRIMARY KEY (id);
2144
2145
2146 --
2147 -- Name: user_preferences user_preferences_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2148 --
2149
2150 ALTER TABLE ONLY public.user_preferences
2151     ADD CONSTRAINT user_preferences_pkey PRIMARY KEY (user_id, k);
2152
2153
2154 --
2155 -- Name: user_roles user_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2156 --
2157
2158 ALTER TABLE ONLY public.user_roles
2159     ADD CONSTRAINT user_roles_pkey PRIMARY KEY (id);
2160
2161
2162 --
2163 -- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2164 --
2165
2166 ALTER TABLE ONLY public.users
2167     ADD CONSTRAINT users_pkey PRIMARY KEY (id);
2168
2169
2170 --
2171 -- Name: way_nodes way_nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2172 --
2173
2174 ALTER TABLE ONLY public.way_nodes
2175     ADD CONSTRAINT way_nodes_pkey PRIMARY KEY (way_id, version, sequence_id);
2176
2177
2178 --
2179 -- Name: way_tags way_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2180 --
2181
2182 ALTER TABLE ONLY public.way_tags
2183     ADD CONSTRAINT way_tags_pkey PRIMARY KEY (way_id, version, k);
2184
2185
2186 --
2187 -- Name: ways ways_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2188 --
2189
2190 ALTER TABLE ONLY public.ways
2191     ADD CONSTRAINT ways_pkey PRIMARY KEY (way_id, version);
2192
2193
2194 --
2195 -- Name: acls_k_idx; Type: INDEX; Schema: public; Owner: -
2196 --
2197
2198 CREATE INDEX acls_k_idx ON public.acls USING btree (k);
2199
2200
2201 --
2202 -- Name: changesets_bbox_idx; Type: INDEX; Schema: public; Owner: -
2203 --
2204
2205 CREATE INDEX changesets_bbox_idx ON public.changesets USING gist (min_lat, max_lat, min_lon, max_lon);
2206
2207
2208 --
2209 -- Name: changesets_closed_at_idx; Type: INDEX; Schema: public; Owner: -
2210 --
2211
2212 CREATE INDEX changesets_closed_at_idx ON public.changesets USING btree (closed_at);
2213
2214
2215 --
2216 -- Name: changesets_created_at_idx; Type: INDEX; Schema: public; Owner: -
2217 --
2218
2219 CREATE INDEX changesets_created_at_idx ON public.changesets USING btree (created_at);
2220
2221
2222 --
2223 -- Name: changesets_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: -
2224 --
2225
2226 CREATE INDEX changesets_user_id_created_at_idx ON public.changesets USING btree (user_id, created_at);
2227
2228
2229 --
2230 -- Name: changesets_user_id_id_idx; Type: INDEX; Schema: public; Owner: -
2231 --
2232
2233 CREATE INDEX changesets_user_id_id_idx ON public.changesets USING btree (user_id, id);
2234
2235
2236 --
2237 -- Name: current_nodes_tile_idx; Type: INDEX; Schema: public; Owner: -
2238 --
2239
2240 CREATE INDEX current_nodes_tile_idx ON public.current_nodes USING btree (tile);
2241
2242
2243 --
2244 -- Name: current_nodes_timestamp_idx; Type: INDEX; Schema: public; Owner: -
2245 --
2246
2247 CREATE INDEX current_nodes_timestamp_idx ON public.current_nodes USING btree ("timestamp");
2248
2249
2250 --
2251 -- Name: current_relation_members_member_idx; Type: INDEX; Schema: public; Owner: -
2252 --
2253
2254 CREATE INDEX current_relation_members_member_idx ON public.current_relation_members USING btree (member_type, member_id);
2255
2256
2257 --
2258 -- Name: current_relations_timestamp_idx; Type: INDEX; Schema: public; Owner: -
2259 --
2260
2261 CREATE INDEX current_relations_timestamp_idx ON public.current_relations USING btree ("timestamp");
2262
2263
2264 --
2265 -- Name: current_way_nodes_node_idx; Type: INDEX; Schema: public; Owner: -
2266 --
2267
2268 CREATE INDEX current_way_nodes_node_idx ON public.current_way_nodes USING btree (node_id);
2269
2270
2271 --
2272 -- Name: current_ways_timestamp_idx; Type: INDEX; Schema: public; Owner: -
2273 --
2274
2275 CREATE INDEX current_ways_timestamp_idx ON public.current_ways USING btree ("timestamp");
2276
2277
2278 --
2279 -- Name: delayed_jobs_priority; Type: INDEX; Schema: public; Owner: -
2280 --
2281
2282 CREATE INDEX delayed_jobs_priority ON public.delayed_jobs USING btree (priority, run_at);
2283
2284
2285 --
2286 -- Name: diary_comment_user_id_created_at_index; Type: INDEX; Schema: public; Owner: -
2287 --
2288
2289 CREATE INDEX diary_comment_user_id_created_at_index ON public.diary_comments USING btree (user_id, created_at);
2290
2291
2292 --
2293 -- Name: diary_comments_entry_id_idx; Type: INDEX; Schema: public; Owner: -
2294 --
2295
2296 CREATE UNIQUE INDEX diary_comments_entry_id_idx ON public.diary_comments USING btree (diary_entry_id, id);
2297
2298
2299 --
2300 -- Name: diary_entry_created_at_index; Type: INDEX; Schema: public; Owner: -
2301 --
2302
2303 CREATE INDEX diary_entry_created_at_index ON public.diary_entries USING btree (created_at);
2304
2305
2306 --
2307 -- Name: diary_entry_language_code_created_at_index; Type: INDEX; Schema: public; Owner: -
2308 --
2309
2310 CREATE INDEX diary_entry_language_code_created_at_index ON public.diary_entries USING btree (language_code, created_at);
2311
2312
2313 --
2314 -- Name: diary_entry_user_id_created_at_index; Type: INDEX; Schema: public; Owner: -
2315 --
2316
2317 CREATE INDEX diary_entry_user_id_created_at_index ON public.diary_entries USING btree (user_id, created_at);
2318
2319
2320 --
2321 -- Name: gpx_file_tags_gpxid_idx; Type: INDEX; Schema: public; Owner: -
2322 --
2323
2324 CREATE INDEX gpx_file_tags_gpxid_idx ON public.gpx_file_tags USING btree (gpx_id);
2325
2326
2327 --
2328 -- Name: gpx_file_tags_tag_idx; Type: INDEX; Schema: public; Owner: -
2329 --
2330
2331 CREATE INDEX gpx_file_tags_tag_idx ON public.gpx_file_tags USING btree (tag);
2332
2333
2334 --
2335 -- Name: gpx_files_timestamp_idx; Type: INDEX; Schema: public; Owner: -
2336 --
2337
2338 CREATE INDEX gpx_files_timestamp_idx ON public.gpx_files USING btree ("timestamp");
2339
2340
2341 --
2342 -- Name: gpx_files_user_id_idx; Type: INDEX; Schema: public; Owner: -
2343 --
2344
2345 CREATE INDEX gpx_files_user_id_idx ON public.gpx_files USING btree (user_id);
2346
2347
2348 --
2349 -- Name: gpx_files_visible_visibility_idx; Type: INDEX; Schema: public; Owner: -
2350 --
2351
2352 CREATE INDEX gpx_files_visible_visibility_idx ON public.gpx_files USING btree (visible, visibility);
2353
2354
2355 --
2356 -- Name: index_acls_on_address; Type: INDEX; Schema: public; Owner: -
2357 --
2358
2359 CREATE INDEX index_acls_on_address ON public.acls USING gist (address inet_ops);
2360
2361
2362 --
2363 -- Name: index_acls_on_domain; Type: INDEX; Schema: public; Owner: -
2364 --
2365
2366 CREATE INDEX index_acls_on_domain ON public.acls USING btree (domain);
2367
2368
2369 --
2370 -- Name: index_acls_on_mx; Type: INDEX; Schema: public; Owner: -
2371 --
2372
2373 CREATE INDEX index_acls_on_mx ON public.acls USING btree (mx);
2374
2375
2376 --
2377 -- Name: index_active_storage_attachments_on_blob_id; Type: INDEX; Schema: public; Owner: -
2378 --
2379
2380 CREATE INDEX index_active_storage_attachments_on_blob_id ON public.active_storage_attachments USING btree (blob_id);
2381
2382
2383 --
2384 -- Name: index_active_storage_attachments_uniqueness; Type: INDEX; Schema: public; Owner: -
2385 --
2386
2387 CREATE UNIQUE INDEX index_active_storage_attachments_uniqueness ON public.active_storage_attachments USING btree (record_type, record_id, name, blob_id);
2388
2389
2390 --
2391 -- Name: index_active_storage_blobs_on_key; Type: INDEX; Schema: public; Owner: -
2392 --
2393
2394 CREATE UNIQUE INDEX index_active_storage_blobs_on_key ON public.active_storage_blobs USING btree (key);
2395
2396
2397 --
2398 -- Name: index_active_storage_variant_records_uniqueness; Type: INDEX; Schema: public; Owner: -
2399 --
2400
2401 CREATE UNIQUE INDEX index_active_storage_variant_records_uniqueness ON public.active_storage_variant_records USING btree (blob_id, variation_digest);
2402
2403
2404 --
2405 -- Name: index_changeset_comments_on_author_id_and_created_at; Type: INDEX; Schema: public; Owner: -
2406 --
2407
2408 CREATE INDEX index_changeset_comments_on_author_id_and_created_at ON public.changeset_comments USING btree (author_id, created_at);
2409
2410
2411 --
2412 -- Name: index_changeset_comments_on_author_id_and_id; Type: INDEX; Schema: public; Owner: -
2413 --
2414
2415 CREATE INDEX index_changeset_comments_on_author_id_and_id ON public.changeset_comments USING btree (author_id, id);
2416
2417
2418 --
2419 -- Name: index_changeset_comments_on_changeset_id_and_created_at; Type: INDEX; Schema: public; Owner: -
2420 --
2421
2422 CREATE INDEX index_changeset_comments_on_changeset_id_and_created_at ON public.changeset_comments USING btree (changeset_id, created_at);
2423
2424
2425 --
2426 -- Name: index_changeset_comments_on_created_at; Type: INDEX; Schema: public; Owner: -
2427 --
2428
2429 CREATE INDEX index_changeset_comments_on_created_at ON public.changeset_comments USING btree (created_at);
2430
2431
2432 --
2433 -- Name: index_changesets_on_user_id_and_closed_at; Type: INDEX; Schema: public; Owner: -
2434 --
2435
2436 CREATE INDEX index_changesets_on_user_id_and_closed_at ON public.changesets USING btree (user_id, closed_at);
2437
2438
2439 --
2440 -- Name: index_changesets_subscribers_on_changeset_id; Type: INDEX; Schema: public; Owner: -
2441 --
2442
2443 CREATE INDEX index_changesets_subscribers_on_changeset_id ON public.changesets_subscribers USING btree (changeset_id);
2444
2445
2446 --
2447 -- Name: index_changesets_subscribers_on_subscriber_id_and_changeset_id; Type: INDEX; Schema: public; Owner: -
2448 --
2449
2450 CREATE UNIQUE INDEX index_changesets_subscribers_on_subscriber_id_and_changeset_id ON public.changesets_subscribers USING btree (subscriber_id, changeset_id);
2451
2452
2453 --
2454 -- Name: index_diary_comments_on_user_id_and_id; Type: INDEX; Schema: public; Owner: -
2455 --
2456
2457 CREATE INDEX index_diary_comments_on_user_id_and_id ON public.diary_comments USING btree (user_id, id);
2458
2459
2460 --
2461 -- Name: index_diary_entry_subscriptions_on_diary_entry_id; Type: INDEX; Schema: public; Owner: -
2462 --
2463
2464 CREATE INDEX index_diary_entry_subscriptions_on_diary_entry_id ON public.diary_entry_subscriptions USING btree (diary_entry_id);
2465
2466
2467 --
2468 -- Name: index_friends_on_user_id_and_created_at; Type: INDEX; Schema: public; Owner: -
2469 --
2470
2471 CREATE INDEX index_friends_on_user_id_and_created_at ON public.friends USING btree (user_id, created_at);
2472
2473
2474 --
2475 -- Name: index_gpx_files_on_user_id_and_id; Type: INDEX; Schema: public; Owner: -
2476 --
2477
2478 CREATE INDEX index_gpx_files_on_user_id_and_id ON public.gpx_files USING btree (user_id, id);
2479
2480
2481 --
2482 -- Name: index_issue_comments_on_issue_id; Type: INDEX; Schema: public; Owner: -
2483 --
2484
2485 CREATE INDEX index_issue_comments_on_issue_id ON public.issue_comments USING btree (issue_id);
2486
2487
2488 --
2489 -- Name: index_issue_comments_on_user_id; Type: INDEX; Schema: public; Owner: -
2490 --
2491
2492 CREATE INDEX index_issue_comments_on_user_id ON public.issue_comments USING btree (user_id);
2493
2494
2495 --
2496 -- Name: index_issues_on_assigned_role; Type: INDEX; Schema: public; Owner: -
2497 --
2498
2499 CREATE INDEX index_issues_on_assigned_role ON public.issues USING btree (assigned_role);
2500
2501
2502 --
2503 -- Name: index_issues_on_reportable_type_and_reportable_id; Type: INDEX; Schema: public; Owner: -
2504 --
2505
2506 CREATE INDEX index_issues_on_reportable_type_and_reportable_id ON public.issues USING btree (reportable_type, reportable_id);
2507
2508
2509 --
2510 -- Name: index_issues_on_reported_user_id; Type: INDEX; Schema: public; Owner: -
2511 --
2512
2513 CREATE INDEX index_issues_on_reported_user_id ON public.issues USING btree (reported_user_id);
2514
2515
2516 --
2517 -- Name: index_issues_on_status; Type: INDEX; Schema: public; Owner: -
2518 --
2519
2520 CREATE INDEX index_issues_on_status ON public.issues USING btree (status);
2521
2522
2523 --
2524 -- Name: index_issues_on_updated_by; Type: INDEX; Schema: public; Owner: -
2525 --
2526
2527 CREATE INDEX index_issues_on_updated_by ON public.issues USING btree (updated_by);
2528
2529
2530 --
2531 -- Name: index_note_comments_on_author_id_and_created_at; Type: INDEX; Schema: public; Owner: -
2532 --
2533
2534 CREATE INDEX index_note_comments_on_author_id_and_created_at ON public.note_comments USING btree (author_id, created_at);
2535
2536
2537 --
2538 -- Name: index_note_comments_on_body; Type: INDEX; Schema: public; Owner: -
2539 --
2540
2541 CREATE INDEX index_note_comments_on_body ON public.note_comments USING gin (to_tsvector('english'::regconfig, body));
2542
2543
2544 --
2545 -- Name: index_note_comments_on_created_at; Type: INDEX; Schema: public; Owner: -
2546 --
2547
2548 CREATE INDEX index_note_comments_on_created_at ON public.note_comments USING btree (created_at);
2549
2550
2551 --
2552 -- Name: index_note_subscriptions_on_note_id; Type: INDEX; Schema: public; Owner: -
2553 --
2554
2555 CREATE INDEX index_note_subscriptions_on_note_id ON public.note_subscriptions USING btree (note_id);
2556
2557
2558 --
2559 -- Name: index_notes_on_description; Type: INDEX; Schema: public; Owner: -
2560 --
2561
2562 CREATE INDEX index_notes_on_description ON public.notes USING gin (to_tsvector('english'::regconfig, description));
2563
2564
2565 --
2566 -- Name: index_notes_on_user_id_and_created_at; Type: INDEX; Schema: public; Owner: -
2567 --
2568
2569 CREATE INDEX index_notes_on_user_id_and_created_at ON public.notes USING btree (user_id, created_at) WHERE (user_id IS NOT NULL);
2570
2571
2572 --
2573 -- Name: index_oauth_access_grants_on_application_id; Type: INDEX; Schema: public; Owner: -
2574 --
2575
2576 CREATE INDEX index_oauth_access_grants_on_application_id ON public.oauth_access_grants USING btree (application_id);
2577
2578
2579 --
2580 -- Name: index_oauth_access_grants_on_resource_owner_id; Type: INDEX; Schema: public; Owner: -
2581 --
2582
2583 CREATE INDEX index_oauth_access_grants_on_resource_owner_id ON public.oauth_access_grants USING btree (resource_owner_id);
2584
2585
2586 --
2587 -- Name: index_oauth_access_grants_on_token; Type: INDEX; Schema: public; Owner: -
2588 --
2589
2590 CREATE UNIQUE INDEX index_oauth_access_grants_on_token ON public.oauth_access_grants USING btree (token);
2591
2592
2593 --
2594 -- Name: index_oauth_access_tokens_on_application_id; Type: INDEX; Schema: public; Owner: -
2595 --
2596
2597 CREATE INDEX index_oauth_access_tokens_on_application_id ON public.oauth_access_tokens USING btree (application_id);
2598
2599
2600 --
2601 -- Name: index_oauth_access_tokens_on_refresh_token; Type: INDEX; Schema: public; Owner: -
2602 --
2603
2604 CREATE UNIQUE INDEX index_oauth_access_tokens_on_refresh_token ON public.oauth_access_tokens USING btree (refresh_token);
2605
2606
2607 --
2608 -- Name: index_oauth_access_tokens_on_resource_owner_id; Type: INDEX; Schema: public; Owner: -
2609 --
2610
2611 CREATE INDEX index_oauth_access_tokens_on_resource_owner_id ON public.oauth_access_tokens USING btree (resource_owner_id);
2612
2613
2614 --
2615 -- Name: index_oauth_access_tokens_on_token; Type: INDEX; Schema: public; Owner: -
2616 --
2617
2618 CREATE UNIQUE INDEX index_oauth_access_tokens_on_token ON public.oauth_access_tokens USING btree (token);
2619
2620
2621 --
2622 -- Name: index_oauth_applications_on_owner_type_and_owner_id; Type: INDEX; Schema: public; Owner: -
2623 --
2624
2625 CREATE INDEX index_oauth_applications_on_owner_type_and_owner_id ON public.oauth_applications USING btree (owner_type, owner_id);
2626
2627
2628 --
2629 -- Name: index_oauth_applications_on_uid; Type: INDEX; Schema: public; Owner: -
2630 --
2631
2632 CREATE UNIQUE INDEX index_oauth_applications_on_uid ON public.oauth_applications USING btree (uid);
2633
2634
2635 --
2636 -- Name: index_oauth_openid_requests_on_access_grant_id; Type: INDEX; Schema: public; Owner: -
2637 --
2638
2639 CREATE INDEX index_oauth_openid_requests_on_access_grant_id ON public.oauth_openid_requests USING btree (access_grant_id);
2640
2641
2642 --
2643 -- Name: index_reports_on_issue_id; Type: INDEX; Schema: public; Owner: -
2644 --
2645
2646 CREATE INDEX index_reports_on_issue_id ON public.reports USING btree (issue_id);
2647
2648
2649 --
2650 -- Name: index_reports_on_user_id; Type: INDEX; Schema: public; Owner: -
2651 --
2652
2653 CREATE INDEX index_reports_on_user_id ON public.reports USING btree (user_id);
2654
2655
2656 --
2657 -- Name: index_user_blocks_on_creator_id_and_id; Type: INDEX; Schema: public; Owner: -
2658 --
2659
2660 CREATE INDEX index_user_blocks_on_creator_id_and_id ON public.user_blocks USING btree (creator_id, id);
2661
2662
2663 --
2664 -- Name: index_user_blocks_on_user_id; Type: INDEX; Schema: public; Owner: -
2665 --
2666
2667 CREATE INDEX index_user_blocks_on_user_id ON public.user_blocks USING btree (user_id);
2668
2669
2670 --
2671 -- Name: index_user_mutes_on_owner_id_and_subject_id; Type: INDEX; Schema: public; Owner: -
2672 --
2673
2674 CREATE UNIQUE INDEX index_user_mutes_on_owner_id_and_subject_id ON public.user_mutes USING btree (owner_id, subject_id);
2675
2676
2677 --
2678 -- Name: index_users_on_creation_address; Type: INDEX; Schema: public; Owner: -
2679 --
2680
2681 CREATE INDEX index_users_on_creation_address ON public.users USING gist (creation_address inet_ops);
2682
2683
2684 --
2685 -- Name: messages_from_user_id_idx; Type: INDEX; Schema: public; Owner: -
2686 --
2687
2688 CREATE INDEX messages_from_user_id_idx ON public.messages USING btree (from_user_id);
2689
2690
2691 --
2692 -- Name: messages_to_user_id_idx; Type: INDEX; Schema: public; Owner: -
2693 --
2694
2695 CREATE INDEX messages_to_user_id_idx ON public.messages USING btree (to_user_id);
2696
2697
2698 --
2699 -- Name: nodes_changeset_id_idx; Type: INDEX; Schema: public; Owner: -
2700 --
2701
2702 CREATE INDEX nodes_changeset_id_idx ON public.nodes USING btree (changeset_id);
2703
2704
2705 --
2706 -- Name: nodes_tile_idx; Type: INDEX; Schema: public; Owner: -
2707 --
2708
2709 CREATE INDEX nodes_tile_idx ON public.nodes USING btree (tile);
2710
2711
2712 --
2713 -- Name: nodes_timestamp_idx; Type: INDEX; Schema: public; Owner: -
2714 --
2715
2716 CREATE INDEX nodes_timestamp_idx ON public.nodes USING btree ("timestamp");
2717
2718
2719 --
2720 -- Name: note_comments_note_id_idx; Type: INDEX; Schema: public; Owner: -
2721 --
2722
2723 CREATE INDEX note_comments_note_id_idx ON public.note_comments USING btree (note_id);
2724
2725
2726 --
2727 -- Name: notes_created_at_idx; Type: INDEX; Schema: public; Owner: -
2728 --
2729
2730 CREATE INDEX notes_created_at_idx ON public.notes USING btree (created_at);
2731
2732
2733 --
2734 -- Name: notes_tile_status_idx; Type: INDEX; Schema: public; Owner: -
2735 --
2736
2737 CREATE INDEX notes_tile_status_idx ON public.notes USING btree (tile, status);
2738
2739
2740 --
2741 -- Name: notes_updated_at_idx; Type: INDEX; Schema: public; Owner: -
2742 --
2743
2744 CREATE INDEX notes_updated_at_idx ON public.notes USING btree (updated_at);
2745
2746
2747 --
2748 -- Name: points_gpxid_idx; Type: INDEX; Schema: public; Owner: -
2749 --
2750
2751 CREATE INDEX points_gpxid_idx ON public.gps_points USING btree (gpx_id);
2752
2753
2754 --
2755 -- Name: points_tile_idx; Type: INDEX; Schema: public; Owner: -
2756 --
2757
2758 CREATE INDEX points_tile_idx ON public.gps_points USING btree (tile);
2759
2760
2761 --
2762 -- Name: relation_members_member_idx; Type: INDEX; Schema: public; Owner: -
2763 --
2764
2765 CREATE INDEX relation_members_member_idx ON public.relation_members USING btree (member_type, member_id);
2766
2767
2768 --
2769 -- Name: relations_changeset_id_idx; Type: INDEX; Schema: public; Owner: -
2770 --
2771
2772 CREATE INDEX relations_changeset_id_idx ON public.relations USING btree (changeset_id);
2773
2774
2775 --
2776 -- Name: relations_timestamp_idx; Type: INDEX; Schema: public; Owner: -
2777 --
2778
2779 CREATE INDEX relations_timestamp_idx ON public.relations USING btree ("timestamp");
2780
2781
2782 --
2783 -- Name: user_id_idx; Type: INDEX; Schema: public; Owner: -
2784 --
2785
2786 CREATE INDEX user_id_idx ON public.friends USING btree (friend_user_id);
2787
2788
2789 --
2790 -- Name: user_roles_id_role_unique; Type: INDEX; Schema: public; Owner: -
2791 --
2792
2793 CREATE UNIQUE INDEX user_roles_id_role_unique ON public.user_roles USING btree (user_id, role);
2794
2795
2796 --
2797 -- Name: users_auth_idx; Type: INDEX; Schema: public; Owner: -
2798 --
2799
2800 CREATE UNIQUE INDEX users_auth_idx ON public.users USING btree (auth_provider, auth_uid);
2801
2802
2803 --
2804 -- Name: users_display_name_canonical_idx; Type: INDEX; Schema: public; Owner: -
2805 --
2806
2807 CREATE INDEX users_display_name_canonical_idx ON public.users USING btree (lower(NORMALIZE(display_name, NFKC)));
2808
2809
2810 --
2811 -- Name: users_display_name_idx; Type: INDEX; Schema: public; Owner: -
2812 --
2813
2814 CREATE UNIQUE INDEX users_display_name_idx ON public.users USING btree (display_name);
2815
2816
2817 --
2818 -- Name: users_email_idx; Type: INDEX; Schema: public; Owner: -
2819 --
2820
2821 CREATE UNIQUE INDEX users_email_idx ON public.users USING btree (email);
2822
2823
2824 --
2825 -- Name: users_email_lower_idx; Type: INDEX; Schema: public; Owner: -
2826 --
2827
2828 CREATE INDEX users_email_lower_idx ON public.users USING btree (lower((email)::text));
2829
2830
2831 --
2832 -- Name: users_home_idx; Type: INDEX; Schema: public; Owner: -
2833 --
2834
2835 CREATE INDEX users_home_idx ON public.users USING btree (home_tile);
2836
2837
2838 --
2839 -- Name: way_nodes_node_idx; Type: INDEX; Schema: public; Owner: -
2840 --
2841
2842 CREATE INDEX way_nodes_node_idx ON public.way_nodes USING btree (node_id);
2843
2844
2845 --
2846 -- Name: ways_changeset_id_idx; Type: INDEX; Schema: public; Owner: -
2847 --
2848
2849 CREATE INDEX ways_changeset_id_idx ON public.ways USING btree (changeset_id);
2850
2851
2852 --
2853 -- Name: ways_timestamp_idx; Type: INDEX; Schema: public; Owner: -
2854 --
2855
2856 CREATE INDEX ways_timestamp_idx ON public.ways USING btree ("timestamp");
2857
2858
2859 --
2860 -- Name: changeset_comments changeset_comments_author_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2861 --
2862
2863 ALTER TABLE ONLY public.changeset_comments
2864     ADD CONSTRAINT changeset_comments_author_id_fkey FOREIGN KEY (author_id) REFERENCES public.users(id);
2865
2866
2867 --
2868 -- Name: changeset_comments changeset_comments_changeset_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2869 --
2870
2871 ALTER TABLE ONLY public.changeset_comments
2872     ADD CONSTRAINT changeset_comments_changeset_id_fkey FOREIGN KEY (changeset_id) REFERENCES public.changesets(id);
2873
2874
2875 --
2876 -- Name: changeset_tags changeset_tags_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2877 --
2878
2879 ALTER TABLE ONLY public.changeset_tags
2880     ADD CONSTRAINT changeset_tags_id_fkey FOREIGN KEY (changeset_id) REFERENCES public.changesets(id);
2881
2882
2883 --
2884 -- Name: changesets_subscribers changesets_subscribers_changeset_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2885 --
2886
2887 ALTER TABLE ONLY public.changesets_subscribers
2888     ADD CONSTRAINT changesets_subscribers_changeset_id_fkey FOREIGN KEY (changeset_id) REFERENCES public.changesets(id);
2889
2890
2891 --
2892 -- Name: changesets_subscribers changesets_subscribers_subscriber_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2893 --
2894
2895 ALTER TABLE ONLY public.changesets_subscribers
2896     ADD CONSTRAINT changesets_subscribers_subscriber_id_fkey FOREIGN KEY (subscriber_id) REFERENCES public.users(id);
2897
2898
2899 --
2900 -- Name: changesets changesets_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2901 --
2902
2903 ALTER TABLE ONLY public.changesets
2904     ADD CONSTRAINT changesets_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
2905
2906
2907 --
2908 -- Name: current_node_tags current_node_tags_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2909 --
2910
2911 ALTER TABLE ONLY public.current_node_tags
2912     ADD CONSTRAINT current_node_tags_id_fkey FOREIGN KEY (node_id) REFERENCES public.current_nodes(id);
2913
2914
2915 --
2916 -- Name: current_nodes current_nodes_changeset_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2917 --
2918
2919 ALTER TABLE ONLY public.current_nodes
2920     ADD CONSTRAINT current_nodes_changeset_id_fkey FOREIGN KEY (changeset_id) REFERENCES public.changesets(id);
2921
2922
2923 --
2924 -- Name: current_relation_members current_relation_members_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2925 --
2926
2927 ALTER TABLE ONLY public.current_relation_members
2928     ADD CONSTRAINT current_relation_members_id_fkey FOREIGN KEY (relation_id) REFERENCES public.current_relations(id);
2929
2930
2931 --
2932 -- Name: current_relation_tags current_relation_tags_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2933 --
2934
2935 ALTER TABLE ONLY public.current_relation_tags
2936     ADD CONSTRAINT current_relation_tags_id_fkey FOREIGN KEY (relation_id) REFERENCES public.current_relations(id);
2937
2938
2939 --
2940 -- Name: current_relations current_relations_changeset_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2941 --
2942
2943 ALTER TABLE ONLY public.current_relations
2944     ADD CONSTRAINT current_relations_changeset_id_fkey FOREIGN KEY (changeset_id) REFERENCES public.changesets(id);
2945
2946
2947 --
2948 -- Name: current_way_nodes current_way_nodes_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2949 --
2950
2951 ALTER TABLE ONLY public.current_way_nodes
2952     ADD CONSTRAINT current_way_nodes_id_fkey FOREIGN KEY (way_id) REFERENCES public.current_ways(id);
2953
2954
2955 --
2956 -- Name: current_way_nodes current_way_nodes_node_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2957 --
2958
2959 ALTER TABLE ONLY public.current_way_nodes
2960     ADD CONSTRAINT current_way_nodes_node_id_fkey FOREIGN KEY (node_id) REFERENCES public.current_nodes(id);
2961
2962
2963 --
2964 -- Name: current_way_tags current_way_tags_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2965 --
2966
2967 ALTER TABLE ONLY public.current_way_tags
2968     ADD CONSTRAINT current_way_tags_id_fkey FOREIGN KEY (way_id) REFERENCES public.current_ways(id);
2969
2970
2971 --
2972 -- Name: current_ways current_ways_changeset_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2973 --
2974
2975 ALTER TABLE ONLY public.current_ways
2976     ADD CONSTRAINT current_ways_changeset_id_fkey FOREIGN KEY (changeset_id) REFERENCES public.changesets(id);
2977
2978
2979 --
2980 -- Name: diary_comments diary_comments_diary_entry_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2981 --
2982
2983 ALTER TABLE ONLY public.diary_comments
2984     ADD CONSTRAINT diary_comments_diary_entry_id_fkey FOREIGN KEY (diary_entry_id) REFERENCES public.diary_entries(id);
2985
2986
2987 --
2988 -- Name: diary_comments diary_comments_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2989 --
2990
2991 ALTER TABLE ONLY public.diary_comments
2992     ADD CONSTRAINT diary_comments_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
2993
2994
2995 --
2996 -- Name: diary_entries diary_entries_language_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2997 --
2998
2999 ALTER TABLE ONLY public.diary_entries
3000     ADD CONSTRAINT diary_entries_language_code_fkey FOREIGN KEY (language_code) REFERENCES public.languages(code);
3001
3002
3003 --
3004 -- Name: diary_entries diary_entries_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3005 --
3006
3007 ALTER TABLE ONLY public.diary_entries
3008     ADD CONSTRAINT diary_entries_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
3009
3010
3011 --
3012 -- Name: diary_entry_subscriptions diary_entry_subscriptions_diary_entry_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3013 --
3014
3015 ALTER TABLE ONLY public.diary_entry_subscriptions
3016     ADD CONSTRAINT diary_entry_subscriptions_diary_entry_id_fkey FOREIGN KEY (diary_entry_id) REFERENCES public.diary_entries(id);
3017
3018
3019 --
3020 -- Name: diary_entry_subscriptions diary_entry_subscriptions_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3021 --
3022
3023 ALTER TABLE ONLY public.diary_entry_subscriptions
3024     ADD CONSTRAINT diary_entry_subscriptions_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
3025
3026
3027 --
3028 -- Name: note_subscriptions fk_rails_2c1913f293; Type: FK CONSTRAINT; Schema: public; Owner: -
3029 --
3030
3031 ALTER TABLE ONLY public.note_subscriptions
3032     ADD CONSTRAINT fk_rails_2c1913f293 FOREIGN KEY (note_id) REFERENCES public.notes(id);
3033
3034
3035 --
3036 -- Name: oauth_access_grants fk_rails_330c32d8d9; Type: FK CONSTRAINT; Schema: public; Owner: -
3037 --
3038
3039 ALTER TABLE ONLY public.oauth_access_grants
3040     ADD CONSTRAINT fk_rails_330c32d8d9 FOREIGN KEY (resource_owner_id) REFERENCES public.users(id) NOT VALID;
3041
3042
3043 --
3044 -- Name: user_mutes fk_rails_591dad3359; Type: FK CONSTRAINT; Schema: public; Owner: -
3045 --
3046
3047 ALTER TABLE ONLY public.user_mutes
3048     ADD CONSTRAINT fk_rails_591dad3359 FOREIGN KEY (owner_id) REFERENCES public.users(id);
3049
3050
3051 --
3052 -- Name: oauth_access_tokens fk_rails_732cb83ab7; Type: FK CONSTRAINT; Schema: public; Owner: -
3053 --
3054
3055 ALTER TABLE ONLY public.oauth_access_tokens
3056     ADD CONSTRAINT fk_rails_732cb83ab7 FOREIGN KEY (application_id) REFERENCES public.oauth_applications(id) NOT VALID;
3057
3058
3059 --
3060 -- Name: oauth_openid_requests fk_rails_77114b3b09; Type: FK CONSTRAINT; Schema: public; Owner: -
3061 --
3062
3063 ALTER TABLE ONLY public.oauth_openid_requests
3064     ADD CONSTRAINT fk_rails_77114b3b09 FOREIGN KEY (access_grant_id) REFERENCES public.oauth_access_grants(id) ON DELETE CASCADE;
3065
3066
3067 --
3068 -- Name: active_storage_variant_records fk_rails_993965df05; Type: FK CONSTRAINT; Schema: public; Owner: -
3069 --
3070
3071 ALTER TABLE ONLY public.active_storage_variant_records
3072     ADD CONSTRAINT fk_rails_993965df05 FOREIGN KEY (blob_id) REFERENCES public.active_storage_blobs(id);
3073
3074
3075 --
3076 -- Name: note_subscriptions fk_rails_a352f4eced; Type: FK CONSTRAINT; Schema: public; Owner: -
3077 --
3078
3079 ALTER TABLE ONLY public.note_subscriptions
3080     ADD CONSTRAINT fk_rails_a352f4eced FOREIGN KEY (user_id) REFERENCES public.users(id);
3081
3082
3083 --
3084 -- Name: oauth_access_grants fk_rails_b4b53e07b8; Type: FK CONSTRAINT; Schema: public; Owner: -
3085 --
3086
3087 ALTER TABLE ONLY public.oauth_access_grants
3088     ADD CONSTRAINT fk_rails_b4b53e07b8 FOREIGN KEY (application_id) REFERENCES public.oauth_applications(id) NOT VALID;
3089
3090
3091 --
3092 -- Name: active_storage_attachments fk_rails_c3b3935057; Type: FK CONSTRAINT; Schema: public; Owner: -
3093 --
3094
3095 ALTER TABLE ONLY public.active_storage_attachments
3096     ADD CONSTRAINT fk_rails_c3b3935057 FOREIGN KEY (blob_id) REFERENCES public.active_storage_blobs(id);
3097
3098
3099 --
3100 -- Name: oauth_applications fk_rails_cc886e315a; Type: FK CONSTRAINT; Schema: public; Owner: -
3101 --
3102
3103 ALTER TABLE ONLY public.oauth_applications
3104     ADD CONSTRAINT fk_rails_cc886e315a FOREIGN KEY (owner_id) REFERENCES public.users(id) NOT VALID;
3105
3106
3107 --
3108 -- Name: user_mutes fk_rails_e9dd4fb6c3; Type: FK CONSTRAINT; Schema: public; Owner: -
3109 --
3110
3111 ALTER TABLE ONLY public.user_mutes
3112     ADD CONSTRAINT fk_rails_e9dd4fb6c3 FOREIGN KEY (subject_id) REFERENCES public.users(id);
3113
3114
3115 --
3116 -- Name: oauth_access_tokens fk_rails_ee63f25419; Type: FK CONSTRAINT; Schema: public; Owner: -
3117 --
3118
3119 ALTER TABLE ONLY public.oauth_access_tokens
3120     ADD CONSTRAINT fk_rails_ee63f25419 FOREIGN KEY (resource_owner_id) REFERENCES public.users(id) NOT VALID;
3121
3122
3123 --
3124 -- Name: friends friends_friend_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3125 --
3126
3127 ALTER TABLE ONLY public.friends
3128     ADD CONSTRAINT friends_friend_user_id_fkey FOREIGN KEY (friend_user_id) REFERENCES public.users(id);
3129
3130
3131 --
3132 -- Name: friends friends_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3133 --
3134
3135 ALTER TABLE ONLY public.friends
3136     ADD CONSTRAINT friends_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
3137
3138
3139 --
3140 -- Name: gps_points gps_points_gpx_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3141 --
3142
3143 ALTER TABLE ONLY public.gps_points
3144     ADD CONSTRAINT gps_points_gpx_id_fkey FOREIGN KEY (gpx_id) REFERENCES public.gpx_files(id);
3145
3146
3147 --
3148 -- Name: gpx_file_tags gpx_file_tags_gpx_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3149 --
3150
3151 ALTER TABLE ONLY public.gpx_file_tags
3152     ADD CONSTRAINT gpx_file_tags_gpx_id_fkey FOREIGN KEY (gpx_id) REFERENCES public.gpx_files(id);
3153
3154
3155 --
3156 -- Name: gpx_files gpx_files_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3157 --
3158
3159 ALTER TABLE ONLY public.gpx_files
3160     ADD CONSTRAINT gpx_files_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
3161
3162
3163 --
3164 -- Name: issue_comments issue_comments_issue_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3165 --
3166
3167 ALTER TABLE ONLY public.issue_comments
3168     ADD CONSTRAINT issue_comments_issue_id_fkey FOREIGN KEY (issue_id) REFERENCES public.issues(id);
3169
3170
3171 --
3172 -- Name: issue_comments issue_comments_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3173 --
3174
3175 ALTER TABLE ONLY public.issue_comments
3176     ADD CONSTRAINT issue_comments_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
3177
3178
3179 --
3180 -- Name: issues issues_reported_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3181 --
3182
3183 ALTER TABLE ONLY public.issues
3184     ADD CONSTRAINT issues_reported_user_id_fkey FOREIGN KEY (reported_user_id) REFERENCES public.users(id);
3185
3186
3187 --
3188 -- Name: issues issues_resolved_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3189 --
3190
3191 ALTER TABLE ONLY public.issues
3192     ADD CONSTRAINT issues_resolved_by_fkey FOREIGN KEY (resolved_by) REFERENCES public.users(id);
3193
3194
3195 --
3196 -- Name: issues issues_updated_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3197 --
3198
3199 ALTER TABLE ONLY public.issues
3200     ADD CONSTRAINT issues_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES public.users(id);
3201
3202
3203 --
3204 -- Name: messages messages_from_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3205 --
3206
3207 ALTER TABLE ONLY public.messages
3208     ADD CONSTRAINT messages_from_user_id_fkey FOREIGN KEY (from_user_id) REFERENCES public.users(id);
3209
3210
3211 --
3212 -- Name: messages messages_to_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3213 --
3214
3215 ALTER TABLE ONLY public.messages
3216     ADD CONSTRAINT messages_to_user_id_fkey FOREIGN KEY (to_user_id) REFERENCES public.users(id);
3217
3218
3219 --
3220 -- Name: node_tags node_tags_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3221 --
3222
3223 ALTER TABLE ONLY public.node_tags
3224     ADD CONSTRAINT node_tags_id_fkey FOREIGN KEY (node_id, version) REFERENCES public.nodes(node_id, version);
3225
3226
3227 --
3228 -- Name: nodes nodes_changeset_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3229 --
3230
3231 ALTER TABLE ONLY public.nodes
3232     ADD CONSTRAINT nodes_changeset_id_fkey FOREIGN KEY (changeset_id) REFERENCES public.changesets(id);
3233
3234
3235 --
3236 -- Name: nodes nodes_redaction_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3237 --
3238
3239 ALTER TABLE ONLY public.nodes
3240     ADD CONSTRAINT nodes_redaction_id_fkey FOREIGN KEY (redaction_id) REFERENCES public.redactions(id);
3241
3242
3243 --
3244 -- Name: note_comments note_comments_author_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3245 --
3246
3247 ALTER TABLE ONLY public.note_comments
3248     ADD CONSTRAINT note_comments_author_id_fkey FOREIGN KEY (author_id) REFERENCES public.users(id);
3249
3250
3251 --
3252 -- Name: note_comments note_comments_note_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3253 --
3254
3255 ALTER TABLE ONLY public.note_comments
3256     ADD CONSTRAINT note_comments_note_id_fkey FOREIGN KEY (note_id) REFERENCES public.notes(id);
3257
3258
3259 --
3260 -- Name: notes notes_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3261 --
3262
3263 ALTER TABLE ONLY public.notes
3264     ADD CONSTRAINT notes_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
3265
3266
3267 --
3268 -- Name: redactions redactions_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3269 --
3270
3271 ALTER TABLE ONLY public.redactions
3272     ADD CONSTRAINT redactions_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
3273
3274
3275 --
3276 -- Name: relation_members relation_members_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3277 --
3278
3279 ALTER TABLE ONLY public.relation_members
3280     ADD CONSTRAINT relation_members_id_fkey FOREIGN KEY (relation_id, version) REFERENCES public.relations(relation_id, version);
3281
3282
3283 --
3284 -- Name: relation_tags relation_tags_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3285 --
3286
3287 ALTER TABLE ONLY public.relation_tags
3288     ADD CONSTRAINT relation_tags_id_fkey FOREIGN KEY (relation_id, version) REFERENCES public.relations(relation_id, version);
3289
3290
3291 --
3292 -- Name: relations relations_changeset_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3293 --
3294
3295 ALTER TABLE ONLY public.relations
3296     ADD CONSTRAINT relations_changeset_id_fkey FOREIGN KEY (changeset_id) REFERENCES public.changesets(id);
3297
3298
3299 --
3300 -- Name: relations relations_redaction_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3301 --
3302
3303 ALTER TABLE ONLY public.relations
3304     ADD CONSTRAINT relations_redaction_id_fkey FOREIGN KEY (redaction_id) REFERENCES public.redactions(id);
3305
3306
3307 --
3308 -- Name: reports reports_issue_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3309 --
3310
3311 ALTER TABLE ONLY public.reports
3312     ADD CONSTRAINT reports_issue_id_fkey FOREIGN KEY (issue_id) REFERENCES public.issues(id);
3313
3314
3315 --
3316 -- Name: reports reports_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3317 --
3318
3319 ALTER TABLE ONLY public.reports
3320     ADD CONSTRAINT reports_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
3321
3322
3323 --
3324 -- Name: user_blocks user_blocks_moderator_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3325 --
3326
3327 ALTER TABLE ONLY public.user_blocks
3328     ADD CONSTRAINT user_blocks_moderator_id_fkey FOREIGN KEY (creator_id) REFERENCES public.users(id);
3329
3330
3331 --
3332 -- Name: user_blocks user_blocks_revoker_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3333 --
3334
3335 ALTER TABLE ONLY public.user_blocks
3336     ADD CONSTRAINT user_blocks_revoker_id_fkey FOREIGN KEY (revoker_id) REFERENCES public.users(id);
3337
3338
3339 --
3340 -- Name: user_blocks user_blocks_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3341 --
3342
3343 ALTER TABLE ONLY public.user_blocks
3344     ADD CONSTRAINT user_blocks_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
3345
3346
3347 --
3348 -- Name: user_preferences user_preferences_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3349 --
3350
3351 ALTER TABLE ONLY public.user_preferences
3352     ADD CONSTRAINT user_preferences_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
3353
3354
3355 --
3356 -- Name: user_roles user_roles_granter_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3357 --
3358
3359 ALTER TABLE ONLY public.user_roles
3360     ADD CONSTRAINT user_roles_granter_id_fkey FOREIGN KEY (granter_id) REFERENCES public.users(id);
3361
3362
3363 --
3364 -- Name: user_roles user_roles_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3365 --
3366
3367 ALTER TABLE ONLY public.user_roles
3368     ADD CONSTRAINT user_roles_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
3369
3370
3371 --
3372 -- Name: way_nodes way_nodes_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3373 --
3374
3375 ALTER TABLE ONLY public.way_nodes
3376     ADD CONSTRAINT way_nodes_id_fkey FOREIGN KEY (way_id, version) REFERENCES public.ways(way_id, version);
3377
3378
3379 --
3380 -- Name: way_tags way_tags_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3381 --
3382
3383 ALTER TABLE ONLY public.way_tags
3384     ADD CONSTRAINT way_tags_id_fkey FOREIGN KEY (way_id, version) REFERENCES public.ways(way_id, version);
3385
3386
3387 --
3388 -- Name: ways ways_changeset_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3389 --
3390
3391 ALTER TABLE ONLY public.ways
3392     ADD CONSTRAINT ways_changeset_id_fkey FOREIGN KEY (changeset_id) REFERENCES public.changesets(id);
3393
3394
3395 --
3396 -- Name: ways ways_redaction_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
3397 --
3398
3399 ALTER TABLE ONLY public.ways
3400     ADD CONSTRAINT ways_redaction_id_fkey FOREIGN KEY (redaction_id) REFERENCES public.redactions(id);
3401
3402
3403 --
3404 -- PostgreSQL database dump complete
3405 --
3406
3407 SET search_path TO "$user", public;
3408
3409 INSERT INTO "schema_migrations" (version) VALUES
3410 ('9'),
3411 ('8'),
3412 ('7'),
3413 ('6'),
3414 ('57'),
3415 ('56'),
3416 ('55'),
3417 ('54'),
3418 ('53'),
3419 ('52'),
3420 ('51'),
3421 ('50'),
3422 ('5'),
3423 ('49'),
3424 ('48'),
3425 ('47'),
3426 ('46'),
3427 ('45'),
3428 ('44'),
3429 ('43'),
3430 ('42'),
3431 ('41'),
3432 ('40'),
3433 ('4'),
3434 ('39'),
3435 ('38'),
3436 ('37'),
3437 ('36'),
3438 ('35'),
3439 ('34'),
3440 ('33'),
3441 ('32'),
3442 ('31'),
3443 ('30'),
3444 ('3'),
3445 ('29'),
3446 ('28'),
3447 ('27'),
3448 ('26'),
3449 ('25'),
3450 ('24'),
3451 ('23'),
3452 ('22'),
3453 ('21'),
3454 ('20250304172798'),
3455 ('20250304172758'),
3456 ('20250212160355'),
3457 ('20250206202905'),
3458 ('20250121191749'),
3459 ('20250105154621'),
3460 ('20250104140952'),
3461 ('20241030090336'),
3462 ('20241023004427'),
3463 ('20241022141247'),
3464 ('20240913171951'),
3465 ('20240912181413'),
3466 ('20240910175616'),
3467 ('20240822121603'),
3468 ('20240813070506'),
3469 ('20240724194738'),
3470 ('20240618193051'),
3471 ('20240605134916'),
3472 ('20240405083825'),
3473 ('20240307181018'),
3474 ('20240307180830'),
3475 ('20240228205723'),
3476 ('20240117185445'),
3477 ('20231213182102'),
3478 ('20231206141457'),
3479 ('20231117170422'),
3480 ('20231101222146'),
3481 ('20231029151516'),
3482 ('20231010203028'),
3483 ('20231010201451'),
3484 ('20231010194809'),
3485 ('20231007141103'),
3486 ('20230830115220'),
3487 ('20230830115219'),
3488 ('20230825162137'),
3489 ('20230816135800'),
3490 ('20220223140543'),
3491 ('20220201183346'),
3492 ('20211216185316'),
3493 ('20210511104518'),
3494 ('20210510083028'),
3495 ('20210510083027'),
3496 ('20201214144017'),
3497 ('20201006220807'),
3498 ('20201006213836'),
3499 ('20201004105659'),
3500 ('20191120140058'),
3501 ('20190716173946'),
3502 ('20190702193519'),
3503 ('20190623093642'),
3504 ('20190518115041'),
3505 ('20181031113522'),
3506 ('20181020114000'),
3507 ('20180204153242'),
3508 ('20170222134109'),
3509 ('20161011010929'),
3510 ('20161002153425'),
3511 ('20160822153055'),
3512 ('20150818224516'),
3513 ('20150222101847'),
3514 ('20150111192335'),
3515 ('20150110152606'),
3516 ('20140519141742'),
3517 ('20140507110937'),
3518 ('20140210003018'),
3519 ('20140117185510'),
3520 ('20140115192822'),
3521 ('20131212124700'),
3522 ('20130328184137'),
3523 ('20121203124841'),
3524 ('20121202155309'),
3525 ('20121119165817'),
3526 ('20121012044047'),
3527 ('20121005195010'),
3528 ('20120808231205'),
3529 ('20120404205604'),
3530 ('20120328090602'),
3531 ('20120318201948'),
3532 ('20120219161649'),
3533 ('20120214210114'),
3534 ('20120208194454'),
3535 ('20120208122334'),
3536 ('20120123184321'),
3537 ('20111212183945'),
3538 ('20111116184519'),
3539 ('20110925112722'),
3540 ('20110521142405'),
3541 ('20110508145337'),
3542 ('20110322001319'),
3543 ('20101114011429'),
3544 ('20100910084426'),
3545 ('20100516124737'),
3546 ('20100513171259'),
3547 ('20'),
3548 ('2'),
3549 ('19'),
3550 ('18'),
3551 ('17'),
3552 ('16'),
3553 ('15'),
3554 ('14'),
3555 ('13'),
3556 ('12'),
3557 ('11'),
3558 ('10'),
3559 ('1');
3560