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 bug INT NOT NULL REFERENCES bug
216 ON UPDATE CASCADE ON DELETE RESTRICT,
218 src_pkg INT REFERENCES src_pkg
219 ON UPDATE CASCADE ON DELETE SET NULL,
220 src_ver INT REFERENCES src_ver
221 ON UPDATE CASCADE ON DELETE SET NULL,
222 found BOOLEAN NOT NULL DEFAULT TRUE,
223 creation TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
224 last_modified TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
226 CREATE INDEX bug_ver_src_pkg_id_idx ON bug_ver(src_pkg);
227 CREATE INDEX bug_ver_src_pkg_id_src_ver_id_idx ON bug_ver(src_pkg,src_ver);
228 CREATE INDEX bug_ver_src_ver_id_idx ON bug_ver(src_ver);
229 CREATE UNIQUE INDEX ON bug_ver(bug,ver_string,found);
230 INSERT INTO table_comments VALUES ('bug_ver','Bug versions');
231 INSERT INTO column_comments VALUES ('bug_ver','bug','Bug number');
232 INSERT INTO column_comments VALUES ('bug_ver','ver_string','Version string');
233 INSERT INTO column_comments VALUES ('bug_ver','src_pkg','Source package id (matches src_pkg table)');
234 INSERT INTO column_comments VALUES ('bug_ver','src_ver','Source package version id (matches src_ver table)');
235 INSERT INTO column_comments VALUES ('bug_ver','found','True if this is a found version; false if this is a fixed version');
236 INSERT INTO column_comments VALUES ('bug_ver','creation','Time that this entry was created');
237 INSERT INTO column_comments VALUES ('bug_ver','last_modified','Time that this entry was modified');
241 id SERIAL PRIMARY KEY,
242 arch TEXT NOT NULL UNIQUE
244 INSERT INTO table_comments VALUES ('arch','Architectures');
245 INSERT INTO column_comments VALUES ('arch','id','Architecture id');
246 INSERT INTO column_comments VALUES ('arch','arch','Architecture name');
249 CREATE TABLE bin_pkg (
250 id SERIAL PRIMARY KEY,
251 pkg TEXT NOT NULL UNIQUE
253 INSERT INTO table_comments VALUES ('bin_pkg','Binary packages');
254 INSERT INTO column_comments VALUES ('bin_pkg','id','Binary package id');
255 INSERT INTO column_comments VALUES ('bin_pkg','pkg','Binary package name');
258 CREATE TABLE bin_ver(
259 id SERIAL PRIMARY KEY,
260 bin_pkg INT NOT NULL REFERENCES bin_pkg
261 ON UPDATE CASCADE ON DELETE CASCADE,
262 src_ver INT NOT NULL REFERENCES src_ver
263 ON UPDATE CASCADE ON DELETE CASCADE,
264 arch INT NOT NULL REFERENCES arch
265 ON UPDATE CASCADE ON DELETE CASCADE,
266 ver public.debversion NOT NULL
268 CREATE INDEX bin_ver_ver_idx ON bin_ver(ver);
269 CREATE UNIQUE INDEX bin_ver_bin_pkg_id_arch_idx ON bin_ver(bin_pkg,arch_id,ver);
270 CREATE UNIQUE INDEX bin_ver_src_ver_id_arch_idx ON bin_ver(src_ver_id,arch);
271 CREATE INDEX bin_ver_bin_pkg_id_idx ON bin_ver(bin_pkg);
272 CREATE INDEX bin_ver_src_ver_id_idx ON bin_ver(src_ver);
273 INSERT INTO table_comments VALUES ('bin_ver','Binary versions');
274 INSERT INTO column_comments VALUES ('bin_ver','id','Binary version id');
275 INSERT INTO column_comments VALUES ('bin_ver','bin_pkg','Binary package id (matches bin_pkg)');
276 INSERT INTO column_comments VALUES ('bin_ver','src_ver','Source version (matchines src_ver)');
277 INSERT INTO column_comments VALUES ('bin_ver','arch','Architecture id (matches arch)');
278 INSERT INTO column_comments VALUES ('bin_ver','ver','Binary version');
281 id SERIAL PRIMARY KEY,
282 tag TEXT NOT NULL UNIQUE,
283 obsolete BOOLEAN DEFAULT FALSE
285 INSERT INTO table_comments VALUES ('tag','Bug tags');
286 INSERT INTO column_comments VALUES ('tag','id','Tag id');
287 INSERT INTO column_comments VALUES ('tag','tag','Tag name');
288 INSERT INTO column_comments VALUES ('tag','obsolete','Whether a tag is obsolete (should not be set on new bugs)');
290 CREATE TABLE bug_tag (
291 id SERIAL PRIMARY KEY,
292 bug INT NOT NULL REFERENCES bug,
293 tag INT NOT NULL REFERENCES tag
295 INSERT INTO table_comments VALUES ('bug_tag','Bug <-> tag mapping');
296 INSERT INTO column_comments VALUES ('bug_tag','bug','Bug id (matches bug)');
297 INSERT INTO column_comments VALUES ('bug_tag','tag','Tag id (matches tag)');
299 CREATE UNIQUE INDEX bug_tag_bug_tag ON bug_tag (bug,tag);
300 CREATE INDEX bug_tag_tag ON bug_tag (tag);
301 CREATE INDEX bug_tag_bug ON bug_tag (bug);
305 CREATE TABLE bug_binpackage (
306 id SERIAL PRIMARY KEY,
307 bug INT NOT NULL REFERENCES bug,
308 bin_pkg INT NOT NULL REFERENCES bin_pkg
310 CREATE UNIQUE INDEX bug_binpackage_id_pkg ON bug_binpackage(bug,bin_pkg);
311 INSERT INTO table_comments VALUES ('bug_binpackage','Bug <-> binary package mapping');
312 INSERT INTO column_comments VALUES ('bug_binpackage','bug','Bug id (matches bug)');
313 INSERT INTO column_comments VALUES ('bug_binpackage','bin_pkg','Binary package id (matches bin_pkg)');
315 CREATE TABLE bug_srcpackage (
316 id SERIAL PRIMARY KEY,
317 bug INT NOT NULL REFERENCES bug,
318 src_pkg INT NOT NULL REFERENCES src_pkg ON UPDATE CASCADE ON DELETE CASCADE
320 CREATE UNIQUE INDEX bug_srcpackage_id_pkg ON bug_srcpackage(bug,src_pkg);
321 INSERT INTO table_comments VALUES ('bug_srcpackage','Bug <-> source package mapping');
322 INSERT INTO column_comments VALUES ('bug_srcpackage','bug','Bug id (matches bug)');
323 INSERT INTO column_comments VALUES ('bug_srcpackage','src_pkg','Source package id (matches src_pkg)');
325 CREATE VIEW bug_package (bug,pkg_id,pkg_type,package) AS
326 SELECT b.bug,b.bin_pkg,'binary',bp.pkg FROM bug_binpackage b JOIN bin_pkg bp ON bp.id=b.bin_pkg UNION
327 SELECT s.bug,s.src_pkg,'source',sp.pkg FROM bug_srcpackage s JOIN src_pkg sp ON sp.id=s.src_pkg;
329 CREATE VIEW binary_versions (src_pkg, src_ver, bin_pkg, arch, bin_ver) AS
330 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,
331 svb.ver AS src_ver_based_on, spb.pkg AS src_pkg_based_on
332 FROM bin_ver b JOIN arch a ON b.arch = a.id
333 JOIN bin_pkg bp ON b.bin_pkg = bp.id
334 JOIN src_ver sv ON b.src_ver = sv.id
335 JOIN src_pkg sp ON sv.src_pkg = sp.id
336 LEFT OUTER JOIN src_ver svb ON sv.based_on = svb.id
337 LEFT OUTER JOIN src_pkg spb ON spb.id = svb.src_pkg;
340 id SERIAL PRIMARY KEY,
341 suite_name TEXT NOT NULL UNIQUE,
344 active BOOLEAN DEFAULT TRUE);
345 CREATE INDEX ON suite(codename);
346 CREATE INDEX ON suite(version);
347 INSERT INTO table_comments VALUES ('suite','Debian Release Suite (stable, testing, etc.)');
348 INSERT INTO column_comments VALUES ('suite','id','Suite id');
349 INSERT INTO column_comments VALUES ('suite','suite_name','Suite name');
350 INSERT INTO column_comments VALUES ('suite','version','Suite version; NULL if there is no appropriate version');
351 INSERT INTO column_comments VALUES ('suite','codename','Suite codename');
352 INSERT INTO column_comments VALUES ('suite','active','TRUE if the suite is still accepting uploads');
354 CREATE TABLE bin_associations (
355 id SERIAL PRIMARY KEY,
356 suite INT NOT NULL REFERENCES suite ON DELETE CASCADE ON UPDATE CASCADE,
357 bin INT NOT NULL REFERENCES bin_ver ON DELETE CASCADE ON UPDATE CASCADE,
358 created TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
359 modified TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL
361 INSERT INTO table_comments VALUES ('bin_associations','Binary <-> suite associations');
362 INSERT INTO column_comments VALUES ('bin_associations','id','Binary <-> suite association id');
363 INSERT INTO column_comments VALUES ('bin_associations','suite','Suite id (matches suite)');
364 INSERT INTO column_comments VALUES ('bin_associations','bin','Binary version id (matches bin_ver)');
365 INSERT INTO column_comments VALUES ('bin_associations','created','Time this binary package entered this suite');
366 INSERT INTO column_comments VALUES ('bin_associations','modified','Time this entry was modified');
368 CREATE TABLE src_associations (
369 id SERIAL PRIMARY KEY,
370 suite INT NOT NULL REFERENCES suite ON DELETE CASCADE ON UPDATE CASCADE,
371 source INT NOT NULL REFERENCES src_ver ON DELETE CASCADE ON UPDATE CASCADE,
372 created TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
373 modified TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL
375 INSERT INTO table_comments VALUES ('src_associations','Source <-> suite associations');
376 INSERT INTO column_comments VALUES ('src_associations','id','Source <-> suite association id');
377 INSERT INTO column_comments VALUES ('src_associations','suite','Suite id (matches suite)');
378 INSERT INTO column_comments VALUES ('src_associations','source','Source version id (matches src_ver)');
379 INSERT INTO column_comments VALUES ('src_associations','created','Time this source package entered this suite');
380 INSERT INTO column_comments VALUES ('src_associations','modified','Time this entry was modified');
384 CREATE TYPE bug_status_type AS ENUM ('pending','forwarded','pending-fixed','fixed','absent','done');
385 CREATE TABLE bug_status_cache (
386 id SERIAL PRIMARY KEY,
387 bug INT NOT NULL REFERENCES bug ON DELETE CASCADE ON UPDATE CASCADE,
388 suite INT REFERENCES suite ON DELETE CASCADE ON UPDATE CASCADE,
389 arch INT REFERENCES arch ON DELETE CASCADE ON UPDATE CASCADE,
390 status bug_status_type NOT NULL,
391 modified TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
392 asof TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL
394 CREATE UNIQUE INDEX ON bug_status_cache(bug,suite,arch);
395 CREATE INDEX ON bug_status_cache(bug);
396 CREATE INDEX ON bug_status_cache(status);
397 INSERT INTO table_comments VALUES ('bug_status_cache','Source <-> suite associations');
398 INSERT INTO column_comments VALUES ('bug_status_cache','id','Source <-> suite association id');
399 INSERT INTO column_comments VALUES ('bug_status_cache','bug','Source <-> suite association id');
400 INSERT INTO column_comments VALUES ('bug_status_cache','suite','Source <-> suite association id');
401 INSERT INTO column_comments VALUES ('bug_status_cache','arch','Source <-> suite association id');
402 INSERT INTO column_comments VALUES ('bug_status_cache','status','Source <-> suite association id');
403 INSERT INTO column_comments VALUES ('bug_status_cache','modified','Source <-> suite association id');
404 INSERT INTO column_comments VALUES ('bug_status_cache','asof','Source <-> suite association id');
408 CREATE TABLE message (
409 id SERIAL PRIMARY KEY,
415 subject TEXT NOT NULL DEFAULT '',
416 sent_date TIMESTAMP WITH TIME ZONE,
417 refs TEXT NOT NULL DEFAULT '',
419 is_spam BOOLEAN DEFAULT FALSE
421 INSERT INTO table_comments VALUES ('message','Messages sent to bugs');
422 INSERT INTO column_comments VALUES ('message','id','Message id');
423 INSERT INTO column_comments VALUES ('message','msgid','Message id header');
424 INSERT INTO column_comments VALUES ('message','from_complete','Complete from header of message');
425 INSERT INTO column_comments VALUES ('message','from_addr','Address(es) of From: headers');
426 INSERT INTO column_comments VALUES ('message','to_complete','Complete to header of message');
427 INSERT INTO column_comments VALUES ('message','to_addr','Address(es) of To: header');
428 INSERT INTO column_comments VALUES ('message','subject','Subject of the message');
429 INSERT INTO column_comments VALUES ('message','sent_date','Time/date message was sent (from Date header)');
430 INSERT INTO column_comments VALUES ('message','refs','Contents of References: header');
431 INSERT INTO column_comments VALUES ('message','spam_score','Spam score from spamassassin');
432 INSERT INTO column_comments VALUES ('message','is_spam','True if this message was spam and should not be shown');
434 CREATE INDEX ON message(msgid);
436 CREATE TABLE message_refs (
437 id SERIAL PRIMARY KEY,
438 message INT NOT NULL REFERENCES message ON DELETE CASCADE ON UPDATE CASCADE,
439 refs INT NOT NULL REFERENCES message ON DELETE CASCADE ON UPDATE CASCADE,
440 inferred BOOLEAN DEFAULT FALSE,
441 primary_ref BOOLEAN DEFAULT FALSE,
442 CONSTRAINT message_doesnt_reference_itself CHECK (message <> refs)
444 CREATE UNIQUE INDEX ON message_refs(message,refs);
445 CREATE INDEX ON message_refs(refs);
446 CREATE INDEX ON message_refs(message);
447 INSERT INTO table_comments VALUES ('message_refs','Message references');
448 INSERT INTO column_comments VALUES ('message_refs','message','Message id (matches message)');
449 INSERT INTO column_comments VALUES ('message_refs','refs','Reference id (matches message)');
450 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');
451 INSERT INTO column_comments VALUES ('message_refs','primary_ref','TRUE if this message->ref came from In-Reply-To: or similar.');
455 CREATE TABLE correspondent_full_name(
456 id SERIAL PRIMARY KEY,
457 correspondent INT NOT NULL REFERENCES correspondent ON DELETE CASCADE ON UPDATE CASCADE,
458 full_name TEXT NOT NULL,
459 last_seen TIMESTAMP NOT NULL DEFAULT NOW()
461 CREATE UNIQUE INDEX ON correspondent_full_name(correspondent,full_name);
462 CREATE INDEX ON correspondent_full_name(full_name);
463 CREATE INDEX ON correspondent_full_name(last_seen);
464 INSERT INTO table_comments VALUES ('correspondent_full_name','Full names of BTS correspondents');
465 INSERT INTO column_comments VALUES ('correspondent_full_name','id','Correspondent full name id');
466 INSERT INTO column_comments VALUES ('correspondent_full_name','correpsondent','Correspondent ID (matches correspondent)');
467 INSERT INTO column_comments VALUES ('correspondent_full_name','full_name','Correspondent full name (includes e-mail address)');
469 CREATE TYPE message_correspondent_type AS ENUM ('to','from','envfrom','cc');
471 CREATE TABLE message_correspondent (
472 id SERIAL PRIMARY KEY,
473 message INT NOT NULL REFERENCES message ON DELETE CASCADE ON UPDATE CASCADE,
474 correspondent INT NOT NULL REFERENCES correspondent ON DELETE CASCADE ON UPDATE CASCADE,
475 correspondent_type message_correspondent_type NOT NULL DEFAULT 'to'
477 INSERT INTO table_comments VALUES ('message_correspondent','Linkage between correspondent and message');
478 INSERT INTO column_comments VALUES ('message_correspondent','message','Message id (matches message)');
479 INSERT INTO column_comments VALUES ('message_correspondent','correspondent','Correspondent (matches correspondent)');
480 INSERT INTO column_comments VALUES ('message_correspondent','correspondent_type','Type of correspondent (to, from, envfrom, cc, etc.)');
482 CREATE UNIQUE INDEX ON message_correspondent(message,correspondent,correspondent_type);
483 CREATE INDEX ON message_correspondent(correspondent);
484 CREATE INDEX ON message_correspondent(message);
486 CREATE TABLE bug_message (
487 id SERIAL PRIMARY KEY,
488 bug INT NOT NULL REFERENCES bug ON DELETE CASCADE ON UPDATE CASCADE,
489 message INT NOT NULL REFERENCES message ON DELETE CASCADE ON UPDATE CASCADE,
490 message_number INT NOT NULL,
492 offset_valid TIMESTAMP WITH TIME ZONE
494 INSERT INTO table_comments VALUES ('bug_mesage','Mapping between a bug and a message');
495 INSERT INTO column_comments VALUES ('bug_message','bug','Bug id (matches bug)');
496 INSERT INTO column_comments VALUES ('bug_message','message','Message id (matches message)');
497 INSERT INTO column_comments VALUES ('bug_message','message_number','Message number in the bug log');
498 INSERT INTO column_comments VALUES ('bug_message','bug_log_offset','Byte offset in the bug log');
499 INSERT INTO column_comments VALUES ('bug_message','offset_valid','Time offset was valid');