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