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