]> git.ipfire.org Git - pbs.git/blob - src/database.sql
Drop all all history stuff
[pbs.git] / src / database.sql
1 --
2 -- PostgreSQL database dump
3 --
4
5 -- Dumped from database version 13.8 (Debian 13.8-0+deb11u1)
6 -- Dumped by pg_dump version 13.8 (Debian 13.8-0+deb11u1)
7
8 SET statement_timeout = 0;
9 SET lock_timeout = 0;
10 SET idle_in_transaction_session_timeout = 0;
11 SET client_encoding = 'UTF8';
12 SET standard_conforming_strings = on;
13 SELECT pg_catalog.set_config('search_path', '', false);
14 SET check_function_bodies = false;
15 SET xmloption = content;
16 SET client_min_messages = warning;
17 SET row_security = off;
18
19 --
20 -- Name: on_update_current_timestamp_sources(); Type: FUNCTION; Schema: public; Owner: -
21 --
22
23 CREATE FUNCTION public.on_update_current_timestamp_sources() RETURNS trigger
24 LANGUAGE plpgsql
25 AS $$
26 BEGIN
27 NEW.updated = now();
28 RETURN NEW;
29 END;
30 $$;
31
32
33 SET default_tablespace = '';
34
35 SET default_table_access_method = heap;
36
37 --
38 -- Name: build_packages; Type: TABLE; Schema: public; Owner: -
39 --
40
41 CREATE TABLE public.build_packages (
42 build_id integer NOT NULL,
43 package_id integer NOT NULL,
44 job_id integer NOT NULL,
45 created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
46 );
47
48
49 --
50 -- Name: build_watchers; Type: TABLE; Schema: public; Owner: -
51 --
52
53 CREATE TABLE public.build_watchers (
54 build_id integer NOT NULL,
55 user_id integer NOT NULL,
56 added_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
57 deleted_at timestamp without time zone
58 );
59
60
61 --
62 -- Name: builder_stats; Type: TABLE; Schema: public; Owner: -
63 --
64
65 CREATE TABLE public.builder_stats (
66 builder_id integer NOT NULL,
67 created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
68 cpu_user double precision NOT NULL,
69 cpu_nice double precision NOT NULL,
70 cpu_system double precision NOT NULL,
71 cpu_idle double precision NOT NULL,
72 cpu_iowait double precision NOT NULL,
73 cpu_irq double precision NOT NULL,
74 cpu_softirq double precision NOT NULL,
75 cpu_steal double precision NOT NULL,
76 cpu_guest double precision NOT NULL,
77 cpu_guest_nice double precision NOT NULL,
78 loadavg1 double precision NOT NULL,
79 loadavg5 double precision NOT NULL,
80 loadavg15 double precision NOT NULL,
81 mem_total bigint NOT NULL,
82 mem_available bigint NOT NULL,
83 mem_used bigint NOT NULL,
84 mem_free bigint NOT NULL,
85 mem_active bigint NOT NULL,
86 mem_inactive bigint NOT NULL,
87 mem_buffers bigint NOT NULL,
88 mem_cached bigint NOT NULL,
89 mem_shared bigint NOT NULL,
90 swap_total bigint NOT NULL,
91 swap_used bigint NOT NULL,
92 swap_free bigint NOT NULL
93 );
94
95
96 --
97 -- Name: builders; Type: TABLE; Schema: public; Owner: -
98 --
99
100 CREATE TABLE public.builders (
101 id integer NOT NULL,
102 name text NOT NULL,
103 description text,
104 enabled boolean DEFAULT false NOT NULL,
105 deleted boolean DEFAULT false NOT NULL,
106 loadavg text DEFAULT '0'::character varying NOT NULL,
107 testmode boolean DEFAULT true NOT NULL,
108 max_jobs bigint DEFAULT (1)::bigint NOT NULL,
109 pakfire_version text,
110 os_name text,
111 cpu_model text,
112 cpu_count integer DEFAULT 1 NOT NULL,
113 host_key_id text,
114 time_created timestamp without time zone DEFAULT now() NOT NULL,
115 updated_at timestamp without time zone,
116 time_keepalive timestamp without time zone,
117 online_until timestamp without time zone,
118 cpu_arch text,
119 instance_id text,
120 instance_type text
121 );
122
123
124 --
125 -- Name: builders_id_seq; Type: SEQUENCE; Schema: public; Owner: -
126 --
127
128 CREATE SEQUENCE public.builders_id_seq
129 START WITH 1
130 INCREMENT BY 1
131 NO MINVALUE
132 NO MAXVALUE
133 CACHE 1;
134
135
136 --
137 -- Name: builders_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
138 --
139
140 ALTER SEQUENCE public.builders_id_seq OWNED BY public.builders.id;
141
142
143 --
144 -- Name: builds; Type: TABLE; Schema: public; Owner: -
145 --
146
147 CREATE TABLE public.builds (
148 id integer NOT NULL,
149 uuid uuid DEFAULT gen_random_uuid() NOT NULL,
150 pkg_id integer NOT NULL,
151 state text DEFAULT 'building'::text NOT NULL,
152 severity text,
153 message text,
154 created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
155 build_repo_id integer NOT NULL,
156 owner_id integer,
157 priority integer DEFAULT 0 NOT NULL,
158 deleted boolean DEFAULT false NOT NULL,
159 bug_ids integer[] DEFAULT ARRAY[]::integer[] NOT NULL,
160 finished_at timestamp without time zone,
161 failed boolean DEFAULT false NOT NULL
162 );
163
164
165 --
166 -- Name: builds_bugs_updates; Type: TABLE; Schema: public; Owner: -
167 --
168
169 CREATE TABLE public.builds_bugs_updates (
170 id integer NOT NULL,
171 bug_id integer NOT NULL,
172 status text,
173 resolution text,
174 comment text,
175 "time" timestamp without time zone NOT NULL,
176 error boolean DEFAULT false NOT NULL,
177 error_msg text
178 );
179
180
181 --
182 -- Name: builds_bugs_updates_id_seq; Type: SEQUENCE; Schema: public; Owner: -
183 --
184
185 CREATE SEQUENCE public.builds_bugs_updates_id_seq
186 START WITH 1
187 INCREMENT BY 1
188 NO MINVALUE
189 NO MAXVALUE
190 CACHE 1;
191
192
193 --
194 -- Name: builds_bugs_updates_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
195 --
196
197 ALTER SEQUENCE public.builds_bugs_updates_id_seq OWNED BY public.builds_bugs_updates.id;
198
199
200 --
201 -- Name: builds_comments; Type: TABLE; Schema: public; Owner: -
202 --
203
204 CREATE TABLE public.builds_comments (
205 id integer NOT NULL,
206 build_id integer NOT NULL,
207 user_id integer NOT NULL,
208 text text,
209 score integer NOT NULL,
210 time_created timestamp without time zone DEFAULT now() NOT NULL,
211 time_updated timestamp without time zone
212 );
213
214
215 --
216 -- Name: builds_comments_id_seq; Type: SEQUENCE; Schema: public; Owner: -
217 --
218
219 CREATE SEQUENCE public.builds_comments_id_seq
220 START WITH 1
221 INCREMENT BY 1
222 NO MINVALUE
223 NO MAXVALUE
224 CACHE 1;
225
226
227 --
228 -- Name: builds_comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
229 --
230
231 ALTER SEQUENCE public.builds_comments_id_seq OWNED BY public.builds_comments.id;
232
233
234 --
235 -- Name: builds_id_seq; Type: SEQUENCE; Schema: public; Owner: -
236 --
237
238 CREATE SEQUENCE public.builds_id_seq
239 START WITH 1
240 INCREMENT BY 1
241 NO MINVALUE
242 NO MAXVALUE
243 CACHE 1;
244
245
246 --
247 -- Name: builds_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
248 --
249
250 ALTER SEQUENCE public.builds_id_seq OWNED BY public.builds.id;
251
252
253 --
254 -- Name: distributions; Type: TABLE; Schema: public; Owner: -
255 --
256
257 CREATE TABLE public.distributions (
258 id integer NOT NULL,
259 name text NOT NULL,
260 slug text NOT NULL,
261 slogan text DEFAULT ''::text NOT NULL,
262 description text DEFAULT ''::text NOT NULL,
263 vendor text DEFAULT ''::text NOT NULL,
264 contact text DEFAULT ''::text NOT NULL,
265 tag text NOT NULL,
266 deleted boolean DEFAULT false NOT NULL,
267 arches text[] DEFAULT ARRAY[]::text[] NOT NULL,
268 created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
269 custom_config text DEFAULT ''::text NOT NULL
270 );
271
272
273 --
274 -- Name: distributions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
275 --
276
277 CREATE SEQUENCE public.distributions_id_seq
278 START WITH 1
279 INCREMENT BY 1
280 NO MINVALUE
281 NO MAXVALUE
282 CACHE 1;
283
284
285 --
286 -- Name: distributions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
287 --
288
289 ALTER SEQUENCE public.distributions_id_seq OWNED BY public.distributions.id;
290
291
292 --
293 -- Name: filelists; Type: TABLE; Schema: public; Owner: -
294 --
295
296 CREATE TABLE public.filelists (
297 pkg_id integer NOT NULL,
298 path text NOT NULL,
299 size bigint NOT NULL,
300 config boolean DEFAULT false NOT NULL,
301 mode integer NOT NULL,
302 uname text NOT NULL,
303 gname text NOT NULL,
304 capabilities text,
305 ctime timestamp without time zone NOT NULL,
306 mtime timestamp without time zone NOT NULL,
307 digest_sha2_512 bytea,
308 digest_sha2_256 bytea,
309 digest_blake2b512 bytea,
310 digest_blake2s256 bytea,
311 digest_sha3_512 bytea,
312 digest_sha3_256 bytea
313 );
314
315
316 --
317 -- Name: images_types; Type: TABLE; Schema: public; Owner: -
318 --
319
320 CREATE TABLE public.images_types (
321 id integer NOT NULL,
322 type text NOT NULL
323 );
324
325
326 --
327 -- Name: images_types_id_seq; Type: SEQUENCE; Schema: public; Owner: -
328 --
329
330 CREATE SEQUENCE public.images_types_id_seq
331 START WITH 1
332 INCREMENT BY 1
333 NO MINVALUE
334 NO MAXVALUE
335 CACHE 1;
336
337
338 --
339 -- Name: images_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
340 --
341
342 ALTER SEQUENCE public.images_types_id_seq OWNED BY public.images_types.id;
343
344
345 --
346 -- Name: jobs; Type: TABLE; Schema: public; Owner: -
347 --
348
349 CREATE TABLE public.jobs (
350 id integer NOT NULL,
351 uuid uuid DEFAULT gen_random_uuid() NOT NULL,
352 build_id integer NOT NULL,
353 arch text NOT NULL,
354 created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
355 started_at timestamp without time zone,
356 finished_at timestamp without time zone,
357 builder_id integer,
358 message text,
359 test boolean DEFAULT true NOT NULL,
360 superseeded_by integer,
361 depcheck_succeeded boolean,
362 depcheck_performed_at timestamp without time zone,
363 deleted boolean DEFAULT false NOT NULL,
364 failed boolean DEFAULT false NOT NULL,
365 log_path text,
366 log_size bigint,
367 log_digest_blake2s bytea
368 );
369
370
371 --
372 -- Name: job_queue; Type: VIEW; Schema: public; Owner: -
373 --
374
375 CREATE VIEW public.job_queue AS
376 SELECT jobs.id AS job_id,
377 rank() OVER (ORDER BY (NOT jobs.test), builds.priority DESC, jobs.created_at) AS rank,
378 jobs.arch
379 FROM (public.jobs
380 LEFT JOIN public.builds ON ((jobs.build_id = builds.id)))
381 WHERE ((jobs.deleted IS FALSE) AND (jobs.started_at IS NULL) AND (jobs.finished_at IS NULL) AND (jobs.depcheck_succeeded IS TRUE));
382
383
384 --
385 -- Name: jobs_buildroots; Type: TABLE; Schema: public; Owner: -
386 --
387
388 CREATE TABLE public.jobs_buildroots (
389 job_id integer NOT NULL,
390 pkg_uuid uuid NOT NULL,
391 pkg_name text NOT NULL
392 );
393
394
395 --
396 -- Name: jobs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
397 --
398
399 CREATE SEQUENCE public.jobs_id_seq
400 START WITH 1
401 INCREMENT BY 1
402 NO MINVALUE
403 NO MAXVALUE
404 CACHE 1;
405
406
407 --
408 -- Name: jobs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
409 --
410
411 ALTER SEQUENCE public.jobs_id_seq OWNED BY public.jobs.id;
412
413
414 --
415 -- Name: jobs_packages; Type: TABLE; Schema: public; Owner: -
416 --
417
418 CREATE TABLE public.jobs_packages (
419 id integer NOT NULL,
420 job_id integer NOT NULL,
421 pkg_id integer NOT NULL
422 );
423
424
425 --
426 -- Name: jobs_packages_id_seq; Type: SEQUENCE; Schema: public; Owner: -
427 --
428
429 CREATE SEQUENCE public.jobs_packages_id_seq
430 START WITH 1
431 INCREMENT BY 1
432 NO MINVALUE
433 NO MAXVALUE
434 CACHE 1;
435
436
437 --
438 -- Name: jobs_packages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
439 --
440
441 ALTER SEQUENCE public.jobs_packages_id_seq OWNED BY public.jobs_packages.id;
442
443
444 --
445 -- Name: keys; Type: TABLE; Schema: public; Owner: -
446 --
447
448 CREATE TABLE public.keys (
449 id integer NOT NULL,
450 fingerprint text NOT NULL,
451 uid text NOT NULL,
452 created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
453 expires_at timestamp without time zone,
454 public_key text NOT NULL,
455 secret_key text NOT NULL,
456 name text NOT NULL,
457 email text NOT NULL,
458 deleted boolean DEFAULT false NOT NULL,
459 algo text NOT NULL,
460 length integer NOT NULL,
461 parent_key_id integer,
462 revoked_at timestamp without time zone
463 );
464
465
466 --
467 -- Name: keys_id_seq; Type: SEQUENCE; Schema: public; Owner: -
468 --
469
470 CREATE SEQUENCE public.keys_id_seq
471 START WITH 1
472 INCREMENT BY 1
473 NO MINVALUE
474 NO MAXVALUE
475 CACHE 1;
476
477
478 --
479 -- Name: keys_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
480 --
481
482 ALTER SEQUENCE public.keys_id_seq OWNED BY public.keys.id;
483
484
485 --
486 -- Name: logfiles; Type: TABLE; Schema: public; Owner: -
487 --
488
489 CREATE TABLE public.logfiles (
490 id integer NOT NULL,
491 job_id integer NOT NULL,
492 path text NOT NULL,
493 filesize bigint NOT NULL,
494 hash_sha512 text NOT NULL
495 );
496
497
498 --
499 -- Name: logfiles_id_seq; Type: SEQUENCE; Schema: public; Owner: -
500 --
501
502 CREATE SEQUENCE public.logfiles_id_seq
503 START WITH 1
504 INCREMENT BY 1
505 NO MINVALUE
506 NO MAXVALUE
507 CACHE 1;
508
509
510 --
511 -- Name: logfiles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
512 --
513
514 ALTER SEQUENCE public.logfiles_id_seq OWNED BY public.logfiles.id;
515
516
517 --
518 -- Name: messages; Type: TABLE; Schema: public; Owner: -
519 --
520
521 CREATE TABLE public.messages (
522 id integer NOT NULL,
523 message text NOT NULL,
524 queued_at timestamp without time zone DEFAULT now() NOT NULL,
525 sent_at timestamp without time zone
526 );
527
528
529 --
530 -- Name: messages_id_seq; Type: SEQUENCE; Schema: public; Owner: -
531 --
532
533 CREATE SEQUENCE public.messages_id_seq
534 START WITH 1
535 INCREMENT BY 1
536 NO MINVALUE
537 NO MAXVALUE
538 CACHE 1;
539
540
541 --
542 -- Name: messages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
543 --
544
545 ALTER SEQUENCE public.messages_id_seq OWNED BY public.messages.id;
546
547
548 --
549 -- Name: mirrors; Type: TABLE; Schema: public; Owner: -
550 --
551
552 CREATE TABLE public.mirrors (
553 id integer NOT NULL,
554 hostname text NOT NULL,
555 path text NOT NULL,
556 owner text,
557 contact text,
558 deleted boolean DEFAULT false NOT NULL,
559 supports_https boolean DEFAULT false NOT NULL
560 );
561
562
563 --
564 -- Name: mirrors_checks; Type: TABLE; Schema: public; Owner: -
565 --
566
567 CREATE TABLE public.mirrors_checks (
568 id integer NOT NULL,
569 mirror_id integer NOT NULL,
570 "timestamp" timestamp without time zone DEFAULT now() NOT NULL,
571 response_time double precision,
572 http_status integer,
573 last_sync_at timestamp without time zone,
574 status text DEFAULT 'OK'::text NOT NULL
575 );
576
577
578 --
579 -- Name: mirrors_checks_id_seq; Type: SEQUENCE; Schema: public; Owner: -
580 --
581
582 CREATE SEQUENCE public.mirrors_checks_id_seq
583 START WITH 1
584 INCREMENT BY 1
585 NO MINVALUE
586 NO MAXVALUE
587 CACHE 1;
588
589
590 --
591 -- Name: mirrors_checks_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
592 --
593
594 ALTER SEQUENCE public.mirrors_checks_id_seq OWNED BY public.mirrors_checks.id;
595
596
597 --
598 -- Name: mirrors_id_seq; Type: SEQUENCE; Schema: public; Owner: -
599 --
600
601 CREATE SEQUENCE public.mirrors_id_seq
602 START WITH 1
603 INCREMENT BY 1
604 NO MINVALUE
605 NO MAXVALUE
606 CACHE 1;
607
608
609 --
610 -- Name: mirrors_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
611 --
612
613 ALTER SEQUENCE public.mirrors_id_seq OWNED BY public.mirrors.id;
614
615
616 --
617 -- Name: packages; Type: TABLE; Schema: public; Owner: -
618 --
619
620 CREATE TABLE public.packages (
621 id integer NOT NULL,
622 name text NOT NULL,
623 evr text NOT NULL,
624 arch text NOT NULL,
625 groups text NOT NULL,
626 maintainer text,
627 license text NOT NULL,
628 url text NOT NULL,
629 summary text NOT NULL,
630 description text NOT NULL,
631 size bigint NOT NULL,
632 supported_arches text,
633 uuid uuid NOT NULL,
634 commit_id integer,
635 build_id text,
636 build_host text NOT NULL,
637 build_time timestamp without time zone NOT NULL,
638 path text,
639 filesize bigint NOT NULL,
640 prerequires text[] DEFAULT ARRAY[]::text[] NOT NULL,
641 requires text[] DEFAULT ARRAY[]::text[] NOT NULL,
642 provides text[] DEFAULT ARRAY[]::text[] NOT NULL,
643 obsoletes text[] DEFAULT ARRAY[]::text[] NOT NULL,
644 conflicts text[] DEFAULT ARRAY[]::text[] NOT NULL,
645 recommends text[] DEFAULT ARRAY[]::text[] NOT NULL,
646 suggests text[] DEFAULT ARRAY[]::text[] NOT NULL,
647 created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
648 deleted boolean DEFAULT false NOT NULL,
649 digest_type text NOT NULL,
650 digest bytea NOT NULL
651 );
652
653
654 --
655 -- Name: package_estimated_build_times; Type: VIEW; Schema: public; Owner: -
656 --
657
658 CREATE VIEW public.package_estimated_build_times AS
659 SELECT packages.name,
660 jobs.arch,
661 avg((jobs.finished_at - jobs.started_at)) AS build_time
662 FROM ((public.jobs
663 LEFT JOIN public.builds ON ((jobs.build_id = builds.id)))
664 LEFT JOIN public.packages ON ((builds.pkg_id = packages.id)))
665 WHERE ((jobs.deleted IS FALSE) AND (jobs.started_at IS NOT NULL) AND (jobs.finished_at IS NOT NULL) AND (jobs.failed IS FALSE) AND (jobs.test IS FALSE))
666 GROUP BY packages.name, jobs.arch;
667
668
669 --
670 -- Name: VIEW package_estimated_build_times; Type: COMMENT; Schema: public; Owner: -
671 --
672
673 COMMENT ON VIEW public.package_estimated_build_times IS 'Should add this later: AND jobs.time_finished >= (CURRENT_TIMESTAMP - ''180 days''::interval)';
674
675
676 --
677 -- Name: package_search_index_generator; Type: VIEW; Schema: public; Owner: -
678 --
679
680 CREATE VIEW public.package_search_index_generator AS
681 WITH p AS (
682 SELECT DISTINCT ON (packages.name) packages.id,
683 packages.name,
684 packages.summary,
685 packages.description
686 FROM public.packages
687 WHERE ((packages.deleted IS FALSE) AND (packages.arch = 'src'::text))
688 ORDER BY packages.name, packages.created_at DESC
689 )
690 SELECT p.id AS package_id,
691 ((setweight(to_tsvector('simple'::regconfig, p.name), 'A'::"char") || setweight(to_tsvector('english'::regconfig, p.summary), 'B'::"char")) || setweight(to_tsvector('english'::regconfig, p.description), 'C'::"char")) AS document
692 FROM p;
693
694
695 --
696 -- Name: package_search_index; Type: MATERIALIZED VIEW; Schema: public; Owner: -
697 --
698
699 CREATE MATERIALIZED VIEW public.package_search_index AS
700 SELECT package_search_index_generator.package_id,
701 package_search_index_generator.document
702 FROM public.package_search_index_generator
703 WITH NO DATA;
704
705
706 --
707 -- Name: packages_id_seq; Type: SEQUENCE; Schema: public; Owner: -
708 --
709
710 CREATE SEQUENCE public.packages_id_seq
711 START WITH 1
712 INCREMENT BY 1
713 NO MINVALUE
714 NO MAXVALUE
715 CACHE 1;
716
717
718 --
719 -- Name: packages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
720 --
721
722 ALTER SEQUENCE public.packages_id_seq OWNED BY public.packages.id;
723
724
725 --
726 -- Name: packages_properties; Type: TABLE; Schema: public; Owner: -
727 --
728
729 CREATE TABLE public.packages_properties (
730 id integer NOT NULL,
731 name text NOT NULL,
732 priority integer DEFAULT 0 NOT NULL
733 );
734
735
736 --
737 -- Name: packages_properties_id_seq; Type: SEQUENCE; Schema: public; Owner: -
738 --
739
740 CREATE SEQUENCE public.packages_properties_id_seq
741 START WITH 1
742 INCREMENT BY 1
743 NO MINVALUE
744 NO MAXVALUE
745 CACHE 1;
746
747
748 --
749 -- Name: packages_properties_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
750 --
751
752 ALTER SEQUENCE public.packages_properties_id_seq OWNED BY public.packages_properties.id;
753
754
755 --
756 -- Name: relation_sizes; Type: VIEW; Schema: public; Owner: -
757 --
758
759 CREATE VIEW public.relation_sizes AS
760 SELECT c.relname AS relation,
761 pg_size_pretty(pg_relation_size((c.oid)::regclass)) AS size
762 FROM (pg_class c
763 LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
764 WHERE (n.nspname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name]))
765 ORDER BY (pg_relation_size((c.oid)::regclass)) DESC;
766
767
768 --
769 -- Name: repo_builds; Type: TABLE; Schema: public; Owner: -
770 --
771
772 CREATE TABLE public.repo_builds (
773 repo_id integer NOT NULL,
774 build_id integer NOT NULL,
775 added_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
776 added_by integer,
777 removed_at timestamp without time zone,
778 removed_by integer
779 );
780
781
782 --
783 -- Name: repositories; Type: TABLE; Schema: public; Owner: -
784 --
785
786 CREATE TABLE public.repositories (
787 id integer NOT NULL,
788 name text NOT NULL,
789 slug text,
790 description text DEFAULT ''::text NOT NULL,
791 distro_id integer NOT NULL,
792 parent_id integer,
793 key_id integer NOT NULL,
794 mirrored boolean DEFAULT false NOT NULL,
795 updated_at timestamp without time zone,
796 deleted boolean DEFAULT false NOT NULL,
797 priority integer,
798 owner_id integer,
799 created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
800 listed boolean DEFAULT true NOT NULL
801 );
802
803
804 --
805 -- Name: repositories_builds; Type: TABLE; Schema: public; Owner: -
806 --
807
808 CREATE TABLE public.repositories_builds (
809 id integer NOT NULL,
810 repo_id integer NOT NULL,
811 build_id bigint NOT NULL,
812 time_added timestamp without time zone NOT NULL
813 );
814
815
816 --
817 -- Name: repositories_builds_id_seq; Type: SEQUENCE; Schema: public; Owner: -
818 --
819
820 CREATE SEQUENCE public.repositories_builds_id_seq
821 START WITH 1
822 INCREMENT BY 1
823 NO MINVALUE
824 NO MAXVALUE
825 CACHE 1;
826
827
828 --
829 -- Name: repositories_builds_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
830 --
831
832 ALTER SEQUENCE public.repositories_builds_id_seq OWNED BY public.repositories_builds.id;
833
834
835 --
836 -- Name: repositories_id_seq; Type: SEQUENCE; Schema: public; Owner: -
837 --
838
839 CREATE SEQUENCE public.repositories_id_seq
840 START WITH 1
841 INCREMENT BY 1
842 NO MINVALUE
843 NO MAXVALUE
844 CACHE 1;
845
846
847 --
848 -- Name: repositories_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
849 --
850
851 ALTER SEQUENCE public.repositories_id_seq OWNED BY public.repositories.id;
852
853
854 --
855 -- Name: sessions; Type: TABLE; Schema: public; Owner: -
856 --
857
858 CREATE TABLE public.sessions (
859 id integer NOT NULL,
860 session_id text NOT NULL,
861 created_at timestamp without time zone DEFAULT now() NOT NULL,
862 valid_until timestamp without time zone DEFAULT (now() + '7 days'::interval) NOT NULL,
863 user_id integer NOT NULL,
864 address inet,
865 user_agent text
866 );
867
868
869 --
870 -- Name: sessions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
871 --
872
873 CREATE SEQUENCE public.sessions_id_seq
874 START WITH 1
875 INCREMENT BY 1
876 NO MINVALUE
877 NO MAXVALUE
878 CACHE 1;
879
880
881 --
882 -- Name: sessions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
883 --
884
885 ALTER SEQUENCE public.sessions_id_seq OWNED BY public.sessions.id;
886
887
888 --
889 -- Name: settings; Type: TABLE; Schema: public; Owner: -
890 --
891
892 CREATE TABLE public.settings (
893 k text NOT NULL,
894 v text NOT NULL
895 );
896
897
898 --
899 -- Name: sources; Type: TABLE; Schema: public; Owner: -
900 --
901
902 CREATE TABLE public.sources (
903 id integer NOT NULL,
904 name text NOT NULL,
905 identifier text NOT NULL,
906 url text NOT NULL,
907 gitweb text,
908 revision text NOT NULL,
909 branch text NOT NULL,
910 updated timestamp without time zone,
911 distro_id integer NOT NULL
912 );
913
914
915 --
916 -- Name: sources_commits; Type: TABLE; Schema: public; Owner: -
917 --
918
919 CREATE TABLE public.sources_commits (
920 id integer NOT NULL,
921 source_id integer NOT NULL,
922 revision text NOT NULL,
923 author text NOT NULL,
924 committer text NOT NULL,
925 subject text NOT NULL,
926 body text NOT NULL,
927 date timestamp without time zone NOT NULL,
928 state text DEFAULT 'pending'::text NOT NULL,
929 imported_at timestamp without time zone DEFAULT now() NOT NULL
930 );
931
932
933 --
934 -- Name: sources_commits_id_seq; Type: SEQUENCE; Schema: public; Owner: -
935 --
936
937 CREATE SEQUENCE public.sources_commits_id_seq
938 START WITH 1
939 INCREMENT BY 1
940 NO MINVALUE
941 NO MAXVALUE
942 CACHE 1;
943
944
945 --
946 -- Name: sources_commits_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
947 --
948
949 ALTER SEQUENCE public.sources_commits_id_seq OWNED BY public.sources_commits.id;
950
951
952 --
953 -- Name: sources_id_seq; Type: SEQUENCE; Schema: public; Owner: -
954 --
955
956 CREATE SEQUENCE public.sources_id_seq
957 START WITH 1
958 INCREMENT BY 1
959 NO MINVALUE
960 NO MAXVALUE
961 CACHE 1;
962
963
964 --
965 -- Name: sources_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
966 --
967
968 ALTER SEQUENCE public.sources_id_seq OWNED BY public.sources.id;
969
970
971 --
972 -- Name: uploads; Type: TABLE; Schema: public; Owner: -
973 --
974
975 CREATE TABLE public.uploads (
976 id integer NOT NULL,
977 uuid uuid DEFAULT gen_random_uuid() NOT NULL,
978 user_id integer,
979 builder_id integer,
980 filename text NOT NULL,
981 path text NOT NULL,
982 size bigint NOT NULL,
983 created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
984 expires_at timestamp without time zone DEFAULT (CURRENT_TIMESTAMP + '24:00:00'::interval) NOT NULL
985 );
986
987
988 --
989 -- Name: uploads_id_seq; Type: SEQUENCE; Schema: public; Owner: -
990 --
991
992 CREATE SEQUENCE public.uploads_id_seq
993 START WITH 1
994 INCREMENT BY 1
995 NO MINVALUE
996 NO MAXVALUE
997 CACHE 1;
998
999
1000 --
1001 -- Name: uploads_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1002 --
1003
1004 ALTER SEQUENCE public.uploads_id_seq OWNED BY public.uploads.id;
1005
1006
1007 --
1008 -- Name: user_disk_usages; Type: VIEW; Schema: public; Owner: -
1009 --
1010
1011 CREATE VIEW public.user_disk_usages AS
1012 WITH objects AS (
1013 SELECT uploads.user_id,
1014 uploads.size
1015 FROM public.uploads
1016 WHERE (uploads.expires_at > CURRENT_TIMESTAMP)
1017 UNION ALL
1018 SELECT builds.owner_id,
1019 packages.size
1020 FROM (public.builds
1021 LEFT JOIN public.packages ON ((builds.pkg_id = packages.id)))
1022 WHERE ((builds.deleted IS FALSE) AND (builds.owner_id IS NOT NULL))
1023 UNION ALL
1024 SELECT builds.owner_id,
1025 jobs.log_size
1026 FROM (public.jobs
1027 LEFT JOIN public.builds ON ((builds.id = jobs.build_id)))
1028 WHERE ((builds.deleted IS FALSE) AND (jobs.deleted IS FALSE) AND (builds.owner_id IS NOT NULL) AND (jobs.log_size IS NOT NULL))
1029 )
1030 SELECT objects.user_id,
1031 sum(objects.size) AS disk_usage
1032 FROM objects
1033 GROUP BY objects.user_id;
1034
1035
1036 --
1037 -- Name: users; Type: TABLE; Schema: public; Owner: -
1038 --
1039
1040 CREATE TABLE public.users (
1041 id integer NOT NULL,
1042 name text NOT NULL,
1043 realname text,
1044 locale text,
1045 timezone text,
1046 activated boolean DEFAULT true NOT NULL,
1047 deleted boolean DEFAULT false NOT NULL,
1048 registered_at timestamp without time zone DEFAULT now() NOT NULL,
1049 admin boolean DEFAULT false NOT NULL,
1050 quota bigint,
1051 perms text[] DEFAULT ARRAY[]::text[] NOT NULL
1052 );
1053
1054
1055 --
1056 -- Name: users_emails; Type: TABLE; Schema: public; Owner: -
1057 --
1058
1059 CREATE TABLE public.users_emails (
1060 id integer NOT NULL,
1061 user_id integer NOT NULL,
1062 email text NOT NULL,
1063 "primary" boolean DEFAULT false NOT NULL,
1064 activated boolean DEFAULT false NOT NULL,
1065 activation_code text
1066 );
1067
1068
1069 --
1070 -- Name: users_emails_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1071 --
1072
1073 CREATE SEQUENCE public.users_emails_id_seq
1074 START WITH 1
1075 INCREMENT BY 1
1076 NO MINVALUE
1077 NO MAXVALUE
1078 CACHE 1;
1079
1080
1081 --
1082 -- Name: users_emails_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1083 --
1084
1085 ALTER SEQUENCE public.users_emails_id_seq OWNED BY public.users_emails.id;
1086
1087
1088 --
1089 -- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1090 --
1091
1092 CREATE SEQUENCE public.users_id_seq
1093 START WITH 1
1094 INCREMENT BY 1
1095 NO MINVALUE
1096 NO MAXVALUE
1097 CACHE 1;
1098
1099
1100 --
1101 -- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1102 --
1103
1104 ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
1105
1106
1107 --
1108 -- Name: builders id; Type: DEFAULT; Schema: public; Owner: -
1109 --
1110
1111 ALTER TABLE ONLY public.builders ALTER COLUMN id SET DEFAULT nextval('public.builders_id_seq'::regclass);
1112
1113
1114 --
1115 -- Name: builds id; Type: DEFAULT; Schema: public; Owner: -
1116 --
1117
1118 ALTER TABLE ONLY public.builds ALTER COLUMN id SET DEFAULT nextval('public.builds_id_seq'::regclass);
1119
1120
1121 --
1122 -- Name: builds_bugs_updates id; Type: DEFAULT; Schema: public; Owner: -
1123 --
1124
1125 ALTER TABLE ONLY public.builds_bugs_updates ALTER COLUMN id SET DEFAULT nextval('public.builds_bugs_updates_id_seq'::regclass);
1126
1127
1128 --
1129 -- Name: builds_comments id; Type: DEFAULT; Schema: public; Owner: -
1130 --
1131
1132 ALTER TABLE ONLY public.builds_comments ALTER COLUMN id SET DEFAULT nextval('public.builds_comments_id_seq'::regclass);
1133
1134
1135 --
1136 -- Name: distributions id; Type: DEFAULT; Schema: public; Owner: -
1137 --
1138
1139 ALTER TABLE ONLY public.distributions ALTER COLUMN id SET DEFAULT nextval('public.distributions_id_seq'::regclass);
1140
1141
1142 --
1143 -- Name: images_types id; Type: DEFAULT; Schema: public; Owner: -
1144 --
1145
1146 ALTER TABLE ONLY public.images_types ALTER COLUMN id SET DEFAULT nextval('public.images_types_id_seq'::regclass);
1147
1148
1149 --
1150 -- Name: jobs id; Type: DEFAULT; Schema: public; Owner: -
1151 --
1152
1153 ALTER TABLE ONLY public.jobs ALTER COLUMN id SET DEFAULT nextval('public.jobs_id_seq'::regclass);
1154
1155
1156 --
1157 -- Name: jobs_packages id; Type: DEFAULT; Schema: public; Owner: -
1158 --
1159
1160 ALTER TABLE ONLY public.jobs_packages ALTER COLUMN id SET DEFAULT nextval('public.jobs_packages_id_seq'::regclass);
1161
1162
1163 --
1164 -- Name: keys id; Type: DEFAULT; Schema: public; Owner: -
1165 --
1166
1167 ALTER TABLE ONLY public.keys ALTER COLUMN id SET DEFAULT nextval('public.keys_id_seq'::regclass);
1168
1169
1170 --
1171 -- Name: logfiles id; Type: DEFAULT; Schema: public; Owner: -
1172 --
1173
1174 ALTER TABLE ONLY public.logfiles ALTER COLUMN id SET DEFAULT nextval('public.logfiles_id_seq'::regclass);
1175
1176
1177 --
1178 -- Name: messages id; Type: DEFAULT; Schema: public; Owner: -
1179 --
1180
1181 ALTER TABLE ONLY public.messages ALTER COLUMN id SET DEFAULT nextval('public.messages_id_seq'::regclass);
1182
1183
1184 --
1185 -- Name: mirrors id; Type: DEFAULT; Schema: public; Owner: -
1186 --
1187
1188 ALTER TABLE ONLY public.mirrors ALTER COLUMN id SET DEFAULT nextval('public.mirrors_id_seq'::regclass);
1189
1190
1191 --
1192 -- Name: mirrors_checks id; Type: DEFAULT; Schema: public; Owner: -
1193 --
1194
1195 ALTER TABLE ONLY public.mirrors_checks ALTER COLUMN id SET DEFAULT nextval('public.mirrors_checks_id_seq'::regclass);
1196
1197
1198 --
1199 -- Name: packages id; Type: DEFAULT; Schema: public; Owner: -
1200 --
1201
1202 ALTER TABLE ONLY public.packages ALTER COLUMN id SET DEFAULT nextval('public.packages_id_seq'::regclass);
1203
1204
1205 --
1206 -- Name: packages_properties id; Type: DEFAULT; Schema: public; Owner: -
1207 --
1208
1209 ALTER TABLE ONLY public.packages_properties ALTER COLUMN id SET DEFAULT nextval('public.packages_properties_id_seq'::regclass);
1210
1211
1212 --
1213 -- Name: repositories id; Type: DEFAULT; Schema: public; Owner: -
1214 --
1215
1216 ALTER TABLE ONLY public.repositories ALTER COLUMN id SET DEFAULT nextval('public.repositories_id_seq'::regclass);
1217
1218
1219 --
1220 -- Name: repositories_builds id; Type: DEFAULT; Schema: public; Owner: -
1221 --
1222
1223 ALTER TABLE ONLY public.repositories_builds ALTER COLUMN id SET DEFAULT nextval('public.repositories_builds_id_seq'::regclass);
1224
1225
1226 --
1227 -- Name: sessions id; Type: DEFAULT; Schema: public; Owner: -
1228 --
1229
1230 ALTER TABLE ONLY public.sessions ALTER COLUMN id SET DEFAULT nextval('public.sessions_id_seq'::regclass);
1231
1232
1233 --
1234 -- Name: sources id; Type: DEFAULT; Schema: public; Owner: -
1235 --
1236
1237 ALTER TABLE ONLY public.sources ALTER COLUMN id SET DEFAULT nextval('public.sources_id_seq'::regclass);
1238
1239
1240 --
1241 -- Name: sources_commits id; Type: DEFAULT; Schema: public; Owner: -
1242 --
1243
1244 ALTER TABLE ONLY public.sources_commits ALTER COLUMN id SET DEFAULT nextval('public.sources_commits_id_seq'::regclass);
1245
1246
1247 --
1248 -- Name: uploads id; Type: DEFAULT; Schema: public; Owner: -
1249 --
1250
1251 ALTER TABLE ONLY public.uploads ALTER COLUMN id SET DEFAULT nextval('public.uploads_id_seq'::regclass);
1252
1253
1254 --
1255 -- Name: users id; Type: DEFAULT; Schema: public; Owner: -
1256 --
1257
1258 ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
1259
1260
1261 --
1262 -- Name: users_emails id; Type: DEFAULT; Schema: public; Owner: -
1263 --
1264
1265 ALTER TABLE ONLY public.users_emails ALTER COLUMN id SET DEFAULT nextval('public.users_emails_id_seq'::regclass);
1266
1267
1268 --
1269 -- Name: builds builds_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1270 --
1271
1272 ALTER TABLE ONLY public.builds
1273 ADD CONSTRAINT builds_pkey PRIMARY KEY (id);
1274
1275
1276 --
1277 -- Name: distributions distributions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1278 --
1279
1280 ALTER TABLE ONLY public.distributions
1281 ADD CONSTRAINT distributions_pkey PRIMARY KEY (id);
1282
1283
1284 --
1285 -- Name: builders idx_2197954_primary; Type: CONSTRAINT; Schema: public; Owner: -
1286 --
1287
1288 ALTER TABLE ONLY public.builders
1289 ADD CONSTRAINT idx_2197954_primary PRIMARY KEY (id);
1290
1291
1292 --
1293 -- Name: builds_bugs_updates idx_2198008_primary; Type: CONSTRAINT; Schema: public; Owner: -
1294 --
1295
1296 ALTER TABLE ONLY public.builds_bugs_updates
1297 ADD CONSTRAINT idx_2198008_primary PRIMARY KEY (id);
1298
1299
1300 --
1301 -- Name: builds_comments idx_2198018_primary; Type: CONSTRAINT; Schema: public; Owner: -
1302 --
1303
1304 ALTER TABLE ONLY public.builds_comments
1305 ADD CONSTRAINT idx_2198018_primary PRIMARY KEY (id);
1306
1307
1308 --
1309 -- Name: images_types idx_2198057_primary; Type: CONSTRAINT; Schema: public; Owner: -
1310 --
1311
1312 ALTER TABLE ONLY public.images_types
1313 ADD CONSTRAINT idx_2198057_primary PRIMARY KEY (id);
1314
1315
1316 --
1317 -- Name: jobs_packages idx_2198085_primary; Type: CONSTRAINT; Schema: public; Owner: -
1318 --
1319
1320 ALTER TABLE ONLY public.jobs_packages
1321 ADD CONSTRAINT idx_2198085_primary PRIMARY KEY (id);
1322
1323
1324 --
1325 -- Name: logfiles idx_2198109_primary; Type: CONSTRAINT; Schema: public; Owner: -
1326 --
1327
1328 ALTER TABLE ONLY public.logfiles
1329 ADD CONSTRAINT idx_2198109_primary PRIMARY KEY (id);
1330
1331
1332 --
1333 -- Name: mirrors idx_2198115_primary; Type: CONSTRAINT; Schema: public; Owner: -
1334 --
1335
1336 ALTER TABLE ONLY public.mirrors
1337 ADD CONSTRAINT idx_2198115_primary PRIMARY KEY (id);
1338
1339
1340 --
1341 -- Name: packages_properties idx_2198147_primary; Type: CONSTRAINT; Schema: public; Owner: -
1342 --
1343
1344 ALTER TABLE ONLY public.packages_properties
1345 ADD CONSTRAINT idx_2198147_primary PRIMARY KEY (id);
1346
1347
1348 --
1349 -- Name: repositories_builds idx_2198189_primary; Type: CONSTRAINT; Schema: public; Owner: -
1350 --
1351
1352 ALTER TABLE ONLY public.repositories_builds
1353 ADD CONSTRAINT idx_2198189_primary PRIMARY KEY (id);
1354
1355
1356 --
1357 -- Name: sources idx_2198213_primary; Type: CONSTRAINT; Schema: public; Owner: -
1358 --
1359
1360 ALTER TABLE ONLY public.sources
1361 ADD CONSTRAINT idx_2198213_primary PRIMARY KEY (id);
1362
1363
1364 --
1365 -- Name: sources_commits idx_2198222_primary; Type: CONSTRAINT; Schema: public; Owner: -
1366 --
1367
1368 ALTER TABLE ONLY public.sources_commits
1369 ADD CONSTRAINT idx_2198222_primary PRIMARY KEY (id);
1370
1371
1372 --
1373 -- Name: users idx_2198244_primary; Type: CONSTRAINT; Schema: public; Owner: -
1374 --
1375
1376 ALTER TABLE ONLY public.users
1377 ADD CONSTRAINT idx_2198244_primary PRIMARY KEY (id);
1378
1379
1380 --
1381 -- Name: users_emails idx_2198256_primary; Type: CONSTRAINT; Schema: public; Owner: -
1382 --
1383
1384 ALTER TABLE ONLY public.users_emails
1385 ADD CONSTRAINT idx_2198256_primary PRIMARY KEY (id);
1386
1387
1388 --
1389 -- Name: messages idx_2198274_primary; Type: CONSTRAINT; Schema: public; Owner: -
1390 --
1391
1392 ALTER TABLE ONLY public.messages
1393 ADD CONSTRAINT idx_2198274_primary PRIMARY KEY (id);
1394
1395
1396 --
1397 -- Name: jobs_packages jobs_packages_unique; Type: CONSTRAINT; Schema: public; Owner: -
1398 --
1399
1400 ALTER TABLE ONLY public.jobs_packages
1401 ADD CONSTRAINT jobs_packages_unique UNIQUE (job_id, pkg_id);
1402
1403
1404 --
1405 -- Name: jobs jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1406 --
1407
1408 ALTER TABLE ONLY public.jobs
1409 ADD CONSTRAINT jobs_pkey PRIMARY KEY (id);
1410
1411
1412 --
1413 -- Name: keys keys_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1414 --
1415
1416 ALTER TABLE ONLY public.keys
1417 ADD CONSTRAINT keys_pkey PRIMARY KEY (id);
1418
1419
1420 --
1421 -- Name: mirrors_checks mirrors_checks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1422 --
1423
1424 ALTER TABLE ONLY public.mirrors_checks
1425 ADD CONSTRAINT mirrors_checks_pkey PRIMARY KEY (id);
1426
1427
1428 --
1429 -- Name: packages packages_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1430 --
1431
1432 ALTER TABLE ONLY public.packages
1433 ADD CONSTRAINT packages_pkey PRIMARY KEY (id);
1434
1435
1436 --
1437 -- Name: repositories_builds repositories_builds_unique; Type: CONSTRAINT; Schema: public; Owner: -
1438 --
1439
1440 ALTER TABLE ONLY public.repositories_builds
1441 ADD CONSTRAINT repositories_builds_unique UNIQUE (repo_id, build_id);
1442
1443
1444 --
1445 -- Name: repositories repositories_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1446 --
1447
1448 ALTER TABLE ONLY public.repositories
1449 ADD CONSTRAINT repositories_pkey PRIMARY KEY (id);
1450
1451
1452 --
1453 -- Name: sessions sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1454 --
1455
1456 ALTER TABLE ONLY public.sessions
1457 ADD CONSTRAINT sessions_pkey PRIMARY KEY (id);
1458
1459
1460 --
1461 -- Name: sessions sessions_session_id_key; Type: CONSTRAINT; Schema: public; Owner: -
1462 --
1463
1464 ALTER TABLE ONLY public.sessions
1465 ADD CONSTRAINT sessions_session_id_key UNIQUE (session_id);
1466
1467
1468 --
1469 -- Name: uploads uploads_id; Type: CONSTRAINT; Schema: public; Owner: -
1470 --
1471
1472 ALTER TABLE ONLY public.uploads
1473 ADD CONSTRAINT uploads_id PRIMARY KEY (id);
1474
1475
1476 --
1477 -- Name: build_packages_build_id; Type: INDEX; Schema: public; Owner: -
1478 --
1479
1480 CREATE INDEX build_packages_build_id ON public.build_packages USING btree (build_id);
1481
1482
1483 --
1484 -- Name: build_watchers_unique; Type: INDEX; Schema: public; Owner: -
1485 --
1486
1487 CREATE UNIQUE INDEX build_watchers_unique ON public.build_watchers USING btree (build_id, user_id) WHERE (deleted_at IS NULL);
1488
1489
1490 --
1491 -- Name: builders_name; Type: INDEX; Schema: public; Owner: -
1492 --
1493
1494 CREATE UNIQUE INDEX builders_name ON public.builders USING btree (name) WHERE (deleted IS FALSE);
1495
1496
1497 --
1498 -- Name: builds_created_at; Type: INDEX; Schema: public; Owner: -
1499 --
1500
1501 CREATE INDEX builds_created_at ON public.builds USING btree (created_at DESC);
1502
1503
1504 --
1505 -- Name: builds_pkg_id; Type: INDEX; Schema: public; Owner: -
1506 --
1507
1508 CREATE INDEX builds_pkg_id ON public.builds USING btree (pkg_id) WHERE (deleted IS FALSE);
1509
1510
1511 --
1512 -- Name: builds_uuid; Type: INDEX; Schema: public; Owner: -
1513 --
1514
1515 CREATE UNIQUE INDEX builds_uuid ON public.builds USING btree (uuid) WHERE (deleted IS FALSE);
1516
1517
1518 --
1519 -- Name: distributions_slug; Type: INDEX; Schema: public; Owner: -
1520 --
1521
1522 CREATE UNIQUE INDEX distributions_slug ON public.distributions USING btree (slug) WHERE (deleted IS FALSE);
1523
1524
1525 --
1526 -- Name: filelists_path; Type: INDEX; Schema: public; Owner: -
1527 --
1528
1529 CREATE INDEX filelists_path ON public.filelists USING btree (path);
1530
1531
1532 --
1533 -- Name: filelists_pkg_id; Type: INDEX; Schema: public; Owner: -
1534 --
1535
1536 CREATE INDEX filelists_pkg_id ON public.filelists USING btree (pkg_id);
1537
1538 ALTER TABLE public.filelists CLUSTER ON filelists_pkg_id;
1539
1540
1541 --
1542 -- Name: idx_2198018_build_id; Type: INDEX; Schema: public; Owner: -
1543 --
1544
1545 CREATE INDEX idx_2198018_build_id ON public.builds_comments USING btree (build_id);
1546
1547
1548 --
1549 -- Name: idx_2198018_user_id; Type: INDEX; Schema: public; Owner: -
1550 --
1551
1552 CREATE INDEX idx_2198018_user_id ON public.builds_comments USING btree (user_id);
1553
1554
1555 --
1556 -- Name: idx_2198147_name; Type: INDEX; Schema: public; Owner: -
1557 --
1558
1559 CREATE UNIQUE INDEX idx_2198147_name ON public.packages_properties USING btree (name);
1560
1561
1562 --
1563 -- Name: idx_2198189_build_id; Type: INDEX; Schema: public; Owner: -
1564 --
1565
1566 CREATE UNIQUE INDEX idx_2198189_build_id ON public.repositories_builds USING btree (build_id);
1567
1568
1569 --
1570 -- Name: idx_2198199_k; Type: INDEX; Schema: public; Owner: -
1571 --
1572
1573 CREATE UNIQUE INDEX idx_2198199_k ON public.settings USING btree (k);
1574
1575
1576 --
1577 -- Name: idx_2198213_identifier; Type: INDEX; Schema: public; Owner: -
1578 --
1579
1580 CREATE UNIQUE INDEX idx_2198213_identifier ON public.sources USING btree (identifier);
1581
1582
1583 --
1584 -- Name: idx_2198222_revision; Type: INDEX; Schema: public; Owner: -
1585 --
1586
1587 CREATE INDEX idx_2198222_revision ON public.sources_commits USING btree (revision);
1588
1589
1590 --
1591 -- Name: idx_2198244_name; Type: INDEX; Schema: public; Owner: -
1592 --
1593
1594 CREATE UNIQUE INDEX idx_2198244_name ON public.users USING btree (name);
1595
1596
1597 --
1598 -- Name: idx_2198256_email; Type: INDEX; Schema: public; Owner: -
1599 --
1600
1601 CREATE UNIQUE INDEX idx_2198256_email ON public.users_emails USING btree (email);
1602
1603
1604 --
1605 -- Name: idx_2198256_user_id; Type: INDEX; Schema: public; Owner: -
1606 --
1607
1608 CREATE INDEX idx_2198256_user_id ON public.users_emails USING btree (user_id);
1609
1610
1611 --
1612 -- Name: jobs_arch; Type: INDEX; Schema: public; Owner: -
1613 --
1614
1615 CREATE INDEX jobs_arch ON public.jobs USING btree (arch);
1616
1617
1618 --
1619 -- Name: jobs_build_id; Type: INDEX; Schema: public; Owner: -
1620 --
1621
1622 CREATE INDEX jobs_build_id ON public.jobs USING btree (build_id) WHERE (deleted IS FALSE);
1623
1624
1625 --
1626 -- Name: jobs_buildroots_job_id; Type: INDEX; Schema: public; Owner: -
1627 --
1628
1629 CREATE INDEX jobs_buildroots_job_id ON public.jobs_buildroots USING btree (job_id);
1630
1631 ALTER TABLE public.jobs_buildroots CLUSTER ON jobs_buildroots_job_id;
1632
1633
1634 --
1635 -- Name: jobs_buildroots_pkg_uuid; Type: INDEX; Schema: public; Owner: -
1636 --
1637
1638 CREATE INDEX jobs_buildroots_pkg_uuid ON public.jobs_buildroots USING btree (pkg_uuid);
1639
1640
1641 --
1642 -- Name: jobs_finished_at; Type: INDEX; Schema: public; Owner: -
1643 --
1644
1645 CREATE INDEX jobs_finished_at ON public.jobs USING btree (finished_at DESC) WHERE (finished_at IS NOT NULL);
1646
1647
1648 --
1649 -- Name: jobs_pending; Type: INDEX; Schema: public; Owner: -
1650 --
1651
1652 CREATE INDEX jobs_pending ON public.jobs USING btree (id) WHERE ((deleted IS FALSE) AND (started_at IS NULL) AND (finished_at IS NULL) AND (depcheck_succeeded IS TRUE));
1653
1654
1655 --
1656 -- Name: jobs_running; Type: INDEX; Schema: public; Owner: -
1657 --
1658
1659 CREATE INDEX jobs_running ON public.jobs USING btree (started_at) WHERE ((started_at IS NOT NULL) AND (finished_at IS NULL));
1660
1661
1662 --
1663 -- Name: jobs_uuid; Type: INDEX; Schema: public; Owner: -
1664 --
1665
1666 CREATE UNIQUE INDEX jobs_uuid ON public.jobs USING btree (uuid) WHERE (deleted IS FALSE);
1667
1668
1669 --
1670 -- Name: keys_fingerprint; Type: INDEX; Schema: public; Owner: -
1671 --
1672
1673 CREATE UNIQUE INDEX keys_fingerprint ON public.keys USING btree (fingerprint) WHERE (deleted IS FALSE);
1674
1675
1676 --
1677 -- Name: messages_order; Type: INDEX; Schema: public; Owner: -
1678 --
1679
1680 CREATE INDEX messages_order ON public.messages USING btree (queued_at) WHERE (sent_at IS NULL);
1681
1682
1683 --
1684 -- Name: mirrors_checks_sort; Type: INDEX; Schema: public; Owner: -
1685 --
1686
1687 CREATE INDEX mirrors_checks_sort ON public.mirrors_checks USING btree (mirror_id, "timestamp");
1688
1689 ALTER TABLE public.mirrors_checks CLUSTER ON mirrors_checks_sort;
1690
1691
1692 --
1693 -- Name: package_search_index_unique; Type: INDEX; Schema: public; Owner: -
1694 --
1695
1696 CREATE UNIQUE INDEX package_search_index_unique ON public.package_search_index USING btree (package_id);
1697
1698
1699 --
1700 -- Name: packages_name; Type: INDEX; Schema: public; Owner: -
1701 --
1702
1703 CREATE INDEX packages_name ON public.packages USING btree (name);
1704
1705
1706 --
1707 -- Name: packages_src_created_at; Type: INDEX; Schema: public; Owner: -
1708 --
1709
1710 CREATE INDEX packages_src_created_at ON public.packages USING btree (created_at DESC) WHERE ((deleted IS FALSE) AND (arch = 'src'::text));
1711
1712
1713 --
1714 -- Name: packages_uuid; Type: INDEX; Schema: public; Owner: -
1715 --
1716
1717 CREATE UNIQUE INDEX packages_uuid ON public.packages USING btree (uuid) WHERE (deleted IS FALSE);
1718
1719
1720 --
1721 -- Name: repo_builds_build_id; Type: INDEX; Schema: public; Owner: -
1722 --
1723
1724 CREATE INDEX repo_builds_build_id ON public.repo_builds USING btree (build_id);
1725
1726
1727 --
1728 -- Name: repo_builds_repo_id; Type: INDEX; Schema: public; Owner: -
1729 --
1730
1731 CREATE INDEX repo_builds_repo_id ON public.repo_builds USING btree (repo_id);
1732
1733
1734 --
1735 -- Name: repo_builds_unique; Type: INDEX; Schema: public; Owner: -
1736 --
1737
1738 CREATE UNIQUE INDEX repo_builds_unique ON public.repo_builds USING btree (repo_id, build_id) WHERE ((added_at IS NOT NULL) AND (removed_at IS NULL));
1739
1740
1741 --
1742 -- Name: repositories_builds_repo_id; Type: INDEX; Schema: public; Owner: -
1743 --
1744
1745 CREATE INDEX repositories_builds_repo_id ON public.repositories_builds USING btree (repo_id);
1746
1747
1748 --
1749 -- Name: repositories_unique; Type: INDEX; Schema: public; Owner: -
1750 --
1751
1752 CREATE UNIQUE INDEX repositories_unique ON public.repositories USING btree (owner_id, distro_id, slug) WHERE (deleted IS FALSE);
1753
1754
1755 --
1756 -- Name: uploads_uuid; Type: INDEX; Schema: public; Owner: -
1757 --
1758
1759 CREATE UNIQUE INDEX uploads_uuid ON public.uploads USING btree (uuid);
1760
1761
1762 --
1763 -- Name: sources on_update_current_timestamp; Type: TRIGGER; Schema: public; Owner: -
1764 --
1765
1766 CREATE TRIGGER on_update_current_timestamp BEFORE UPDATE ON public.sources FOR EACH ROW EXECUTE FUNCTION public.on_update_current_timestamp_sources();
1767
1768
1769 --
1770 -- Name: build_packages build_packages_build_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1771 --
1772
1773 ALTER TABLE ONLY public.build_packages
1774 ADD CONSTRAINT build_packages_build_id FOREIGN KEY (build_id) REFERENCES public.builds(id);
1775
1776
1777 --
1778 -- Name: build_packages build_packages_job_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1779 --
1780
1781 ALTER TABLE ONLY public.build_packages
1782 ADD CONSTRAINT build_packages_job_id FOREIGN KEY (job_id) REFERENCES public.jobs(id);
1783
1784
1785 --
1786 -- Name: build_packages build_packages_package_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1787 --
1788
1789 ALTER TABLE ONLY public.build_packages
1790 ADD CONSTRAINT build_packages_package_id FOREIGN KEY (package_id) REFERENCES public.packages(id);
1791
1792
1793 --
1794 -- Name: build_watchers build_watchers_build_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1795 --
1796
1797 ALTER TABLE ONLY public.build_watchers
1798 ADD CONSTRAINT build_watchers_build_id FOREIGN KEY (build_id) REFERENCES public.builds(id);
1799
1800
1801 --
1802 -- Name: build_watchers build_watchers_user_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1803 --
1804
1805 ALTER TABLE ONLY public.build_watchers
1806 ADD CONSTRAINT build_watchers_user_id FOREIGN KEY (user_id) REFERENCES public.users(id);
1807
1808
1809 --
1810 -- Name: builder_stats builder_stats_builder_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1811 --
1812
1813 ALTER TABLE ONLY public.builder_stats
1814 ADD CONSTRAINT builder_stats_builder_id FOREIGN KEY (builder_id) REFERENCES public.builders(id);
1815
1816
1817 --
1818 -- Name: builds builds_build_repo_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1819 --
1820
1821 ALTER TABLE ONLY public.builds
1822 ADD CONSTRAINT builds_build_repo_id FOREIGN KEY (build_repo_id) REFERENCES public.repositories(id);
1823
1824
1825 --
1826 -- Name: builds_comments builds_comments_build_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1827 --
1828
1829 ALTER TABLE ONLY public.builds_comments
1830 ADD CONSTRAINT builds_comments_build_id FOREIGN KEY (build_id) REFERENCES public.builds(id);
1831
1832
1833 --
1834 -- Name: builds_comments builds_comments_user_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1835 --
1836
1837 ALTER TABLE ONLY public.builds_comments
1838 ADD CONSTRAINT builds_comments_user_id FOREIGN KEY (user_id) REFERENCES public.users(id);
1839
1840
1841 --
1842 -- Name: builds builds_owner_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1843 --
1844
1845 ALTER TABLE ONLY public.builds
1846 ADD CONSTRAINT builds_owner_id FOREIGN KEY (owner_id) REFERENCES public.users(id);
1847
1848
1849 --
1850 -- Name: builds builds_pkg_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1851 --
1852
1853 ALTER TABLE ONLY public.builds
1854 ADD CONSTRAINT builds_pkg_id FOREIGN KEY (pkg_id) REFERENCES public.packages(id);
1855
1856
1857 --
1858 -- Name: filelists filelists_pkg_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1859 --
1860
1861 ALTER TABLE ONLY public.filelists
1862 ADD CONSTRAINT filelists_pkg_id FOREIGN KEY (pkg_id) REFERENCES public.packages(id);
1863
1864
1865 --
1866 -- Name: jobs jobs_build_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1867 --
1868
1869 ALTER TABLE ONLY public.jobs
1870 ADD CONSTRAINT jobs_build_id FOREIGN KEY (build_id) REFERENCES public.builds(id);
1871
1872
1873 --
1874 -- Name: jobs jobs_builder_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1875 --
1876
1877 ALTER TABLE ONLY public.jobs
1878 ADD CONSTRAINT jobs_builder_id FOREIGN KEY (builder_id) REFERENCES public.builders(id);
1879
1880
1881 --
1882 -- Name: jobs_buildroots jobs_buildroots_job_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1883 --
1884
1885 ALTER TABLE ONLY public.jobs_buildroots
1886 ADD CONSTRAINT jobs_buildroots_job_id FOREIGN KEY (job_id) REFERENCES public.jobs(id);
1887
1888
1889 --
1890 -- Name: jobs_packages jobs_packaged_job_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1891 --
1892
1893 ALTER TABLE ONLY public.jobs_packages
1894 ADD CONSTRAINT jobs_packaged_job_id FOREIGN KEY (job_id) REFERENCES public.jobs(id);
1895
1896
1897 --
1898 -- Name: jobs_packages jobs_packages_pkg_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1899 --
1900
1901 ALTER TABLE ONLY public.jobs_packages
1902 ADD CONSTRAINT jobs_packages_pkg_id FOREIGN KEY (pkg_id) REFERENCES public.packages(id);
1903
1904
1905 --
1906 -- Name: jobs jobs_superseeded_by; Type: FK CONSTRAINT; Schema: public; Owner: -
1907 --
1908
1909 ALTER TABLE ONLY public.jobs
1910 ADD CONSTRAINT jobs_superseeded_by FOREIGN KEY (superseeded_by) REFERENCES public.jobs(id);
1911
1912
1913 --
1914 -- Name: keys keys_parent_key_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1915 --
1916
1917 ALTER TABLE ONLY public.keys
1918 ADD CONSTRAINT keys_parent_key_id FOREIGN KEY (parent_key_id) REFERENCES public.keys(id);
1919
1920
1921 --
1922 -- Name: logfiles logfiles_job_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1923 --
1924
1925 ALTER TABLE ONLY public.logfiles
1926 ADD CONSTRAINT logfiles_job_id FOREIGN KEY (job_id) REFERENCES public.jobs(id);
1927
1928
1929 --
1930 -- Name: mirrors_checks mirrors_checks_mirror_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1931 --
1932
1933 ALTER TABLE ONLY public.mirrors_checks
1934 ADD CONSTRAINT mirrors_checks_mirror_id FOREIGN KEY (mirror_id) REFERENCES public.mirrors(id);
1935
1936
1937 --
1938 -- Name: packages packages_commit_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1939 --
1940
1941 ALTER TABLE ONLY public.packages
1942 ADD CONSTRAINT packages_commit_id FOREIGN KEY (commit_id) REFERENCES public.sources_commits(id);
1943
1944
1945 --
1946 -- Name: repo_builds repo_builds_added_by; Type: FK CONSTRAINT; Schema: public; Owner: -
1947 --
1948
1949 ALTER TABLE ONLY public.repo_builds
1950 ADD CONSTRAINT repo_builds_added_by FOREIGN KEY (added_by) REFERENCES public.users(id);
1951
1952
1953 --
1954 -- Name: repo_builds repo_builds_build_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1955 --
1956
1957 ALTER TABLE ONLY public.repo_builds
1958 ADD CONSTRAINT repo_builds_build_id FOREIGN KEY (build_id) REFERENCES public.builds(id);
1959
1960
1961 --
1962 -- Name: repo_builds repo_builds_removed_by; Type: FK CONSTRAINT; Schema: public; Owner: -
1963 --
1964
1965 ALTER TABLE ONLY public.repo_builds
1966 ADD CONSTRAINT repo_builds_removed_by FOREIGN KEY (removed_by) REFERENCES public.users(id);
1967
1968
1969 --
1970 -- Name: repo_builds repo_builds_repo_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1971 --
1972
1973 ALTER TABLE ONLY public.repo_builds
1974 ADD CONSTRAINT repo_builds_repo_id FOREIGN KEY (repo_id) REFERENCES public.repositories(id);
1975
1976
1977 --
1978 -- Name: repositories_builds repositories_builds_build_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1979 --
1980
1981 ALTER TABLE ONLY public.repositories_builds
1982 ADD CONSTRAINT repositories_builds_build_id FOREIGN KEY (build_id) REFERENCES public.builds(id);
1983
1984
1985 --
1986 -- Name: repositories_builds repositories_builds_repo_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1987 --
1988
1989 ALTER TABLE ONLY public.repositories_builds
1990 ADD CONSTRAINT repositories_builds_repo_id FOREIGN KEY (repo_id) REFERENCES public.repositories(id);
1991
1992
1993 --
1994 -- Name: repositories repositories_distro_id; Type: FK CONSTRAINT; Schema: public; Owner: -
1995 --
1996
1997 ALTER TABLE ONLY public.repositories
1998 ADD CONSTRAINT repositories_distro_id FOREIGN KEY (distro_id) REFERENCES public.distributions(id);
1999
2000
2001 --
2002 -- Name: repositories repositories_key_id; Type: FK CONSTRAINT; Schema: public; Owner: -
2003 --
2004
2005 ALTER TABLE ONLY public.repositories
2006 ADD CONSTRAINT repositories_key_id FOREIGN KEY (key_id) REFERENCES public.keys(id);
2007
2008
2009 --
2010 -- Name: repositories repositories_owner_id; Type: FK CONSTRAINT; Schema: public; Owner: -
2011 --
2012
2013 ALTER TABLE ONLY public.repositories
2014 ADD CONSTRAINT repositories_owner_id FOREIGN KEY (owner_id) REFERENCES public.users(id);
2015
2016
2017 --
2018 -- Name: repositories repositories_parent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
2019 --
2020
2021 ALTER TABLE ONLY public.repositories
2022 ADD CONSTRAINT repositories_parent_id FOREIGN KEY (parent_id) REFERENCES public.repositories(id);
2023
2024
2025 --
2026 -- Name: sessions sessions_user_id; Type: FK CONSTRAINT; Schema: public; Owner: -
2027 --
2028
2029 ALTER TABLE ONLY public.sessions
2030 ADD CONSTRAINT sessions_user_id FOREIGN KEY (user_id) REFERENCES public.users(id);
2031
2032
2033 --
2034 -- Name: sources_commits sources_commits_source_id; Type: FK CONSTRAINT; Schema: public; Owner: -
2035 --
2036
2037 ALTER TABLE ONLY public.sources_commits
2038 ADD CONSTRAINT sources_commits_source_id FOREIGN KEY (source_id) REFERENCES public.sources(id);
2039
2040
2041 --
2042 -- Name: sources sources_distro_id; Type: FK CONSTRAINT; Schema: public; Owner: -
2043 --
2044
2045 ALTER TABLE ONLY public.sources
2046 ADD CONSTRAINT sources_distro_id FOREIGN KEY (distro_id) REFERENCES public.distributions(id);
2047
2048
2049 --
2050 -- Name: uploads uploads_builder_id; Type: FK CONSTRAINT; Schema: public; Owner: -
2051 --
2052
2053 ALTER TABLE ONLY public.uploads
2054 ADD CONSTRAINT uploads_builder_id FOREIGN KEY (builder_id) REFERENCES public.builders(id);
2055
2056
2057 --
2058 -- Name: uploads uploads_user_id; Type: FK CONSTRAINT; Schema: public; Owner: -
2059 --
2060
2061 ALTER TABLE ONLY public.uploads
2062 ADD CONSTRAINT uploads_user_id FOREIGN KEY (user_id) REFERENCES public.users(id);
2063
2064
2065 --
2066 -- Name: users_emails users_emails_user_id; Type: FK CONSTRAINT; Schema: public; Owner: -
2067 --
2068
2069 ALTER TABLE ONLY public.users_emails
2070 ADD CONSTRAINT users_emails_user_id FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
2071
2072
2073 --
2074 -- PostgreSQL database dump complete
2075 --
2076