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