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