]> git.donarmstrong.com Git - debbugs.git/blob - sql/PostgreSQL/deploy/6/001-auto.sql
add postgresql upgrade and deploy from DBICDH
[debbugs.git] / sql / PostgreSQL / deploy / 6 / 001-auto.sql
1 -- 
2 -- Created by SQL::Translator::Producer::PostgreSQL
3 -- Created on Fri Apr 14 20:22:11 2017
4 -- 
5 ;
6 --
7 -- Table: arch
8 --
9 CREATE TABLE "arch" (
10   "id" serial NOT NULL,
11   "arch" text NOT NULL,
12   PRIMARY KEY ("id"),
13   CONSTRAINT "arch_arch_key" UNIQUE ("arch")
14 );
15
16 ;
17 --
18 -- Table: bin_pkg
19 --
20 CREATE TABLE "bin_pkg" (
21   "id" serial NOT NULL,
22   "pkg" text NOT NULL,
23   PRIMARY KEY ("id"),
24   CONSTRAINT "bin_pkg_pkg_key" UNIQUE ("pkg")
25 );
26
27 ;
28 --
29 -- Table: column_comments
30 --
31 CREATE TABLE "column_comments" (
32   "table_name" text NOT NULL,
33   "column_name" text NOT NULL,
34   "comment_text" text NOT NULL,
35   CONSTRAINT "column_comments_table_name_column_name_idx" UNIQUE ("table_name", "column_name")
36 );
37
38 ;
39 --
40 -- Table: correspondent
41 --
42 CREATE TABLE "correspondent" (
43   "id" serial NOT NULL,
44   "addr" text NOT NULL,
45   PRIMARY KEY ("id"),
46   CONSTRAINT "correspondent_addr_idx" UNIQUE ("addr")
47 );
48
49 ;
50 --
51 -- Table: message
52 --
53 CREATE TABLE "message" (
54   "id" serial NOT NULL,
55   "msgid" text DEFAULT '' NOT NULL,
56   "from_complete" text DEFAULT '' NOT NULL,
57   "to_complete" text DEFAULT '' NOT NULL,
58   "subject" text DEFAULT '' NOT NULL,
59   "sent_date" timestamp with time zone,
60   "refs" text DEFAULT '' NOT NULL,
61   "spam_score" double precision DEFAULT '0' NOT NULL,
62   "is_spam" boolean DEFAULT false NOT NULL,
63   PRIMARY KEY ("id"),
64   CONSTRAINT "message_msgid_from_complete_to_complete_subject_idx" UNIQUE ("msgid", "from_complete", "to_complete", "subject")
65 );
66 CREATE INDEX "message_msgid_idx" on "message" ("msgid");
67 CREATE INDEX "message_subject_idx" on "message" ("subject");
68
69 ;
70 --
71 -- Table: severity
72 --
73 CREATE TABLE "severity" (
74   "id" serial NOT NULL,
75   "severity" text NOT NULL,
76   "ordering" integer DEFAULT 5 NOT NULL,
77   "strong" boolean DEFAULT false,
78   "obsolete" boolean DEFAULT false,
79   PRIMARY KEY ("id"),
80   CONSTRAINT "severity_severity_idx" UNIQUE ("severity")
81 );
82 CREATE INDEX "severity_ordering_idx" on "severity" ("ordering");
83
84 ;
85 --
86 -- Table: src_pkg
87 --
88 CREATE TABLE "src_pkg" (
89   "id" serial NOT NULL,
90   "pkg" text NOT NULL,
91   "pseduopkg" boolean DEFAULT false NOT NULL,
92   "alias_of" integer,
93   "creation" timestamp with time zone DEFAULT current_timestamp NOT NULL,
94   "disabled" timestamp with time zone DEFAULT 'infinity' NOT NULL,
95   "last_modified" timestamp with time zone DEFAULT current_timestamp NOT NULL,
96   "obsolete" boolean DEFAULT false NOT NULL,
97   PRIMARY KEY ("id"),
98   CONSTRAINT "src_pkg_pkg_disabled" UNIQUE ("pkg", "disabled")
99 );
100 CREATE INDEX "src_pkg_idx_alias_of" on "src_pkg" ("alias_of");
101 CREATE INDEX "src_pkg_pkg" on "src_pkg" ("pkg");
102
103 ;
104 --
105 -- Table: suite
106 --
107 CREATE TABLE "suite" (
108   "id" serial NOT NULL,
109   "codename" text NOT NULL,
110   "suite_name" text,
111   "version" text,
112   "active" boolean DEFAULT true,
113   PRIMARY KEY ("id"),
114   CONSTRAINT "suite_idx_codename" UNIQUE ("codename"),
115   CONSTRAINT "suite_idx_version" UNIQUE ("version"),
116   CONSTRAINT "suite_suite_name_key" UNIQUE ("suite_name")
117 );
118
119 ;
120 --
121 -- Table: table_comments
122 --
123 CREATE TABLE "table_comments" (
124   "table_name" text NOT NULL,
125   "comment_text" text NOT NULL,
126   CONSTRAINT "table_comments_table_name_idx" UNIQUE ("table_name"),
127   CONSTRAINT "table_comments_table_name_key" UNIQUE ("table_name")
128 );
129
130 ;
131 --
132 -- Table: tag
133 --
134 CREATE TABLE "tag" (
135   "id" serial NOT NULL,
136   "tag" text NOT NULL,
137   "obsolete" boolean DEFAULT false,
138   PRIMARY KEY ("id"),
139   CONSTRAINT "tag_tag_key" UNIQUE ("tag")
140 );
141
142 ;
143 --
144 -- Table: correspondent_full_name
145 --
146 CREATE TABLE "correspondent_full_name" (
147   "correspondent" integer NOT NULL,
148   "full_name" text NOT NULL,
149   "last_seen" timestamp DEFAULT current_timestamp NOT NULL,
150   CONSTRAINT "correspondent_full_name_correspondent_full_name_idx" UNIQUE ("correspondent", "full_name")
151 );
152 CREATE INDEX "correspondent_full_name_idx_correspondent" on "correspondent_full_name" ("correspondent");
153 CREATE INDEX "message_correspondent_idxcorrespondent" on "correspondent_full_name" ("correspondent");
154 CREATE INDEX "message_correspondent_idxmessage" on "correspondent_full_name" ("message");
155
156 ;
157 --
158 -- Table: maintainer
159 --
160 CREATE TABLE "maintainer" (
161   "id" serial NOT NULL,
162   "name" text NOT NULL,
163   "correspondent" integer NOT NULL,
164   "created" timestamp with time zone DEFAULT current_timestamp NOT NULL,
165   "modified" timestamp with time zone DEFAULT current_timestamp NOT NULL,
166   PRIMARY KEY ("id"),
167   CONSTRAINT "maintainer_name_idx" UNIQUE ("name")
168 );
169 CREATE INDEX "maintainer_idx_correspondent" on "maintainer" ("correspondent");
170
171 ;
172 --
173 -- Table: message_refs
174 --
175 CREATE TABLE "message_refs" (
176   "message" integer NOT NULL,
177   "refs" integer NOT NULL,
178   "inferred" boolean DEFAULT false,
179   "primary_ref" boolean DEFAULT false,
180   CONSTRAINT "message_refs_message_refs_idx" UNIQUE ("message", "refs")
181 );
182 CREATE INDEX "message_refs_idx_message" on "message_refs" ("message");
183 CREATE INDEX "message_refs_idx_refs" on "message_refs" ("refs");
184
185 ;
186 --
187 -- Table: user_tag
188 --
189 CREATE TABLE "user_tag" (
190   "id" serial NOT NULL,
191   "tag" text NOT NULL,
192   "correspondent" integer NOT NULL,
193   PRIMARY KEY ("id"),
194   CONSTRAINT "user_tag_tag_correspondent" UNIQUE ("tag", "correspondent")
195 );
196 CREATE INDEX "user_tag_idx_correspondent" on "user_tag" ("correspondent");
197 CREATE INDEX "user_tag_correspondent" on "user_tag" ("correspondent");
198
199 ;
200 --
201 -- Table: bug
202 --
203 CREATE TABLE "bug" (
204   "id" integer NOT NULL,
205   "creation" timestamp with time zone DEFAULT current_timestamp NOT NULL,
206   "log_modified" timestamp with time zone DEFAULT current_timestamp NOT NULL,
207   "last_modified" timestamp with time zone DEFAULT current_timestamp NOT NULL,
208   "archived" boolean DEFAULT false NOT NULL,
209   "unarchived" timestamp with time zone,
210   "forwarded" text DEFAULT '' NOT NULL,
211   "summary" text DEFAULT '' NOT NULL,
212   "outlook" text DEFAULT '' NOT NULL,
213   "subject" text NOT NULL,
214   "severity" integer NOT NULL,
215   "done" integer,
216   "done_full" text DEFAULT '' NOT NULL,
217   "owner" integer,
218   "owner_full" text DEFAULT '' NOT NULL,
219   "submitter" integer,
220   "submitter_full" text DEFAULT '' NOT NULL,
221   "unknown_packages" text DEFAULT '' NOT NULL,
222   PRIMARY KEY ("id")
223 );
224 CREATE INDEX "bug_idx_done" on "bug" ("done");
225 CREATE INDEX "bug_idx_owner" on "bug" ("owner");
226 CREATE INDEX "bug_idx_severity" on "bug" ("severity");
227 CREATE INDEX "bug_idx_submitter" on "bug" ("submitter");
228 CREATE INDEX "bug_idxowner" on "bug" ("owner");
229 CREATE INDEX "bug_idxsubmitter" on "bug" ("submitter");
230 CREATE INDEX "bug_idxdone" on "bug" ("done");
231 CREATE INDEX "bug_idxforwarded" on "bug" ("forwarded");
232 CREATE INDEX "bug_idxlast_modified" on "bug" ("last_modified");
233 CREATE INDEX "bug_idxseverity" on "bug" ("severity");
234 CREATE INDEX "bug_idxcreation" on "bug" ("creation");
235 CREATE INDEX "bug_idxlog_modified" on "bug" ("log_modified");
236
237 ;
238 --
239 -- Table: message_correspondent
240 --
241 CREATE TABLE "message_correspondent" (
242   "message" integer NOT NULL,
243   "correspondent" integer NOT NULL,
244   "correspondent_type" character varying DEFAULT 'to' NOT NULL,
245   CONSTRAINT "message_correspondent_message_correspondent_correspondent_t_idx" UNIQUE ("message", "correspondent", "correspondent_type")
246 );
247 CREATE INDEX "message_correspondent_idx_correspondent" on "message_correspondent" ("correspondent");
248 CREATE INDEX "message_correspondent_idx_message" on "message_correspondent" ("message");
249
250 ;
251 --
252 -- Table: bug_blocks
253 --
254 CREATE TABLE "bug_blocks" (
255   "id" serial NOT NULL,
256   "bug" integer NOT NULL,
257   "blocks" integer NOT NULL,
258   PRIMARY KEY ("id"),
259   CONSTRAINT "bug_blocks_bug_id_blocks_idx" UNIQUE ("bug", "blocks")
260 );
261 CREATE INDEX "bug_blocks_idx_blocks" on "bug_blocks" ("blocks");
262 CREATE INDEX "bug_blocks_idx_bug" on "bug_blocks" ("bug");
263 CREATE INDEX "bug_blocks_bug_idx" on "bug_blocks" ("bug");
264 CREATE INDEX "bug_blocks_blocks_idx" on "bug_blocks" ("blocks");
265
266 ;
267 --
268 -- Table: bug_merged
269 --
270 CREATE TABLE "bug_merged" (
271   "id" serial NOT NULL,
272   "bug" integer NOT NULL,
273   "merged" integer NOT NULL,
274   PRIMARY KEY ("id"),
275   CONSTRAINT "bug_merged_bug_id_merged_idx" UNIQUE ("bug", "merged")
276 );
277 CREATE INDEX "bug_merged_idx_bug" on "bug_merged" ("bug");
278 CREATE INDEX "bug_merged_idx_merged" on "bug_merged" ("merged");
279 CREATE INDEX "bug_merged_bug_idx" on "bug_merged" ("bug");
280 CREATE INDEX "bug_merged_merged_idx" on "bug_merged" ("merged");
281
282 ;
283 --
284 -- Table: src_ver
285 --
286 CREATE TABLE "src_ver" (
287   "id" serial NOT NULL,
288   "src_pkg" integer NOT NULL,
289   "ver" debversion NOT NULL,
290   "maintainer" integer,
291   "upload_date" timestamp with time zone DEFAULT current_timestamp NOT NULL,
292   "based_on" integer,
293   PRIMARY KEY ("id"),
294   CONSTRAINT "src_ver_src_pkg_id_ver" UNIQUE ("src_pkg", "ver")
295 );
296 CREATE INDEX "src_ver_idx_based_on" on "src_ver" ("based_on");
297 CREATE INDEX "src_ver_idx_maintainer" on "src_ver" ("maintainer");
298 CREATE INDEX "src_ver_idx_src_pkg" on "src_ver" ("src_pkg");
299
300 ;
301 --
302 -- Table: bug_affects_binpackage
303 --
304 CREATE TABLE "bug_affects_binpackage" (
305   "bug" integer NOT NULL,
306   "bin_pkg" integer NOT NULL,
307   CONSTRAINT "bug_affects_binpackage_id_pkg" UNIQUE ("bug", "bin_pkg")
308 );
309 CREATE INDEX "bug_affects_binpackage_idx_bin_pkg" on "bug_affects_binpackage" ("bin_pkg");
310 CREATE INDEX "bug_affects_binpackage_idx_bug" on "bug_affects_binpackage" ("bug");
311
312 ;
313 --
314 -- Table: bug_affects_srcpackage
315 --
316 CREATE TABLE "bug_affects_srcpackage" (
317   "bug" integer NOT NULL,
318   "src_pkg" integer NOT NULL,
319   CONSTRAINT "bug_affects_srcpackage_id_pkg" UNIQUE ("bug", "src_pkg")
320 );
321 CREATE INDEX "bug_affects_srcpackage_idx_bug" on "bug_affects_srcpackage" ("bug");
322 CREATE INDEX "bug_affects_srcpackage_idx_src_pkg" on "bug_affects_srcpackage" ("src_pkg");
323
324 ;
325 --
326 -- Table: bug_binpackage
327 --
328 CREATE TABLE "bug_binpackage" (
329   "bug" integer NOT NULL,
330   "bin_pkg" integer NOT NULL,
331   CONSTRAINT "bug_binpackage_id_pkg" UNIQUE ("bug", "bin_pkg")
332 );
333 CREATE INDEX "bug_binpackage_idx_bin_pkg" on "bug_binpackage" ("bin_pkg");
334 CREATE INDEX "bug_binpackage_idx_bug" on "bug_binpackage" ("bug");
335 CREATE INDEX "bug_binpackage_bin_pkg_idx" on "bug_binpackage" ("bin_pkg");
336
337 ;
338 --
339 -- Table: bug_message
340 --
341 CREATE TABLE "bug_message" (
342   "bug" integer NOT NULL,
343   "message" integer NOT NULL,
344   "message_number" integer NOT NULL,
345   "bug_log_offset" integer,
346   "offset_valid" timestamp with time zone,
347   CONSTRAINT "bug_message_bug_message_idx" UNIQUE ("bug", "message")
348 );
349 CREATE INDEX "bug_message_idx_bug" on "bug_message" ("bug");
350 CREATE INDEX "bug_message_idx_message" on "bug_message" ("message");
351 CREATE INDEX "bug_message_idx_bug_message_number" on "bug_message" ("bug", "message_number");
352
353 ;
354 --
355 -- Table: bug_srcpackage
356 --
357 CREATE TABLE "bug_srcpackage" (
358   "bug" integer NOT NULL,
359   "src_pkg" integer NOT NULL,
360   CONSTRAINT "bug_srcpackage_id_pkg" UNIQUE ("bug", "src_pkg")
361 );
362 CREATE INDEX "bug_srcpackage_idx_bug" on "bug_srcpackage" ("bug");
363 CREATE INDEX "bug_srcpackage_idx_src_pkg" on "bug_srcpackage" ("src_pkg");
364 CREATE INDEX "bug_srcpackage_src_pkg_idx" on "bug_srcpackage" ("src_pkg");
365
366 ;
367 --
368 -- Table: bug_tag
369 --
370 CREATE TABLE "bug_tag" (
371   "bug" integer NOT NULL,
372   "tag" integer NOT NULL,
373   CONSTRAINT "bug_tag_bug_tag" UNIQUE ("bug", "tag")
374 );
375 CREATE INDEX "bug_tag_idx_bug" on "bug_tag" ("bug");
376 CREATE INDEX "bug_tag_idx_tag" on "bug_tag" ("tag");
377 CREATE INDEX "bug_tag_tag" on "bug_tag" ("tag");
378
379 ;
380 --
381 -- Table: bug_user_tag
382 --
383 CREATE TABLE "bug_user_tag" (
384   "bug" integer NOT NULL,
385   "user_tag" integer NOT NULL,
386   CONSTRAINT "bug_user_tag_bug_tag" UNIQUE ("bug", "user_tag")
387 );
388 CREATE INDEX "bug_user_tag_idx_bug" on "bug_user_tag" ("bug");
389 CREATE INDEX "bug_user_tag_idx_user_tag" on "bug_user_tag" ("user_tag");
390 CREATE INDEX "bug_user_tag_tag" on "bug_user_tag" ("user_tag");
391
392 ;
393 --
394 -- Table: bug_status_cache
395 --
396 CREATE TABLE "bug_status_cache" (
397   "bug" integer NOT NULL,
398   "suite" integer,
399   "arch" integer,
400   "status" character varying NOT NULL,
401   "modified" timestamp with time zone DEFAULT current_timestamp NOT NULL,
402   "asof" timestamp with time zone DEFAULT current_timestamp NOT NULL,
403   CONSTRAINT "bug_status_cache_bug_suite_arch_idx" UNIQUE ("bug", "suite", "arch")
404 );
405 CREATE INDEX "bug_status_cache_idx_arch" on "bug_status_cache" ("arch");
406 CREATE INDEX "bug_status_cache_idx_bug" on "bug_status_cache" ("bug");
407 CREATE INDEX "bug_status_cache_idx_suite" on "bug_status_cache" ("suite");
408
409 ;
410 --
411 -- Table: src_associations
412 --
413 CREATE TABLE "src_associations" (
414   "id" serial NOT NULL,
415   "suite" integer NOT NULL,
416   "source" integer NOT NULL,
417   "created" timestamp with time zone DEFAULT current_timestamp NOT NULL,
418   "modified" timestamp with time zone DEFAULT current_timestamp NOT NULL,
419   PRIMARY KEY ("id"),
420   CONSTRAINT "src_associations_source_suite" UNIQUE ("source", "suite")
421 );
422 CREATE INDEX "src_associations_idx_source" on "src_associations" ("source");
423 CREATE INDEX "src_associations_idx_suite" on "src_associations" ("suite");
424
425 ;
426 --
427 -- Table: bin_ver
428 --
429 CREATE TABLE "bin_ver" (
430   "id" serial NOT NULL,
431   "bin_pkg" integer NOT NULL,
432   "src_ver" integer NOT NULL,
433   "arch" integer NOT NULL,
434   "ver" debversion NOT NULL,
435   PRIMARY KEY ("id"),
436   CONSTRAINT "bin_ver_bin_pkg_id_arch_idx" UNIQUE ("bin_pkg", "arch", "ver")
437 );
438 CREATE INDEX "bin_ver_idx_arch" on "bin_ver" ("arch");
439 CREATE INDEX "bin_ver_idx_bin_pkg" on "bin_ver" ("bin_pkg");
440 CREATE INDEX "bin_ver_idx_src_ver" on "bin_ver" ("src_ver");
441 CREATE INDEX "bin_ver_ver_id_idx" on "bin_ver" ("ver");
442 CREATE INDEX "bin_ver_bin_pkg_id_idx" on "bin_ver" ("bin_pkg");
443 CREATE INDEX "bin_ver_src_ver_id_idx" on "bin_ver" ("src_ver");
444 CREATE INDEX "bin_ver_src_ver_id_arch_idx" on "bin_ver" ("src_ver", "arch");
445
446 ;
447 --
448 -- Table: bug_ver
449 --
450 CREATE TABLE "bug_ver" (
451   "id" serial NOT NULL,
452   "bug" integer NOT NULL,
453   "ver_string" text,
454   "src_pkg" integer,
455   "src_ver" integer,
456   "found" boolean DEFAULT true NOT NULL,
457   "creation" timestamp with time zone DEFAULT current_timestamp NOT NULL,
458   "last_modified" timestamp with time zone DEFAULT current_timestamp NOT NULL,
459   PRIMARY KEY ("id"),
460   CONSTRAINT "bug_ver_bug_ver_string_found_idx" UNIQUE ("bug", "ver_string", "found")
461 );
462 CREATE INDEX "bug_ver_idx_bug" on "bug_ver" ("bug");
463 CREATE INDEX "bug_ver_idx_src_pkg" on "bug_ver" ("src_pkg");
464 CREATE INDEX "bug_ver_idx_src_ver" on "bug_ver" ("src_ver");
465 CREATE INDEX "bug_ver_src_pkg_id_idx" on "bug_ver" ("src_pkg");
466 CREATE INDEX "bug_ver_src_ver_id_idx" on "bug_ver" ("src_ver");
467 CREATE INDEX "bug_ver_src_pkg_id_src_ver_id_idx" on "bug_ver" ("src_pkg", "src_ver");
468
469 ;
470 --
471 -- Table: bin_associations
472 --
473 CREATE TABLE "bin_associations" (
474   "id" serial NOT NULL,
475   "suite" integer NOT NULL,
476   "bin" integer NOT NULL,
477   "created" timestamp with time zone DEFAULT current_timestamp NOT NULL,
478   "modified" timestamp with time zone DEFAULT current_timestamp NOT NULL,
479   PRIMARY KEY ("id"),
480   CONSTRAINT "bin_associations_bin_suite" UNIQUE ("bin", "suite")
481 );
482 CREATE INDEX "bin_associations_idx_bin" on "bin_associations" ("bin");
483 CREATE INDEX "bin_associations_idx_suite" on "bin_associations" ("suite");
484
485 ;
486 --
487 -- View: "binary_versions"
488 --
489 CREATE VIEW "binary_versions" ( "src_pkg", "src_ver", "bin_pkg", "arch", "bin_ver", "src_ver_based_on", "src_pkg_based_on" ) AS
490     SELECT sp.pkg AS src_pkg, sv.ver AS src_ver, bp.pkg AS bin_pkg, a.arch AS arch, b.ver AS bin_ver,
491 svb.ver AS src_ver_based_on, spb.pkg AS src_pkg_based_on
492 FROM bin_ver b JOIN arch a ON b.arch = a.id
493                       JOIN bin_pkg bp ON b.bin_pkg  = bp.id
494                JOIN src_ver sv ON b.src_ver  = sv.id
495                JOIN src_pkg sp ON sv.src_pkg = sp.id
496                LEFT OUTER JOIN src_ver svb ON sv.based_on = svb.id
497                LEFT OUTER JOIN src_pkg spb ON spb.id = svb.src_pkg;
498
499 ;
500
501 ;
502 --
503 -- View: "bug_package"
504 --
505 CREATE VIEW "bug_package" ( "bug", "pkg_id", "pkg_type", "package" ) AS
506     SELECT b.bug,b.bin_pkg,'binary',bp.pkg FROM bug_binpackage b JOIN bin_pkg bp ON bp.id=b.bin_pkg UNION
507        SELECT s.bug,s.src_pkg,'source',sp.pkg FROM bug_srcpackage s JOIN src_pkg sp ON sp.id=s.src_pkg;
508
509 ;
510
511 ;
512 --
513 -- Foreign Key Definitions
514 --
515
516 ;
517 ALTER TABLE "src_pkg" ADD CONSTRAINT "src_pkg_fk_alias_of" FOREIGN KEY ("alias_of")
518   REFERENCES "src_pkg" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
519
520 ;
521 ALTER TABLE "correspondent_full_name" ADD CONSTRAINT "correspondent_full_name_fk_correspondent" FOREIGN KEY ("correspondent")
522   REFERENCES "correspondent" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
523
524 ;
525 ALTER TABLE "maintainer" ADD CONSTRAINT "maintainer_fk_correspondent" FOREIGN KEY ("correspondent")
526   REFERENCES "correspondent" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
527
528 ;
529 ALTER TABLE "message_refs" ADD CONSTRAINT "message_refs_fk_message" FOREIGN KEY ("message")
530   REFERENCES "message" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
531
532 ;
533 ALTER TABLE "message_refs" ADD CONSTRAINT "message_refs_fk_refs" FOREIGN KEY ("refs")
534   REFERENCES "message" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
535
536 ;
537 ALTER TABLE "user_tag" ADD CONSTRAINT "user_tag_fk_correspondent" FOREIGN KEY ("correspondent")
538   REFERENCES "correspondent" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
539
540 ;
541 ALTER TABLE "bug" ADD CONSTRAINT "bug_fk_done" FOREIGN KEY ("done")
542   REFERENCES "correspondent" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
543
544 ;
545 ALTER TABLE "bug" ADD CONSTRAINT "bug_fk_owner" FOREIGN KEY ("owner")
546   REFERENCES "correspondent" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
547
548 ;
549 ALTER TABLE "bug" ADD CONSTRAINT "bug_fk_severity" FOREIGN KEY ("severity")
550   REFERENCES "severity" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
551
552 ;
553 ALTER TABLE "bug" ADD CONSTRAINT "bug_fk_submitter" FOREIGN KEY ("submitter")
554   REFERENCES "correspondent" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
555
556 ;
557 ALTER TABLE "message_correspondent" ADD CONSTRAINT "message_correspondent_fk_correspondent" FOREIGN KEY ("correspondent")
558   REFERENCES "correspondent" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
559
560 ;
561 ALTER TABLE "message_correspondent" ADD CONSTRAINT "message_correspondent_fk_message" FOREIGN KEY ("message")
562   REFERENCES "message" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
563
564 ;
565 ALTER TABLE "bug_blocks" ADD CONSTRAINT "bug_blocks_fk_blocks" FOREIGN KEY ("blocks")
566   REFERENCES "bug" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
567
568 ;
569 ALTER TABLE "bug_blocks" ADD CONSTRAINT "bug_blocks_fk_bug" FOREIGN KEY ("bug")
570   REFERENCES "bug" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
571
572 ;
573 ALTER TABLE "bug_merged" ADD CONSTRAINT "bug_merged_fk_bug" FOREIGN KEY ("bug")
574   REFERENCES "bug" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
575
576 ;
577 ALTER TABLE "bug_merged" ADD CONSTRAINT "bug_merged_fk_merged" FOREIGN KEY ("merged")
578   REFERENCES "bug" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
579
580 ;
581 ALTER TABLE "src_ver" ADD CONSTRAINT "src_ver_fk_based_on" FOREIGN KEY ("based_on")
582   REFERENCES "src_ver" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
583
584 ;
585 ALTER TABLE "src_ver" ADD CONSTRAINT "src_ver_fk_maintainer" FOREIGN KEY ("maintainer")
586   REFERENCES "maintainer" ("id") ON DELETE SET NULL ON UPDATE CASCADE;
587
588 ;
589 ALTER TABLE "src_ver" ADD CONSTRAINT "src_ver_fk_src_pkg" FOREIGN KEY ("src_pkg")
590   REFERENCES "src_pkg" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
591
592 ;
593 ALTER TABLE "bug_affects_binpackage" ADD CONSTRAINT "bug_affects_binpackage_fk_bin_pkg" FOREIGN KEY ("bin_pkg")
594   REFERENCES "bin_pkg" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
595
596 ;
597 ALTER TABLE "bug_affects_binpackage" ADD CONSTRAINT "bug_affects_binpackage_fk_bug" FOREIGN KEY ("bug")
598   REFERENCES "bug" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
599
600 ;
601 ALTER TABLE "bug_affects_srcpackage" ADD CONSTRAINT "bug_affects_srcpackage_fk_bug" FOREIGN KEY ("bug")
602   REFERENCES "bug" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
603
604 ;
605 ALTER TABLE "bug_affects_srcpackage" ADD CONSTRAINT "bug_affects_srcpackage_fk_src_pkg" FOREIGN KEY ("src_pkg")
606   REFERENCES "src_pkg" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
607
608 ;
609 ALTER TABLE "bug_binpackage" ADD CONSTRAINT "bug_binpackage_fk_bin_pkg" FOREIGN KEY ("bin_pkg")
610   REFERENCES "bin_pkg" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
611
612 ;
613 ALTER TABLE "bug_binpackage" ADD CONSTRAINT "bug_binpackage_fk_bug" FOREIGN KEY ("bug")
614   REFERENCES "bug" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
615
616 ;
617 ALTER TABLE "bug_message" ADD CONSTRAINT "bug_message_fk_bug" FOREIGN KEY ("bug")
618   REFERENCES "bug" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
619
620 ;
621 ALTER TABLE "bug_message" ADD CONSTRAINT "bug_message_fk_message" FOREIGN KEY ("message")
622   REFERENCES "message" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
623
624 ;
625 ALTER TABLE "bug_srcpackage" ADD CONSTRAINT "bug_srcpackage_fk_bug" FOREIGN KEY ("bug")
626   REFERENCES "bug" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
627
628 ;
629 ALTER TABLE "bug_srcpackage" ADD CONSTRAINT "bug_srcpackage_fk_src_pkg" FOREIGN KEY ("src_pkg")
630   REFERENCES "src_pkg" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
631
632 ;
633 ALTER TABLE "bug_tag" ADD CONSTRAINT "bug_tag_fk_bug" FOREIGN KEY ("bug")
634   REFERENCES "bug" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
635
636 ;
637 ALTER TABLE "bug_tag" ADD CONSTRAINT "bug_tag_fk_tag" FOREIGN KEY ("tag")
638   REFERENCES "tag" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
639
640 ;
641 ALTER TABLE "bug_user_tag" ADD CONSTRAINT "bug_user_tag_fk_bug" FOREIGN KEY ("bug")
642   REFERENCES "bug" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
643
644 ;
645 ALTER TABLE "bug_user_tag" ADD CONSTRAINT "bug_user_tag_fk_user_tag" FOREIGN KEY ("user_tag")
646   REFERENCES "user_tag" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
647
648 ;
649 ALTER TABLE "bug_status_cache" ADD CONSTRAINT "bug_status_cache_fk_arch" FOREIGN KEY ("arch")
650   REFERENCES "arch" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
651
652 ;
653 ALTER TABLE "bug_status_cache" ADD CONSTRAINT "bug_status_cache_fk_bug" FOREIGN KEY ("bug")
654   REFERENCES "bug" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
655
656 ;
657 ALTER TABLE "bug_status_cache" ADD CONSTRAINT "bug_status_cache_fk_suite" FOREIGN KEY ("suite")
658   REFERENCES "suite" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
659
660 ;
661 ALTER TABLE "src_associations" ADD CONSTRAINT "src_associations_fk_source" FOREIGN KEY ("source")
662   REFERENCES "src_ver" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
663
664 ;
665 ALTER TABLE "src_associations" ADD CONSTRAINT "src_associations_fk_suite" FOREIGN KEY ("suite")
666   REFERENCES "suite" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
667
668 ;
669 ALTER TABLE "bin_ver" ADD CONSTRAINT "bin_ver_fk_arch" FOREIGN KEY ("arch")
670   REFERENCES "arch" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
671
672 ;
673 ALTER TABLE "bin_ver" ADD CONSTRAINT "bin_ver_fk_bin_pkg" FOREIGN KEY ("bin_pkg")
674   REFERENCES "bin_pkg" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
675
676 ;
677 ALTER TABLE "bin_ver" ADD CONSTRAINT "bin_ver_fk_src_ver" FOREIGN KEY ("src_ver")
678   REFERENCES "src_ver" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
679
680 ;
681 ALTER TABLE "bug_ver" ADD CONSTRAINT "bug_ver_fk_bug" FOREIGN KEY ("bug")
682   REFERENCES "bug" ("id") ON DELETE RESTRICT ON UPDATE CASCADE;
683
684 ;
685 ALTER TABLE "bug_ver" ADD CONSTRAINT "bug_ver_fk_src_pkg" FOREIGN KEY ("src_pkg")
686   REFERENCES "src_pkg" ("id") ON DELETE SET NULL ON UPDATE CASCADE;
687
688 ;
689 ALTER TABLE "bug_ver" ADD CONSTRAINT "bug_ver_fk_src_ver" FOREIGN KEY ("src_ver")
690   REFERENCES "src_ver" ("id") ON DELETE SET NULL ON UPDATE CASCADE;
691
692 ;
693 ALTER TABLE "bin_associations" ADD CONSTRAINT "bin_associations_fk_bin" FOREIGN KEY ("bin")
694   REFERENCES "bin_ver" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
695
696 ;
697 ALTER TABLE "bin_associations" ADD CONSTRAINT "bin_associations_fk_suite" FOREIGN KEY ("suite")
698   REFERENCES "suite" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
699
700 ;