]> git.donarmstrong.com Git - debbugs.git/blob - sql/PostgreSQL/deploy/1/001-auto.sql
283b43fb2eeb9c38f11ad07089ff27299417e65e
[debbugs.git] / sql / PostgreSQL / deploy / 1 / 001-auto.sql
1 -- 
2 -- Created by SQL::Translator::Producer::PostgreSQL
3 -- Created on Wed Aug  6 09:18:36 2014
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: binary_versions.
30 --
31 CREATE TABLE "binary_versions" (
32   "src_pkg" text,
33   "src_ver" debversion,
34   "bin_pkg" text,
35   "arch" text,
36   "bin_ver" debversion,
37   "src_ver_based_on" debversion,
38   "src_pkg_based_on" text
39 );
40
41 ;
42 --
43 -- Table: bug_package.
44 --
45 CREATE TABLE "bug_package" (
46   "bug" integer,
47   "pkg_id" integer,
48   "pkg_type" text,
49   "package" text
50 );
51
52 ;
53 --
54 -- Table: column_comments.
55 --
56 CREATE TABLE "column_comments" (
57   "table_name" text NOT NULL,
58   "column_name" text NOT NULL,
59   "comment_text" text NOT NULL,
60   CONSTRAINT "column_comments_table_name_column_name_idx" UNIQUE ("table_name", "column_name")
61 );
62
63 ;
64 --
65 -- Table: correspondent.
66 --
67 CREATE TABLE "correspondent" (
68   "id" serial NOT NULL,
69   "addr" text NOT NULL,
70   PRIMARY KEY ("id"),
71   CONSTRAINT "correspondent_addr_idx" UNIQUE ("addr")
72 );
73
74 ;
75 --
76 -- Table: dbix_class_deploymenthandler_versions.
77 --
78 CREATE TABLE "dbix_class_deploymenthandler_versions" (
79   "id" serial NOT NULL,
80   "version" character varying(50) NOT NULL,
81   "ddl" text,
82   "upgrade_sql" text,
83   PRIMARY KEY ("id"),
84   CONSTRAINT "dbix_class_deploymenthandler_versions_version" UNIQUE ("version")
85 );
86
87 ;
88 --
89 -- Table: message.
90 --
91 CREATE TABLE "message" (
92   "id" serial NOT NULL,
93   "msgid" text,
94   "from_complete" text,
95   "from_addr" text,
96   "to_complete" text,
97   "to_addr" text,
98   "subject" text DEFAULT '' NOT NULL,
99   "sent_date" timestamp with time zone,
100   "refs" text DEFAULT '' NOT NULL,
101   "spam_score" double precision,
102   "is_spam" boolean DEFAULT false,
103   PRIMARY KEY ("id")
104 );
105
106 ;
107 --
108 -- Table: severity.
109 --
110 CREATE TABLE "severity" (
111   "id" serial NOT NULL,
112   "severity" text NOT NULL,
113   "ordering" integer DEFAULT 5 NOT NULL,
114   "strong" boolean DEFAULT false,
115   "obsolete" boolean DEFAULT false,
116   PRIMARY KEY ("id"),
117   CONSTRAINT "severity_severity_idx" UNIQUE ("severity")
118 );
119
120 ;
121 --
122 -- Table: src_pkg.
123 --
124 CREATE TABLE "src_pkg" (
125   "id" serial NOT NULL,
126   "pkg" text NOT NULL,
127   "pseduopkg" boolean DEFAULT false,
128   "alias_of" integer,
129   "creation" timestamp with time zone DEFAULT current_timestamp,
130   "disabled" timestamp with time zone,
131   "last_modified" timestamp with time zone DEFAULT current_timestamp,
132   "obsolete" boolean DEFAULT false,
133   PRIMARY KEY ("id"),
134   CONSTRAINT "src_pkg_pkg_disabled" UNIQUE ("pkg", "disabled")
135 );
136 CREATE INDEX "src_pkg_idx_alias_of" on "src_pkg" ("alias_of");
137
138 ;
139 --
140 -- Table: suite.
141 --
142 CREATE TABLE "suite" (
143   "id" serial NOT NULL,
144   "suite_name" text NOT NULL,
145   "version" text,
146   "codename" text,
147   "active" boolean DEFAULT true,
148   PRIMARY KEY ("id"),
149   CONSTRAINT "suite_suite_name_key" UNIQUE ("suite_name")
150 );
151
152 ;
153 --
154 -- Table: table_comments.
155 --
156 CREATE TABLE "table_comments" (
157   "table_name" text NOT NULL,
158   "comment_text" text NOT NULL,
159   CONSTRAINT "table_comments_table_name_key" UNIQUE ("table_name")
160 );
161
162 ;
163 --
164 -- Table: tag.
165 --
166 CREATE TABLE "tag" (
167   "id" serial NOT NULL,
168   "tag" text NOT NULL,
169   "obsolete" boolean DEFAULT false,
170   PRIMARY KEY ("id"),
171   CONSTRAINT "tag_tag_key" UNIQUE ("tag")
172 );
173
174 ;
175 --
176 -- Table: correspondent_full_name.
177 --
178 CREATE TABLE "correspondent_full_name" (
179   "id" serial NOT NULL,
180   "correspondent" integer NOT NULL,
181   "full_name" text NOT NULL,
182   "last_seen" timestamp DEFAULT current_timestamp NOT NULL,
183   PRIMARY KEY ("id"),
184   CONSTRAINT "correspondent_full_name_correspondent_full_name_idx" UNIQUE ("correspondent", "full_name")
185 );
186 CREATE INDEX "correspondent_full_name_idx_correspondent" on "correspondent_full_name" ("correspondent");
187
188 ;
189 --
190 -- Table: maintainer.
191 --
192 CREATE TABLE "maintainer" (
193   "id" serial NOT NULL,
194   "name" text NOT NULL,
195   "correspondent" integer NOT NULL,
196   "created" timestamp with time zone DEFAULT current_timestamp NOT NULL,
197   "modified" timestamp with time zone DEFAULT current_timestamp NOT NULL,
198   PRIMARY KEY ("id"),
199   CONSTRAINT "maintainer_name_idx" UNIQUE ("name")
200 );
201 CREATE INDEX "maintainer_idx_correspondent" on "maintainer" ("correspondent");
202
203 ;
204 --
205 -- Table: message_refs.
206 --
207 CREATE TABLE "message_refs" (
208   "id" serial NOT NULL,
209   "message" integer NOT NULL,
210   "refs" integer NOT NULL,
211   "inferred" boolean DEFAULT false,
212   "primary_ref" boolean DEFAULT false,
213   PRIMARY KEY ("id"),
214   CONSTRAINT "message_refs_message_refs_idx" UNIQUE ("message", "refs")
215 );
216 CREATE INDEX "message_refs_idx_message" on "message_refs" ("message");
217 CREATE INDEX "message_refs_idx_refs" on "message_refs" ("refs");
218
219 ;
220 --
221 -- Table: bug.
222 --
223 CREATE TABLE "bug" (
224   "id" integer NOT NULL,
225   "creation" timestamp with time zone DEFAULT current_timestamp NOT NULL,
226   "log_modified" timestamp with time zone DEFAULT current_timestamp NOT NULL,
227   "last_modified" timestamp with time zone DEFAULT current_timestamp NOT NULL,
228   "archived" boolean DEFAULT false NOT NULL,
229   "unarchived" timestamp with time zone,
230   "forwarded" text DEFAULT '' NOT NULL,
231   "summary" text DEFAULT '' NOT NULL,
232   "outlook" text DEFAULT '' NOT NULL,
233   "subject" text NOT NULL,
234   "severity" integer NOT NULL,
235   "done" integer,
236   "done_full" text DEFAULT '' NOT NULL,
237   "owner" integer,
238   "owner_full" text DEFAULT '' NOT NULL,
239   "submitter" integer,
240   "submitter_full" text DEFAULT '' NOT NULL,
241   "unknown_packages" text DEFAULT '' NOT NULL,
242   PRIMARY KEY ("id")
243 );
244 CREATE INDEX "bug_idx_done" on "bug" ("done");
245 CREATE INDEX "bug_idx_owner" on "bug" ("owner");
246 CREATE INDEX "bug_idx_severity" on "bug" ("severity");
247 CREATE INDEX "bug_idx_submitter" on "bug" ("submitter");
248
249 ;
250 --
251 -- Table: message_correspondent.
252 --
253 CREATE TABLE "message_correspondent" (
254   "id" serial NOT NULL,
255   "message" integer NOT NULL,
256   "correspondent" integer NOT NULL,
257   "correspondent_type" character varying DEFAULT 'to' NOT NULL,
258   PRIMARY KEY ("id"),
259   CONSTRAINT "message_correspondent_message_correspondent_correspondent_t_idx" UNIQUE ("message", "correspondent", "correspondent_type")
260 );
261 CREATE INDEX "message_correspondent_idx_correspondent" on "message_correspondent" ("correspondent");
262 CREATE INDEX "message_correspondent_idx_message" on "message_correspondent" ("message");
263
264 ;
265 --
266 -- Table: bug_blocks.
267 --
268 CREATE TABLE "bug_blocks" (
269   "id" serial NOT NULL,
270   "bug" integer NOT NULL,
271   "blocks" integer NOT NULL,
272   PRIMARY KEY ("id"),
273   CONSTRAINT "bug_blocks_bug_id_blocks_idx" UNIQUE ("bug", "blocks")
274 );
275 CREATE INDEX "bug_blocks_idx_blocks" on "bug_blocks" ("blocks");
276 CREATE INDEX "bug_blocks_idx_bug" on "bug_blocks" ("bug");
277
278 ;
279 --
280 -- Table: bug_merged.
281 --
282 CREATE TABLE "bug_merged" (
283   "id" serial NOT NULL,
284   "bug" integer NOT NULL,
285   "merged" integer NOT NULL,
286   PRIMARY KEY ("id"),
287   CONSTRAINT "bug_merged_bug_id_merged_idx" UNIQUE ("bug", "merged")
288 );
289 CREATE INDEX "bug_merged_idx_bug" on "bug_merged" ("bug");
290 CREATE INDEX "bug_merged_idx_merged" on "bug_merged" ("merged");
291
292 ;
293 --
294 -- Table: src_ver.
295 --
296 CREATE TABLE "src_ver" (
297   "id" serial NOT NULL,
298   "src_pkg" integer NOT NULL,
299   "ver" debversion NOT NULL,
300   "maintainer" integer,
301   "upload_date" timestamp with time zone DEFAULT current_timestamp NOT NULL,
302   "based_on" integer,
303   PRIMARY KEY ("id"),
304   CONSTRAINT "src_ver_src_pkg_id_ver" UNIQUE ("src_pkg", "ver")
305 );
306 CREATE INDEX "src_ver_idx_based_on" on "src_ver" ("based_on");
307 CREATE INDEX "src_ver_idx_maintainer" on "src_ver" ("maintainer");
308 CREATE INDEX "src_ver_idx_src_pkg" on "src_ver" ("src_pkg");
309
310 ;
311 --
312 -- Table: bug_binpackage.
313 --
314 CREATE TABLE "bug_binpackage" (
315   "id" serial NOT NULL,
316   "bug" integer NOT NULL,
317   "bin_pkg" integer NOT NULL,
318   PRIMARY KEY ("id"),
319   CONSTRAINT "bug_binpackage_id_pkg" UNIQUE ("bug", "bin_pkg")
320 );
321 CREATE INDEX "bug_binpackage_idx_bin_pkg" on "bug_binpackage" ("bin_pkg");
322 CREATE INDEX "bug_binpackage_idx_bug" on "bug_binpackage" ("bug");
323
324 ;
325 --
326 -- Table: bug_message.
327 --
328 CREATE TABLE "bug_message" (
329   "id" serial NOT NULL,
330   "bug" integer NOT NULL,
331   "message" integer NOT NULL,
332   "message_number" integer NOT NULL,
333   "bug_log_offset" integer,
334   "offset_valid" timestamp with time zone,
335   PRIMARY KEY ("id"),
336   CONSTRAINT "bug_message_bug_message_idx" UNIQUE ("bug", "message")
337 );
338 CREATE INDEX "bug_message_idx_bug" on "bug_message" ("bug");
339 CREATE INDEX "bug_message_idx_message" on "bug_message" ("message");
340
341 ;
342 --
343 -- Table: bug_srcpackage.
344 --
345 CREATE TABLE "bug_srcpackage" (
346   "id" serial NOT NULL,
347   "bug" integer NOT NULL,
348   "src_pkg" integer NOT NULL,
349   PRIMARY KEY ("id"),
350   CONSTRAINT "bug_srcpackage_id_pkg" UNIQUE ("bug", "src_pkg")
351 );
352 CREATE INDEX "bug_srcpackage_idx_bug" on "bug_srcpackage" ("bug");
353 CREATE INDEX "bug_srcpackage_idx_src_pkg" on "bug_srcpackage" ("src_pkg");
354
355 ;
356 --
357 -- Table: bug_tag.
358 --
359 CREATE TABLE "bug_tag" (
360   "id" serial NOT NULL,
361   "bug" integer NOT NULL,
362   "tag" integer NOT NULL,
363   PRIMARY KEY ("id"),
364   CONSTRAINT "bug_tag_bug_tag" UNIQUE ("bug", "tag")
365 );
366 CREATE INDEX "bug_tag_idx_bug" on "bug_tag" ("bug");
367 CREATE INDEX "bug_tag_idx_tag" on "bug_tag" ("tag");
368
369 ;
370 --
371 -- Table: bug_status_cache.
372 --
373 CREATE TABLE "bug_status_cache" (
374   "id" serial NOT NULL,
375   "bug" integer NOT NULL,
376   "suite" integer,
377   "arch" integer,
378   "status" character varying NOT NULL,
379   "modified" timestamp with time zone DEFAULT current_timestamp NOT NULL,
380   "asof" timestamp with time zone DEFAULT current_timestamp NOT NULL,
381   PRIMARY KEY ("id"),
382   CONSTRAINT "bug_status_cache_bug_suite_arch_idx" UNIQUE ("bug", "suite", "arch")
383 );
384 CREATE INDEX "bug_status_cache_idx_arch" on "bug_status_cache" ("arch");
385 CREATE INDEX "bug_status_cache_idx_bug" on "bug_status_cache" ("bug");
386 CREATE INDEX "bug_status_cache_idx_suite" on "bug_status_cache" ("suite");
387
388 ;
389 --
390 -- Table: src_associations.
391 --
392 CREATE TABLE "src_associations" (
393   "id" serial NOT NULL,
394   "suite" integer NOT NULL,
395   "source" integer NOT NULL,
396   "created" timestamp with time zone DEFAULT current_timestamp NOT NULL,
397   "modified" timestamp with time zone DEFAULT current_timestamp NOT NULL,
398   PRIMARY KEY ("id")
399 );
400 CREATE INDEX "src_associations_idx_source" on "src_associations" ("source");
401 CREATE INDEX "src_associations_idx_suite" on "src_associations" ("suite");
402
403 ;
404 --
405 -- Table: bin_ver.
406 --
407 CREATE TABLE "bin_ver" (
408   "id" serial NOT NULL,
409   "bin_pkg" integer NOT NULL,
410   "src_ver" integer NOT NULL,
411   "arch" integer NOT NULL,
412   "ver" debversion NOT NULL,
413   PRIMARY KEY ("id")
414 );
415 CREATE INDEX "bin_ver_idx_arch" on "bin_ver" ("arch");
416 CREATE INDEX "bin_ver_idx_bin_pkg" on "bin_ver" ("bin_pkg");
417 CREATE INDEX "bin_ver_idx_src_ver" on "bin_ver" ("src_ver");
418
419 ;
420 --
421 -- Table: bug_ver.
422 --
423 CREATE TABLE "bug_ver" (
424   "id" serial NOT NULL,
425   "bug" integer NOT NULL,
426   "ver_string" text,
427   "src_pkg" integer,
428   "src_ver" integer,
429   "found" boolean DEFAULT true NOT NULL,
430   "creation" timestamp with time zone DEFAULT current_timestamp NOT NULL,
431   "last_modified" timestamp with time zone DEFAULT current_timestamp NOT NULL,
432   PRIMARY KEY ("id"),
433   CONSTRAINT "bug_ver_bug_ver_string_found_idx" UNIQUE ("bug", "ver_string", "found")
434 );
435 CREATE INDEX "bug_ver_idx_bug" on "bug_ver" ("bug");
436 CREATE INDEX "bug_ver_idx_src_pkg" on "bug_ver" ("src_pkg");
437 CREATE INDEX "bug_ver_idx_src_ver" on "bug_ver" ("src_ver");
438
439 ;
440 --
441 -- Table: bin_associations.
442 --
443 CREATE TABLE "bin_associations" (
444   "id" serial NOT NULL,
445   "suite" integer NOT NULL,
446   "bin" integer NOT NULL,
447   "created" timestamp with time zone DEFAULT current_timestamp NOT NULL,
448   "modified" timestamp with time zone DEFAULT current_timestamp NOT NULL,
449   PRIMARY KEY ("id")
450 );
451 CREATE INDEX "bin_associations_idx_bin" on "bin_associations" ("bin");
452 CREATE INDEX "bin_associations_idx_suite" on "bin_associations" ("suite");
453
454 ;
455 --
456 -- Foreign Key Definitions
457 --
458
459 ;
460 ALTER TABLE "src_pkg" ADD CONSTRAINT "src_pkg_fk_alias_of" FOREIGN KEY ("alias_of")
461   REFERENCES "src_pkg" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
462
463 ;
464 ALTER TABLE "correspondent_full_name" ADD CONSTRAINT "correspondent_full_name_fk_correspondent" FOREIGN KEY ("correspondent")
465   REFERENCES "correspondent" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
466
467 ;
468 ALTER TABLE "maintainer" ADD CONSTRAINT "maintainer_fk_correspondent" FOREIGN KEY ("correspondent")
469   REFERENCES "correspondent" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
470
471 ;
472 ALTER TABLE "message_refs" ADD CONSTRAINT "message_refs_fk_message" FOREIGN KEY ("message")
473   REFERENCES "message" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
474
475 ;
476 ALTER TABLE "message_refs" ADD CONSTRAINT "message_refs_fk_refs" FOREIGN KEY ("refs")
477   REFERENCES "message" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
478
479 ;
480 ALTER TABLE "bug" ADD CONSTRAINT "bug_fk_done" FOREIGN KEY ("done")
481   REFERENCES "correspondent" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
482
483 ;
484 ALTER TABLE "bug" ADD CONSTRAINT "bug_fk_owner" FOREIGN KEY ("owner")
485   REFERENCES "correspondent" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
486
487 ;
488 ALTER TABLE "bug" ADD CONSTRAINT "bug_fk_severity" FOREIGN KEY ("severity")
489   REFERENCES "severity" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
490
491 ;
492 ALTER TABLE "bug" ADD CONSTRAINT "bug_fk_submitter" FOREIGN KEY ("submitter")
493   REFERENCES "correspondent" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
494
495 ;
496 ALTER TABLE "message_correspondent" ADD CONSTRAINT "message_correspondent_fk_correspondent" FOREIGN KEY ("correspondent")
497   REFERENCES "correspondent" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
498
499 ;
500 ALTER TABLE "message_correspondent" ADD CONSTRAINT "message_correspondent_fk_message" FOREIGN KEY ("message")
501   REFERENCES "message" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
502
503 ;
504 ALTER TABLE "bug_blocks" ADD CONSTRAINT "bug_blocks_fk_blocks" FOREIGN KEY ("blocks")
505   REFERENCES "bug" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
506
507 ;
508 ALTER TABLE "bug_blocks" ADD CONSTRAINT "bug_blocks_fk_bug" FOREIGN KEY ("bug")
509   REFERENCES "bug" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
510
511 ;
512 ALTER TABLE "bug_merged" ADD CONSTRAINT "bug_merged_fk_bug" FOREIGN KEY ("bug")
513   REFERENCES "bug" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
514
515 ;
516 ALTER TABLE "bug_merged" ADD CONSTRAINT "bug_merged_fk_merged" FOREIGN KEY ("merged")
517   REFERENCES "bug" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
518
519 ;
520 ALTER TABLE "src_ver" ADD CONSTRAINT "src_ver_fk_based_on" FOREIGN KEY ("based_on")
521   REFERENCES "src_ver" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
522
523 ;
524 ALTER TABLE "src_ver" ADD CONSTRAINT "src_ver_fk_maintainer" FOREIGN KEY ("maintainer")
525   REFERENCES "maintainer" ("id") ON DELETE SET NULL ON UPDATE CASCADE;
526
527 ;
528 ALTER TABLE "src_ver" ADD CONSTRAINT "src_ver_fk_src_pkg" FOREIGN KEY ("src_pkg")
529   REFERENCES "src_pkg" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
530
531 ;
532 ALTER TABLE "bug_binpackage" ADD CONSTRAINT "bug_binpackage_fk_bin_pkg" FOREIGN KEY ("bin_pkg")
533   REFERENCES "bin_pkg" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
534
535 ;
536 ALTER TABLE "bug_binpackage" ADD CONSTRAINT "bug_binpackage_fk_bug" FOREIGN KEY ("bug")
537   REFERENCES "bug" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
538
539 ;
540 ALTER TABLE "bug_message" ADD CONSTRAINT "bug_message_fk_bug" FOREIGN KEY ("bug")
541   REFERENCES "bug" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
542
543 ;
544 ALTER TABLE "bug_message" ADD CONSTRAINT "bug_message_fk_message" FOREIGN KEY ("message")
545   REFERENCES "message" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
546
547 ;
548 ALTER TABLE "bug_srcpackage" ADD CONSTRAINT "bug_srcpackage_fk_bug" FOREIGN KEY ("bug")
549   REFERENCES "bug" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
550
551 ;
552 ALTER TABLE "bug_srcpackage" ADD CONSTRAINT "bug_srcpackage_fk_src_pkg" FOREIGN KEY ("src_pkg")
553   REFERENCES "src_pkg" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
554
555 ;
556 ALTER TABLE "bug_tag" ADD CONSTRAINT "bug_tag_fk_bug" FOREIGN KEY ("bug")
557   REFERENCES "bug" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
558
559 ;
560 ALTER TABLE "bug_tag" ADD CONSTRAINT "bug_tag_fk_tag" FOREIGN KEY ("tag")
561   REFERENCES "tag" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
562
563 ;
564 ALTER TABLE "bug_status_cache" ADD CONSTRAINT "bug_status_cache_fk_arch" FOREIGN KEY ("arch")
565   REFERENCES "arch" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
566
567 ;
568 ALTER TABLE "bug_status_cache" ADD CONSTRAINT "bug_status_cache_fk_bug" FOREIGN KEY ("bug")
569   REFERENCES "bug" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
570
571 ;
572 ALTER TABLE "bug_status_cache" ADD CONSTRAINT "bug_status_cache_fk_suite" FOREIGN KEY ("suite")
573   REFERENCES "suite" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
574
575 ;
576 ALTER TABLE "src_associations" ADD CONSTRAINT "src_associations_fk_source" FOREIGN KEY ("source")
577   REFERENCES "src_ver" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
578
579 ;
580 ALTER TABLE "src_associations" ADD CONSTRAINT "src_associations_fk_suite" FOREIGN KEY ("suite")
581   REFERENCES "suite" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
582
583 ;
584 ALTER TABLE "bin_ver" ADD CONSTRAINT "bin_ver_fk_arch" FOREIGN KEY ("arch")
585   REFERENCES "arch" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
586
587 ;
588 ALTER TABLE "bin_ver" ADD CONSTRAINT "bin_ver_fk_bin_pkg" FOREIGN KEY ("bin_pkg")
589   REFERENCES "bin_pkg" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
590
591 ;
592 ALTER TABLE "bin_ver" ADD CONSTRAINT "bin_ver_fk_src_ver" FOREIGN KEY ("src_ver")
593   REFERENCES "src_ver" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
594
595 ;
596 ALTER TABLE "bug_ver" ADD CONSTRAINT "bug_ver_fk_bug" FOREIGN KEY ("bug")
597   REFERENCES "bug" ("id") ON DELETE RESTRICT ON UPDATE CASCADE;
598
599 ;
600 ALTER TABLE "bug_ver" ADD CONSTRAINT "bug_ver_fk_src_pkg" FOREIGN KEY ("src_pkg")
601   REFERENCES "src_pkg" ("id") ON DELETE SET NULL ON UPDATE CASCADE;
602
603 ;
604 ALTER TABLE "bug_ver" ADD CONSTRAINT "bug_ver_fk_src_ver" FOREIGN KEY ("src_ver")
605   REFERENCES "src_ver" ("id") ON DELETE SET NULL ON UPDATE CASCADE;
606
607 ;
608 ALTER TABLE "bin_associations" ADD CONSTRAINT "bin_associations_fk_bin" FOREIGN KEY ("bin")
609   REFERENCES "bin_ver" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
610
611 ;
612 ALTER TABLE "bin_associations" ADD CONSTRAINT "bin_associations_fk_suite" FOREIGN KEY ("suite")
613   REFERENCES "suite" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
614
615 ;