2 DROP TABLE bug_status_cache CASCADE;
3 DROP VIEW bug_package CASCADE;
4 DROP VIEW binary_versions CASCADE;
5 DROP TABLE bug_tag CASCADE;
6 DROP TABLE tag CASCADE;
7 DROP TABLE severity CASCADE;
8 DROP TABLE bug CASCADE;
9 DROP TABLE src_pkg CASCADE;
10 DROP TABLE bug_ver CASCADE;
11 DROP TABLE src_ver CASCADE;
12 DROP TABLE arch CASCADE;
13 DROP TABLE bin_ver CASCADE;
14 DROP TABLE bin_pkg CASCADE;
15 DROP TABLE bug_blocks CASCADE;
16 DROP TABLE bug_merged CASCADE;
17 DROP TABLE bug_srcpackage CASCADE;
18 DROP TABLE bug_binpackage CASCADE;
19 DROP TABLE suite CASCADE;
20 DROP TABLE bin_associations CASCADE;
21 DROP TABLE src_associations CASCADE;
22 DROP TABLE maintainer CASCADE;
23 DROP TABLE bug_message CASCADE;
24 DROP TABLE message_correspondent CASCADE;
25 DROP TABLE correspondent_full_name CASCADE;
26 DROP TABLE correspondent CASCADE;
27 DROP TABLE message_refs CASCADE;
28 DROP TABLE message CASCADE;
29 DROP TYPE message_correspondent_type CASCADE;
30 DROP TABLE table_comments CASCADE;
31 DROP TABLE column_comments CASCADE;
32 DROP TYPE bug_status_type CASCADE;
34 -- the following two tables are used to provide documentation about
35 -- the tables and columns for DBIx::Class::Schema::Loader
36 CREATE TABLE table_comments (
37 table_name TEXT UNIQUE NOT NULL,
38 comment_text TEXT NOT NULL
40 CREATE TABLE column_comments (
41 table_name TEXT NOT NULL,
42 column_name TEXT NOT NULL,
43 comment_text TEXT NOT NULL
45 CREATE UNIQUE INDEX ON column_comments(table_name,column_name);
48 CREATE TABLE correspondent (
49 id SERIAL PRIMARY KEY,
52 CREATE UNIQUE INDEX ON correspondent(addr);
53 INSERT INTO table_comments VALUES ('correspondent','Individual who has corresponded with the BTS');
54 INSERT INTO column_comments VALUES ('correspondent','id','Correspondent ID');
55 INSERT INTO column_comments VALUES ('correspondent','addr','Correspondent address');
57 CREATE TABLE maintainer (
58 id SERIAL PRIMARY KEY,
60 correspondent INT NOT NULL REFERENCES correspondent(id),
61 created TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
62 modified TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL
64 CREATE UNIQUE INDEX ON maintainer(name);
65 CREATE INDEX ON maintainer(correspondent);
66 INSERT INTO table_comments VALUES ('maintainer','Package maintainer names');
67 INSERT INTO column_comments VALUES ('maintainer','id','Package maintainer id');
68 INSERT INTO column_comments VALUES ('maintainer','name','Name of package maintainer');
69 INSERT INTO column_comments VALUES ('maintainer','correspondent','Correspondent ID');
70 INSERT INTO column_comments VALUES ('maintainer','created','Time maintainer record created');
71 INSERT INTO column_comments VALUES ('maintainer','modified','Time maintainer record modified');
74 CREATE TABLE severity (
75 id SERIAL PRIMARY KEY,
76 severity TEXT NOT NULL,
77 ordering INT NOT NULL DEFAULT 5,
78 strong BOOLEAN DEFAULT FALSE,
79 obsolete BOOLEAN DEFAULT FALSE
81 CREATE UNIQUE INDEX ON severity(severity);
82 CREATE INDEX ON severity(ordering);
83 INSERT INTO table_comments VALUES ('severity','Bug severity');
84 INSERT INTO column_comments VALUES ('severity','id','Severity id');
85 INSERT INTO column_comments VALUES ('severity','severity','Severity name');
86 INSERT INTO column_comments VALUES ('severity','ordering','Severity ordering (more severe severities have higher numbers)');
87 INSERT INTO column_comments VALUES ('severity','strong','True if severity is a strong severity');
88 INSERT INTO column_comments VALUES ('severity','obsolete','Whether a severity level is obsolete (should not be set on new bugs)');
92 id INTEGER NOT NULL PRIMARY KEY,
93 creation TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
94 log_modified TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
95 last_modified TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
96 archived BOOLEAN NOT NULL DEFAULT FALSE,
97 unarchived TIMESTAMP WITH TIME ZONE,
98 forwarded TEXT NOT NULL DEFAULT '',
99 summary TEXT NOT NULL DEFAULT '',
100 outlook TEXT NOT NULL DEFAULT '',
101 subject TEXT NOT NULL,
102 severity INT NOT NULL REFERENCES severity(id),
103 done INT REFERENCES correspondent(id),
104 done_full TEXT NOT NULL DEFAULT '',
105 owner INT REFERENCES correspondent(id),
106 owner_full TEXT NOT NULL DEFAULT '',
107 -- submitter would ideally be NOT NULL, but there are some ancient bugs which do not have submitters
108 submitter INT REFERENCES correspondent(id),
109 submitter_full TEXT NOT NULL DEFAULT '',
110 unknown_packages TEXT NOT NULL DEfAULT ''
112 CREATE INDEX ON bug(owner);
113 CREATE INDEX ON bug(submitter);
114 CREATE INDEX ON bug(done);
115 CREATE INDEX ON bug(forwarded);
116 CREATE INDEX ON bug(last_modified);
117 CREATE INDEX ON bug(severity);
118 INSERT INTO table_comments VALUES ('bug','Bugs');
119 INSERT INTO column_comments VALUES ('bug','id','Bug number');
120 INSERT INTO column_comments VALUES ('bug','creation','Time bug created');
121 INSERT INTO column_comments VALUES ('bug','log_modified','Time bug log was last modified');
122 INSERT INTO column_comments VALUES ('bug','last_modified','Time bug status was last modified');
123 INSERT INTO column_comments VALUES ('bug','archived','True if bug has been archived');
124 INSERT INTO column_comments VALUES ('bug','unarchived','Time bug was last unarchived; null if bug has never been unarchived');
125 INSERT INTO column_comments VALUES ('bug','forwarded','Where bug has been forwarded to; empty if it has not been forwarded');
126 INSERT INTO column_comments VALUES ('bug','summary','Summary of the bug; empty if it has no summary');
127 INSERT INTO column_comments VALUES ('bug','outlook','Outlook of the bug; empty if it has no outlook');
128 INSERT INTO column_comments VALUES ('bug','subject','Subject of the bug');
129 INSERT INTO column_comments VALUES ('bug','done','Individual who did the -done; empty if it has never been -done');
130 INSERT INTO column_comments VALUES ('bug','owner','Individual who owns this bug; empty if no one owns it');
131 INSERT INTO column_comments VALUES ('bug','submitter','Individual who submitted this bug; empty if there is no submitter');
132 INSERT INTO column_comments VALUES ('bug','unknown_packages','Package name if the package is not known');
134 CREATE INDEX ON bug(creation);
135 CREATE INDEX ON bug(log_modified);
136 CREATE INDEX ON bug(done);
137 CREATE INDEX ON bug(owner);
138 CREATE INDEX ON bug(submitter);
139 CREATE INDEX ON bug(forwarded);
143 CREATE TABLE bug_blocks (
144 id SERIAL PRIMARY KEY,
145 bug INT NOT NULL REFERENCES bug,
146 blocks INT NOT NULL REFERENCES bug,
147 CONSTRAINT bug_doesnt_block_itself CHECK (bug <> blocks)
149 CREATE UNIQUE INDEX bug_blocks_bug_id_blocks_idx ON bug_blocks(bug,blocks);
150 CREATE INDEX bug_blocks_bug_id_idx ON bug_blocks(bug);
151 CREATE INDEX bug_blocks_blocks_idx ON bug_blocks(blocks);
152 INSERT INTO table_comments VALUES ('bug_blocks','Bugs which block other bugs');
153 INSERT INTO column_comments VALUES ('bug_blocks','bug','Bug number');
154 INSERT INTO column_comments VALUES ('bug_blocks','blocks','Bug number which is blocked by bug');
157 CREATE TABLE bug_merged (
158 id SERIAL PRIMARY KEY,
159 bug INT NOT NULL REFERENCES bug,
160 merged INT NOT NULL REFERENCES bug,
161 CONSTRAINT bug_doesnt_merged_itself CHECK (bug <> merged)
163 CREATE UNIQUE INDEX bug_merged_bug_id_merged_idx ON bug_merged(bug,merged);
164 CREATE INDEX bug_merged_bug_id_idx ON bug_merged(bug);
165 CREATE INDEX bug_merged_merged_idx ON bug_merged(merged);
166 INSERT INTO table_comments VALUES ('bug_merged','Bugs which are merged with other bugs');
167 INSERT INTO column_comments VALUES ('bug_merged','bug','Bug number');
168 INSERT INTO column_comments VALUES ('bug_merged','merged','Bug number which is merged with bug');
170 CREATE TABLE src_pkg (
171 id SERIAL PRIMARY KEY,
173 pseduopkg BOOLEAN DEFAULT FALSE,
174 alias_of INT REFERENCES src_pkg ON UPDATE CASCADE ON DELETE CASCADE,
175 creation TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
176 disabled TIMESTAMP WITH TIME ZONE DEFAULT NULL,
177 last_modified TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
178 obsolete BOOLEAN DEFAULT FALSE,
179 CONSTRAINT src_pkg_doesnt_alias_itself CHECK (id <> alias_of),
180 CONSTRAINT src_pkg_is_obsolete_if_disabled CHECK ((obsolete IS FALSE AND disabled IS NULL) OR (obsolete IS TRUE AND disabled IS NOT NULL))
182 CREATE INDEX src_pkg_pkg ON src_pkg(pkg);
183 CREATE UNIQUE INDEX src_pkg_pkg_disabled ON src_pkg(pkg,disabled);
184 INSERT INTO table_comments VALUES ('src_pkg','Source packages');
185 INSERT INTO column_comments VALUES ('src_pkg','id','Source package id');
186 INSERT INTO column_comments VALUES ('src_pkg','pkg','Source package name');
187 INSERT INTO column_comments VALUES ('src_pkg','pseudopkg','True if this is a pseudo package');
188 INSERT INTO column_comments VALUES ('src_pkg','alias_of','Source package id which this source package is an alias of');
192 CREATE TABLE src_ver (
193 id SERIAL PRIMARY KEY,
194 src_pkg INT NOT NULL REFERENCES src_pkg
195 ON UPDATE CASCADE ON DELETE CASCADE,
196 ver public.debversion NOT NULL,
197 maintainer INT REFERENCES maintainer
198 ON UPDATE CASCADE ON DELETE SET NULL,
199 upload_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
200 based_on INT REFERENCES src_ver
201 ON UPDATE CASCADE ON DELETE CASCADE
203 CREATE UNIQUE INDEX src_ver_src_pkg_id_ver ON src_ver(src_pkg,ver);
204 INSERT INTO table_comments VALUES ('src_ver','Source Package versions');
205 INSERT INTO column_comments VALUES ('src_ver','id','Source package version id');
206 INSERT INTO column_comments VALUES ('src_ver','src_pkg','Source package id (matches src_pkg table)');
207 INSERT INTO column_comments VALUES ('src_ver','ver','Version of the source package');
208 INSERT INTO column_comments VALUES ('src_ver','maintainer','Maintainer id (matches maintainer table)');
209 INSERT INTO column_comments VALUES ('src_ver','upload_date','Date this version of the source package was uploaded');
210 INSERT INTO column_comments VALUES ('src_ver','based_on','Source package version this version is based on');
214 CREATE TABLE bug_ver (
215 id SERIAL PRIMARY KEY,
216 bug INT NOT NULL REFERENCES bug
217 ON UPDATE CASCADE ON DELETE RESTRICT,
219 src_pkg INT REFERENCES src_pkg
220 ON UPDATE CASCADE ON DELETE SET NULL,
221 src_ver INT REFERENCES src_ver
222 ON UPDATE CASCADE ON DELETE SET NULL,
223 found BOOLEAN NOT NULL DEFAULT TRUE,
224 creation TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
225 last_modified TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
227 CREATE INDEX bug_ver_src_pkg_id_idx ON bug_ver(src_pkg);
228 CREATE INDEX bug_ver_src_pkg_id_src_ver_id_idx ON bug_ver(src_pkg,src_ver);
229 CREATE INDEX bug_ver_src_ver_id_idx ON bug_ver(src_ver);
230 CREATE UNIQUE INDEX ON bug_ver(bug,ver_string,found);
231 INSERT INTO table_comments VALUES ('bug_ver','Bug versions');
232 INSERT INTO column_comments VALUES ('bug_ver','id','Bug version id');
233 INSERT INTO column_comments VALUES ('bug_ver','bug','Bug number');
234 INSERT INTO column_comments VALUES ('bug_ver','ver_string','Version string');
235 INSERT INTO column_comments VALUES ('bug_ver','src_pkg','Source package id (matches src_pkg table)');
236 INSERT INTO column_comments VALUES ('bug_ver','src_ver','Source package version id (matches src_ver table)');
237 INSERT INTO column_comments VALUES ('bug_ver','found','True if this is a found version; false if this is a fixed version');
238 INSERT INTO column_comments VALUES ('bug_ver','creation','Time that this entry was created');
239 INSERT INTO column_comments VALUES ('bug_ver','last_modified','Time that this entry was modified');
243 id SERIAL PRIMARY KEY,
244 arch TEXT NOT NULL UNIQUE
246 INSERT INTO table_comments VALUES ('arch','Architectures');
247 INSERT INTO column_comments VALUES ('arch','id','Architecture id');
248 INSERT INTO column_comments VALUES ('arch','arch','Architecture name');
251 CREATE TABLE bin_pkg (
252 id SERIAL PRIMARY KEY,
253 pkg TEXT NOT NULL UNIQUE
255 INSERT INTO table_comments VALUES ('bin_pkg','Binary packages');
256 INSERT INTO column_comments VALUES ('bin_pkg','id','Binary package id');
257 INSERT INTO column_comments VALUES ('bin_pkg','pkg','Binary package name');
260 CREATE TABLE bin_ver(
261 id SERIAL PRIMARY KEY,
262 bin_pkg INT NOT NULL REFERENCES bin_pkg
263 ON UPDATE CASCADE ON DELETE CASCADE,
264 src_ver INT NOT NULL REFERENCES src_ver
265 ON UPDATE CASCADE ON DELETE CASCADE,
266 arch INT NOT NULL REFERENCES arch
267 ON UPDATE CASCADE ON DELETE CASCADE,
268 ver public.debversion NOT NULL
270 CREATE INDEX bin_ver_ver_idx ON bin_ver(ver);
271 CREATE UNIQUE INDEX bin_ver_bin_pkg_id_arch_idx ON bin_ver(bin_pkg,arch_id,ver);
272 CREATE UNIQUE INDEX bin_ver_src_ver_id_arch_idx ON bin_ver(src_ver_id,arch);
273 CREATE INDEX bin_ver_bin_pkg_id_idx ON bin_ver(bin_pkg);
274 CREATE INDEX bin_ver_src_ver_id_idx ON bin_ver(src_ver);
275 INSERT INTO table_comments VALUES ('bin_ver','Binary versions');
276 INSERT INTO column_comments VALUES ('bin_ver','id','Binary version id');
277 INSERT INTO column_comments VALUES ('bin_ver','bin_pkg','Binary package id (matches bin_pkg)');
278 INSERT INTO column_comments VALUES ('bin_ver','src_ver','Source version (matchines src_ver)');
279 INSERT INTO column_comments VALUES ('bin_ver','arch','Architecture id (matches arch)');
280 INSERT INTO column_comments VALUES ('bin_ver','ver','Binary version');
283 id SERIAL PRIMARY KEY,
284 tag TEXT NOT NULL UNIQUE,
285 obsolete BOOLEAN DEFAULT FALSE
287 INSERT INTO table_comments VALUES ('tag','Bug tags');
288 INSERT INTO column_comments VALUES ('tag','id','Tag id');
289 INSERT INTO column_comments VALUES ('tag','tag','Tag name');
290 INSERT INTO column_comments VALUES ('tag','obsolete','Whether a tag is obsolete (should not be set on new bugs)');
292 CREATE TABLE bug_tag (
293 id SERIAL PRIMARY KEY,
294 bug INT NOT NULL REFERENCES bug,
295 tag INT NOT NULL REFERENCES tag
297 INSERT INTO table_comments VALUES ('bug_tag','Bug <-> tag mapping');
298 INSERT INTO column_comments VALUES ('bug_tag','bug','Bug id (matches bug)');
299 INSERT INTO column_comments VALUES ('bug_tag','tag','Tag id (matches tag)');
301 CREATE UNIQUE INDEX bug_tag_bug_tag ON bug_tag (bug,tag);
302 CREATE INDEX bug_tag_tag ON bug_tag (tag);
303 CREATE INDEX bug_tag_bug ON bug_tag (bug);
307 CREATE TABLE bug_binpackage (
308 id SERIAL PRIMARY KEY,
309 bug INT NOT NULL REFERENCES bug,
310 bin_pkg INT NOT NULL REFERENCES bin_pkg ON UPDATE CASCADE ON DELETE CASCADE
312 CREATE UNIQUE INDEX bug_binpackage_id_pkg ON bug_binpackage(bug,bin_pkg);
313 INSERT INTO table_comments VALUES ('bug_binpackage','Bug <-> binary package mapping');
314 INSERT INTO column_comments VALUES ('bug_binpackage','bug','Bug id (matches bug)');
315 INSERT INTO column_comments VALUES ('bug_binpackage','bin_pkg','Binary package id (matches bin_pkg)');
317 CREATE TABLE bug_srcpackage (
318 id SERIAL PRIMARY KEY,
319 bug INT NOT NULL REFERENCES bug,
320 src_pkg INT NOT NULL REFERENCES src_pkg ON UPDATE CASCADE ON DELETE CASCADE
322 CREATE UNIQUE INDEX bug_srcpackage_id_pkg ON bug_srcpackage(bug,src_pkg);
323 INSERT INTO table_comments VALUES ('bug_srcpackage','Bug <-> source package mapping');
324 INSERT INTO column_comments VALUES ('bug_srcpackage','bug','Bug id (matches bug)');
325 INSERT INTO column_comments VALUES ('bug_srcpackage','src_pkg','Source package id (matches src_pkg)');
327 CREATE VIEW bug_package (bug,pkg_id,pkg_type,package) AS
328 SELECT b.bug,b.bin_pkg,'binary',bp.pkg FROM bug_binpackage b JOIN bin_pkg bp ON bp.id=b.bin_pkg UNION
329 SELECT s.bug,s.src_pkg,'source',sp.pkg FROM bug_srcpackage s JOIN src_pkg sp ON sp.id=s.src_pkg;
331 CREATE TABLE bug_affects_binpackage (
332 id SERIAL PRIMARY KEY,
333 bug INT NOT NULL REFERENCES bug,
334 bin_pkg INT NOT NULL REFERENCES bin_pkg ON UPDATE CASCADE ON DELETE CASCADE
336 CREATE UNIQUE INDEX bug_affects_binpackage_id_pkg ON bug_affects_binpackage(bug,bin_pkg);
337 INSERT INTO table_comments VALUES ('bug_affects_binpackage','Bug <-> binary package mapping');
338 INSERT INTO column_comments VALUES ('bug_affects_binpackage','bug','Bug id (matches bug)');
339 INSERT INTO column_comments VALUES ('bug_affects_binpackage','bin_pkg','Binary package id (matches bin_pkg)');
341 CREATE TABLE bug_affects_srcpackage (
342 id SERIAL PRIMARY KEY,
343 bug INT NOT NULL REFERENCES bug,
344 src_pkg INT NOT NULL REFERENCES src_pkg ON UPDATE CASCADE ON DELETE CASCADE
346 CREATE UNIQUE INDEX bug_affects_srcpackage_id_pkg ON bug_affects_srcpackage(bug,src_pkg);
347 INSERT INTO table_comments VALUES ('bug_affects_srcpackage','Bug <-> source package mapping');
348 INSERT INTO column_comments VALUES ('bug_affects_srcpackage','bug','Bug id (matches bug)');
349 INSERT INTO column_comments VALUES ('bug_affects_srcpackage','src_pkg','Source package id (matches src_pkg)');
351 CREATE VIEW binary_versions (src_pkg, src_ver, bin_pkg, arch, bin_ver) AS
352 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,
353 svb.ver AS src_ver_based_on, spb.pkg AS src_pkg_based_on
354 FROM bin_ver b JOIN arch a ON b.arch = a.id
355 JOIN bin_pkg bp ON b.bin_pkg = bp.id
356 JOIN src_ver sv ON b.src_ver = sv.id
357 JOIN src_pkg sp ON sv.src_pkg = sp.id
358 LEFT OUTER JOIN src_ver svb ON sv.based_on = svb.id
359 LEFT OUTER JOIN src_pkg spb ON spb.id = svb.src_pkg;
362 id SERIAL PRIMARY KEY,
363 suite_name TEXT NOT NULL UNIQUE,
366 active BOOLEAN DEFAULT TRUE);
367 CREATE INDEX ON suite(codename);
368 CREATE INDEX ON suite(version);
369 INSERT INTO table_comments VALUES ('suite','Debian Release Suite (stable, testing, etc.)');
370 INSERT INTO column_comments VALUES ('suite','id','Suite id');
371 INSERT INTO column_comments VALUES ('suite','suite_name','Suite name');
372 INSERT INTO column_comments VALUES ('suite','version','Suite version; NULL if there is no appropriate version');
373 INSERT INTO column_comments VALUES ('suite','codename','Suite codename');
374 INSERT INTO column_comments VALUES ('suite','active','TRUE if the suite is still accepting uploads');
376 CREATE TABLE bin_associations (
377 id SERIAL PRIMARY KEY,
378 suite INT NOT NULL REFERENCES suite ON DELETE CASCADE ON UPDATE CASCADE,
379 bin INT NOT NULL REFERENCES bin_ver ON DELETE CASCADE ON UPDATE CASCADE,
380 created TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
381 modified TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL
383 INSERT INTO table_comments VALUES ('bin_associations','Binary <-> suite associations');
384 INSERT INTO column_comments VALUES ('bin_associations','id','Binary <-> suite association id');
385 INSERT INTO column_comments VALUES ('bin_associations','suite','Suite id (matches suite)');
386 INSERT INTO column_comments VALUES ('bin_associations','bin','Binary version id (matches bin_ver)');
387 INSERT INTO column_comments VALUES ('bin_associations','created','Time this binary package entered this suite');
388 INSERT INTO column_comments VALUES ('bin_associations','modified','Time this entry was modified');
390 CREATE TABLE src_associations (
391 id SERIAL PRIMARY KEY,
392 suite INT NOT NULL REFERENCES suite ON DELETE CASCADE ON UPDATE CASCADE,
393 source INT NOT NULL REFERENCES src_ver ON DELETE CASCADE ON UPDATE CASCADE,
394 created TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
395 modified TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL
397 INSERT INTO table_comments VALUES ('src_associations','Source <-> suite associations');
398 INSERT INTO column_comments VALUES ('src_associations','id','Source <-> suite association id');
399 INSERT INTO column_comments VALUES ('src_associations','suite','Suite id (matches suite)');
400 INSERT INTO column_comments VALUES ('src_associations','source','Source version id (matches src_ver)');
401 INSERT INTO column_comments VALUES ('src_associations','created','Time this source package entered this suite');
402 INSERT INTO column_comments VALUES ('src_associations','modified','Time this entry was modified');
406 CREATE TYPE bug_status_type AS ENUM ('pending','forwarded','pending-fixed','fixed','absent','done');
407 CREATE TABLE bug_status_cache (
408 id SERIAL PRIMARY KEY,
409 bug INT NOT NULL REFERENCES bug ON DELETE CASCADE ON UPDATE CASCADE,
410 suite INT REFERENCES suite ON DELETE CASCADE ON UPDATE CASCADE,
411 arch INT REFERENCES arch ON DELETE CASCADE ON UPDATE CASCADE,
412 status bug_status_type NOT NULL,
413 modified TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
414 asof TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL
416 CREATE UNIQUE INDEX ON bug_status_cache(bug,suite,arch);
417 CREATE INDEX ON bug_status_cache(bug);
418 CREATE INDEX ON bug_status_cache(status);
419 INSERT INTO table_comments VALUES ('bug_status_cache','Source <-> suite associations');
420 INSERT INTO column_comments VALUES ('bug_status_cache','id','Source <-> suite association id');
421 INSERT INTO column_comments VALUES ('bug_status_cache','bug','Source <-> suite association id');
422 INSERT INTO column_comments VALUES ('bug_status_cache','suite','Source <-> suite association id');
423 INSERT INTO column_comments VALUES ('bug_status_cache','arch','Source <-> suite association id');
424 INSERT INTO column_comments VALUES ('bug_status_cache','status','Source <-> suite association id');
425 INSERT INTO column_comments VALUES ('bug_status_cache','modified','Source <-> suite association id');
426 INSERT INTO column_comments VALUES ('bug_status_cache','asof','Source <-> suite association id');
430 CREATE TABLE message (
431 id SERIAL PRIMARY KEY,
437 subject TEXT NOT NULL DEFAULT '',
438 sent_date TIMESTAMP WITH TIME ZONE,
439 refs TEXT NOT NULL DEFAULT '',
441 is_spam BOOLEAN DEFAULT FALSE
443 INSERT INTO table_comments VALUES ('message','Messages sent to bugs');
444 INSERT INTO column_comments VALUES ('message','id','Message id');
445 INSERT INTO column_comments VALUES ('message','msgid','Message id header');
446 INSERT INTO column_comments VALUES ('message','from_complete','Complete from header of message');
447 INSERT INTO column_comments VALUES ('message','from_addr','Address(es) of From: headers');
448 INSERT INTO column_comments VALUES ('message','to_complete','Complete to header of message');
449 INSERT INTO column_comments VALUES ('message','to_addr','Address(es) of To: header');
450 INSERT INTO column_comments VALUES ('message','subject','Subject of the message');
451 INSERT INTO column_comments VALUES ('message','sent_date','Time/date message was sent (from Date header)');
452 INSERT INTO column_comments VALUES ('message','refs','Contents of References: header');
453 INSERT INTO column_comments VALUES ('message','spam_score','Spam score from spamassassin');
454 INSERT INTO column_comments VALUES ('message','is_spam','True if this message was spam and should not be shown');
455 CREATE INDEX ON message(msgid);
457 CREATE TABLE message_refs (
458 id SERIAL PRIMARY KEY,
459 message INT NOT NULL REFERENCES message ON DELETE CASCADE ON UPDATE CASCADE,
460 refs INT NOT NULL REFERENCES message ON DELETE CASCADE ON UPDATE CASCADE,
461 inferred BOOLEAN DEFAULT FALSE,
462 primary_ref BOOLEAN DEFAULT FALSE,
463 CONSTRAINT message_doesnt_reference_itself CHECK (message <> refs)
465 CREATE UNIQUE INDEX ON message_refs(message,refs);
466 CREATE INDEX ON message_refs(refs);
467 CREATE INDEX ON message_refs(message);
468 INSERT INTO table_comments VALUES ('message_refs','Message references');
469 INSERT INTO column_comments VALUES ('message_refs','message','Message id (matches message)');
470 INSERT INTO column_comments VALUES ('message_refs','refs','Reference id (matches message)');
471 INSERT INTO column_comments VALUES ('message_refs','inferred','TRUE if this message reference was reconstructed; primarily of use for messages which lack In-Reply-To: or References: headers');
472 INSERT INTO column_comments VALUES ('message_refs','primary_ref','TRUE if this message->ref came from In-Reply-To: or similar.');
476 CREATE TABLE correspondent_full_name(
477 id SERIAL PRIMARY KEY,
478 correspondent INT NOT NULL REFERENCES correspondent ON DELETE CASCADE ON UPDATE CASCADE,
479 full_name TEXT NOT NULL,
480 last_seen TIMESTAMP NOT NULL DEFAULT NOW()
482 CREATE UNIQUE INDEX ON correspondent_full_name(correspondent,full_name);
483 CREATE INDEX ON correspondent_full_name(full_name);
484 CREATE INDEX ON correspondent_full_name(last_seen);
485 INSERT INTO table_comments VALUES ('correspondent_full_name','Full names of BTS correspondents');
486 INSERT INTO column_comments VALUES ('correspondent_full_name','id','Correspondent full name id');
487 INSERT INTO column_comments VALUES ('correspondent_full_name','correpsondent','Correspondent ID (matches correspondent)');
488 INSERT INTO column_comments VALUES ('correspondent_full_name','full_name','Correspondent full name (includes e-mail address)');
490 CREATE TYPE message_correspondent_type AS ENUM ('to','from','envfrom','cc');
492 CREATE TABLE message_correspondent (
493 id SERIAL PRIMARY KEY,
494 message INT NOT NULL REFERENCES message ON DELETE CASCADE ON UPDATE CASCADE,
495 correspondent INT NOT NULL REFERENCES correspondent ON DELETE CASCADE ON UPDATE CASCADE,
496 correspondent_type message_correspondent_type NOT NULL DEFAULT 'to'
498 INSERT INTO table_comments VALUES ('message_correspondent','Linkage between correspondent and message');
499 INSERT INTO column_comments VALUES ('message_correspondent','message','Message id (matches message)');
500 INSERT INTO column_comments VALUES ('message_correspondent','correspondent','Correspondent (matches correspondent)');
501 INSERT INTO column_comments VALUES ('message_correspondent','correspondent_type','Type of correspondent (to, from, envfrom, cc, etc.)');
503 CREATE UNIQUE INDEX ON message_correspondent(message,correspondent,correspondent_type);
504 CREATE INDEX ON message_correspondent(correspondent);
505 CREATE INDEX ON message_correspondent(message);
507 CREATE TABLE bug_message (
508 id SERIAL PRIMARY KEY,
509 bug INT NOT NULL REFERENCES bug ON DELETE CASCADE ON UPDATE CASCADE,
510 message INT NOT NULL REFERENCES message ON DELETE CASCADE ON UPDATE CASCADE,
511 message_number INT NOT NULL,
513 offset_valid TIMESTAMP WITH TIME ZONE
515 CREATE UNIQUE INDEX ON bug_message(bug,message);
516 CREATE INDEX ON bug_message(bug,message_number);
517 INSERT INTO table_comments VALUES ('bug_mesage','Mapping between a bug and a message');
518 INSERT INTO column_comments VALUES ('bug_message','bug','Bug id (matches bug)');
519 INSERT INTO column_comments VALUES ('bug_message','message','Message id (matches message)');
520 INSERT INTO column_comments VALUES ('bug_message','message_number','Message number in the bug log');
521 INSERT INTO column_comments VALUES ('bug_message','bug_log_offset','Byte offset in the bug log');
522 INSERT INTO column_comments VALUES ('bug_message','offset_valid','Time offset was valid');