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,
50 addr TEXT NOT NULL UNIQUE
52 INSERT INTO table_comments VALUES ('correspondent','Individual who has corresponded with the BTS');
53 INSERT INTO column_comments VALUES ('correspondent','id','Correspondent ID');
54 INSERT INTO column_comments VALUES ('correspondent','addr','Correspondent address');
56 CREATE TABLE maintainer (
57 id SERIAL PRIMARY KEY,
58 name TEXT NOT NULL UNIQUE,
59 correspondent INT NOT NULL REFERENCES correspondent(id),
60 created TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
61 modified TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL
63 INSERT INTO table_comments VALUES ('maintainer','Package maintainer names');
64 INSERT INTO column_comments VALUES ('maintainer','id','Package maintainer id');
65 INSERT INTO column_comments VALUES ('maintainer','name','Name of package maintainer');
66 INSERT INTO column_comments VALUES ('maintainer','correspondent','Correspondent ID');
67 INSERT INTO column_comments VALUES ('maintainer','created','Time maintainer record created');
68 INSERT INTO column_comments VALUES ('maintainer','modified','Time maintainer record modified');
71 CREATE TABLE severity (
72 id SERIAL PRIMARY KEY,
73 severity TEXT NOT NULL UNIQUE,
74 ordering INT NOT NULL DEFAULT 5,
75 strong BOOLEAN DEFAULT FALSE,
76 obsolete BOOLEAN DEFAULT FALSE
78 INSERT INTO table_comments VALUES ('severity','Bug severity');
79 INSERT INTO column_comments VALUES ('severity','id','Severity id');
80 INSERT INTO column_comments VALUES ('severity','severity','Severity name');
81 INSERT INTO column_comments VALUES ('severity','ordering','Severity ordering (more severe severities have higher numbers)');
82 INSERT INTO column_comments VALUES ('severity','strong','True if severity is a strong severity');
83 INSERT INTO column_comments VALUES ('severity','obsolete','Whether a severity level is obsolete (should not be set on new bugs)');
87 id INTEGER NOT NULL PRIMARY KEY,
88 creation TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
89 log_modified TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
90 last_modified TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
91 archived BOOLEAN NOT NULL DEFAULT FALSE,
92 unarchived TIMESTAMP WITH TIME ZONE,
93 forwarded TEXT NOT NULL DEFAULT '',
94 summary TEXT NOT NULL DEFAULT '',
95 outlook TEXT NOT NULL DEFAULT '',
96 subject TEXT NOT NULL,
97 severity INT NOT NULL REFERENCES severity(id),
98 done INT REFERENCES correspondent(id),
99 done_full TEXT NOT NULL DEFAULT '',
100 owner INT REFERENCES correspondent(id),
101 owner_full TEXT NOT NULL DEFAULT '',
102 -- submitter would ideally be NOT NULL, but there are some ancient bugs which do not have submitters
103 submitter INT REFERENCES correspondent(id),
104 submitter_full TEXT NOT NULL DEFAULT '',
105 unknown_packages TEXT NOT NULL DEfAULT ''
107 INSERT INTO table_comments VALUES ('bug','Bugs');
108 INSERT INTO column_comments VALUES ('bug','id','Bug number');
109 INSERT INTO column_comments VALUES ('bug','creation','Time bug created');
110 INSERT INTO column_comments VALUES ('bug','log_modified','Time bug log was last modified');
111 INSERT INTO column_comments VALUES ('bug','last_modified','Time bug status was last modified');
112 INSERT INTO column_comments VALUES ('bug','archived','True if bug has been archived');
113 INSERT INTO column_comments VALUES ('bug','unarchived','Time bug was last unarchived; null if bug has never been unarchived');
114 INSERT INTO column_comments VALUES ('bug','forwarded','Where bug has been forwarded to; empty if it has not been forwarded');
115 INSERT INTO column_comments VALUES ('bug','summary','Summary of the bug; empty if it has no summary');
116 INSERT INTO column_comments VALUES ('bug','outlook','Outlook of the bug; empty if it has no outlook');
117 INSERT INTO column_comments VALUES ('bug','subject','Subject of the bug');
118 INSERT INTO column_comments VALUES ('bug','done','Individual who did the -done; empty if it has never been -done');
119 INSERT INTO column_comments VALUES ('bug','owner','Individual who owns this bug; empty if no one owns it');
120 INSERT INTO column_comments VALUES ('bug','submitter','Individual who submitted this bug; empty if there is no submitter');
121 INSERT INTO column_comments VALUES ('bug','unknown_packages','Package name if the package is not known');
123 CREATE INDEX ON bug(creation);
124 CREATE INDEX ON bug(log_modified);
125 CREATE INDEX ON bug(done);
126 CREATE INDEX ON bug(owner);
127 CREATE INDEX ON bug(submitter);
128 CREATE INDEX ON bug(forwarded);
132 CREATE TABLE bug_blocks (
133 id SERIAL PRIMARY KEY,
134 bug INT NOT NULL REFERENCES bug,
135 blocks INT NOT NULL REFERENCES bug,
136 CONSTRAINT bug_doesnt_block_itself CHECK (bug <> blocks)
138 CREATE UNIQUE INDEX bug_blocks_bug_id_blocks_idx ON bug_blocks(bug,blocks);
139 CREATE INDEX bug_blocks_bug_id_idx ON bug_blocks(bug);
140 CREATE INDEX bug_blocks_blocks_idx ON bug_blocks(blocks);
141 INSERT INTO table_comments VALUES ('bug_blocks','Bugs which block other bugs');
142 INSERT INTO column_comments VALUES ('bug_blocks','bug','Bug number');
143 INSERT INTO column_comments VALUES ('bug_blocks','blocks','Bug number which is blocked by bug');
146 CREATE TABLE bug_merged (
147 id SERIAL PRIMARY KEY,
148 bug INT NOT NULL REFERENCES bug,
149 merged INT NOT NULL REFERENCES bug,
150 CONSTRAINT bug_doesnt_merged_itself CHECK (bug <> merged)
152 CREATE UNIQUE INDEX bug_merged_bug_id_merged_idx ON bug_merged(bug,merged);
153 CREATE INDEX bug_merged_bug_id_idx ON bug_merged(bug);
154 CREATE INDEX bug_merged_merged_idx ON bug_merged(merged);
155 INSERT INTO table_comments VALUES ('bug_merged','Bugs which are merged with other bugs');
156 INSERT INTO column_comments VALUES ('bug_merged','bug','Bug number');
157 INSERT INTO column_comments VALUES ('bug_merged','merged','Bug number which is merged with bug');
159 CREATE TABLE src_pkg (
160 id SERIAL PRIMARY KEY,
162 pseduopkg BOOLEAN DEFAULT FALSE,
163 alias_of INT REFERENCES src_pkg ON UPDATE CASCADE ON DELETE CASCADE,
164 creation TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
165 disabled TIMESTAMP WITH TIME ZONE DEFAULT NULL,
166 last_modified TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
167 obsolete BOOLEAN DEFAULT FALSE,
168 CONSTRAINT src_pkg_doesnt_alias_itself CHECK (id <> alias_of),
169 CONSTRAINT src_pkg_is_obsolete_if_disabled CHECK ((obsolete IS FALSE AND disabled IS NULL) OR (obsolete IS TRUE AND disabled IS NOT NULL))
171 CREATE INDEX src_pkg_pkg ON src_pkg(pkg);
172 CREATE UNIQUE INDEX src_pkg_pkg_disabled ON src_pkg(pkg,disabled);
173 INSERT INTO table_comments VALUES ('src_pkg','Source packages');
174 INSERT INTO column_comments VALUES ('src_pkg','id','Source package id');
175 INSERT INTO column_comments VALUES ('src_pkg','pkg','Source package name');
176 INSERT INTO column_comments VALUES ('src_pkg','pseudopkg','True if this is a pseudo package');
177 INSERT INTO column_comments VALUES ('src_pkg','alias_of','Source package id which this source package is an alias of');
181 CREATE TABLE src_ver (
182 id SERIAL PRIMARY KEY,
183 src_pkg INT NOT NULL REFERENCES src_pkg
184 ON UPDATE CASCADE ON DELETE CASCADE,
185 ver public.debversion NOT NULL,
186 maintainer_id INT REFERENCES maintainer
187 ON UPDATE CASCADE ON DELETE SET NULL,
188 upload_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
189 based_on INT REFERENCES src_ver
190 ON UPDATE CASCADE ON DELETE CASCADE
192 CREATE UNIQUE INDEX src_ver_src_pkg_id_ver ON src_ver(src_pkg,ver);
193 INSERT INTO table_comments VALUES ('src_ver','Source Package versions');
194 INSERT INTO column_comments VALUES ('src_ver','id','Source package version id');
195 INSERT INTO column_comments VALUES ('src_ver','src_pkg','Source package id (matches src_pkg table)');
196 INSERT INTO column_comments VALUES ('src_ver','ver','Version of the source package');
197 INSERT INTO column_comments VALUES ('src_ver','maintainer_id','Maintainer id (matches maintainer table)');
198 INSERT INTO column_comments VALUES ('src_ver','upload_date','Date this version of the source package was uploaded');
199 INSERT INTO column_comments VALUES ('src_ver','based_on','Source package version this version is based on');
203 CREATE TABLE bug_ver (
204 bug INT NOT NULL REFERENCES bug
205 ON UPDATE CASCADE ON DELETE RESTRICT,
207 src_pkg INT REFERENCES src_pkg
208 ON UPDATE CASCADE ON DELETE SET NULL,
209 src_ver_id INT REFERENCES src_ver
210 ON UPDATE CASCADE ON DELETE SET NULL,
211 found BOOLEAN NOT NULL DEFAULT TRUE,
212 creation TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
213 last_modified TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
215 CREATE INDEX bug_ver_src_pkg_id_idx ON bug_ver(src_pkg);
216 CREATE INDEX bug_ver_src_pkg_id_src_ver_id_idx ON bug_ver(src_pkg,src_ver_id);
217 CREATE INDEX bug_ver_src_ver_id_idx ON bug_ver(src_ver_id);
218 CREATE UNIQUE INDEX ON bug_ver(bug,ver_string,found);
219 INSERT INTO table_comments VALUES ('bug_ver','Bug versions');
220 INSERT INTO column_comments VALUES ('bug_ver','bug','Bug number');
221 INSERT INTO column_comments VALUES ('bug_ver','ver_string','Version string');
222 INSERT INTO column_comments VALUES ('bug_ver','src_pkg','Source package id (matches src_pkg table)');
223 INSERT INTO column_comments VALUES ('bug_ver','src_ver_id','Source package version id (matches src_ver table)');
224 INSERT INTO column_comments VALUES ('bug_ver','found','True if this is a found version; false if this is a fixed version');
225 INSERT INTO column_comments VALUES ('bug_ver','creation','Time that this entry was created');
226 INSERT INTO column_comments VALUES ('bug_ver','last_modified','Time that this entry was modified');
230 id SERIAL PRIMARY KEY,
231 arch TEXT NOT NULL UNIQUE
233 INSERT INTO table_comments VALUES ('arch','Architectures');
234 INSERT INTO column_comments VALUES ('arch','id','Architecture id');
235 INSERT INTO column_comments VALUES ('arch','arch','Architecture name');
238 CREATE TABLE bin_pkg (
239 id SERIAL PRIMARY KEY,
240 pkg TEXT NOT NULL UNIQUE
242 INSERT INTO table_comments VALUES ('bin_pkg','Binary packages');
243 INSERT INTO column_comments VALUES ('bin_pkg','id','Binary package id');
244 INSERT INTO column_comments VALUES ('bin_pkg','pkg','Binary package name');
247 CREATE TABLE bin_ver(
248 id SERIAL PRIMARY KEY,
249 bin_pkg INT NOT NULL REFERENCES bin_pkg
250 ON UPDATE CASCADE ON DELETE CASCADE,
251 src_ver_id INT NOT NULL REFERENCES src_ver
252 ON UPDATE CASCADE ON DELETE CASCADE,
253 arch_id INT NOT NULL REFERENCES arch
254 ON UPDATE CASCADE ON DELETE CASCADE,
255 ver public.debversion NOT NULL
257 CREATE INDEX bin_ver_ver_idx ON bin_ver(ver);
258 CREATE UNIQUE INDEX bin_ver_bin_pkg_id_arch_idx ON bin_ver(bin_pkg,arch_id,ver);
259 CREATE UNIQUE INDEX bin_ver_src_ver_id_arch_idx ON bin_ver(src_ver_id,arch_id);
260 CREATE INDEX bin_ver_bin_pkg_id_idx ON bin_ver(bin_pkg);
261 CREATE INDEX bin_ver_src_ver_id_idx ON bin_ver(src_ver_id);
262 INSERT INTO table_comments VALUES ('bin_ver','Binary versions');
263 INSERT INTO column_comments VALUES ('bin_ver','id','Binary version id');
264 INSERT INTO column_comments VALUES ('bin_ver','bin_pkg','Binary package id (matches bin_pkg)');
265 INSERT INTO column_comments VALUES ('bin_ver','src_ver_id','Source version (matchines src_ver)');
266 INSERT INTO column_comments VALUES ('bin_ver','arch_id','Architecture id (matches arch)');
267 INSERT INTO column_comments VALUES ('bin_ver','ver','Binary version');
270 id SERIAL PRIMARY KEY,
271 tag TEXT NOT NULL UNIQUE,
272 obsolete BOOLEAN DEFAULT FALSE
274 INSERT INTO table_comments VALUES ('tag','Bug tags');
275 INSERT INTO column_comments VALUES ('tag','id','Tag id');
276 INSERT INTO column_comments VALUES ('tag','tag','Tag name');
277 INSERT INTO column_comments VALUES ('tag','obsolete','Whether a tag is obsolete (should not be set on new bugs)');
279 CREATE TABLE bug_tag (
280 id SERIAL PRIMARY KEY,
281 bug INT NOT NULL REFERENCES bug,
282 tag INT NOT NULL REFERENCES tag
284 INSERT INTO table_comments VALUES ('bug_tag','Bug <-> tag mapping');
285 INSERT INTO column_comments VALUES ('bug_tag','bug','Bug id (matches bug)');
286 INSERT INTO column_comments VALUES ('bug_tag','tag','Tag id (matches tag)');
288 CREATE UNIQUE INDEX bug_tag_bug_tag_id ON bug_tag (bug,tag);
289 CREATE INDEX bug_tag_tag_id ON bug_tag (tag);
290 CREATE INDEX bug_tag_bug_id ON bug_tag (bug);
294 CREATE TABLE bug_binpackage (
295 id SERIAL PRIMARY KEY,
296 bug INT NOT NULL REFERENCES bug,
297 bin_pkg INT NOT NULL REFERENCES bin_pkg
299 CREATE UNIQUE INDEX bug_binpackage_id_pkg_id ON bug_binpackage(bug,bin_pkg);
300 INSERT INTO table_comments VALUES ('bug_binpackage','Bug <-> binary package mapping');
301 INSERT INTO column_comments VALUES ('bug_binpackage','bug','Bug id (matches bug)');
302 INSERT INTO column_comments VALUES ('bug_binpackage','bin_pkg','Binary package id (matches bin_pkg)');
304 CREATE TABLE bug_srcpackage (
305 id SERIAL PRIMARY KEY,
306 bug INT NOT NULL REFERENCES bug,
307 src_pkg INT NOT NULL REFERENCES src_pkg ON UPDATE CASCADE ON DELETE CASCADE
309 CREATE UNIQUE INDEX bug_srcpackage_id_pkg_id ON bug_srcpackage(bug,src_pkg);
310 INSERT INTO table_comments VALUES ('bug_srcpackage','Bug <-> source package mapping');
311 INSERT INTO column_comments VALUES ('bug_srcpackage','bug','Bug id (matches bug)');
312 INSERT INTO column_comments VALUES ('bug_srcpackage','src_pkg','Source package id (matches src_pkg)');
314 CREATE VIEW bug_package (bug,pkg_id,pkg_type,package) AS
315 SELECT b.bug,b.bin_pkg,'binary',bp.pkg FROM bug_binpackage b JOIN bin_pkg bp ON bp.id=b.bin_pkg UNION
316 SELECT s.bug,s.src_pkg,'source',sp.pkg FROM bug_srcpackage s JOIN src_pkg sp ON sp.id=s.src_pkg;
318 CREATE VIEW binary_versions (src_pkg, src_ver, bin_pkg, arch, bin_ver) AS
319 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,
320 svb.ver AS src_ver_based_on, spb.pkg AS src_pkg_based_on
321 FROM bin_ver b JOIN arch a ON b.arch_id = a.id
322 JOIN bin_pkg bp ON b.bin_pkg = bp.id
323 JOIN src_ver sv ON b.src_ver_id = sv.id
324 JOIN src_pkg sp ON sv.src_pkg = sp.id
325 LEFT OUTER JOIN src_ver svb ON sv.based_on = svb.id
326 LEFT OUTER JOIN src_pkg spb ON spb.id = svb.src_pkg;
329 id SERIAL PRIMARY KEY,
330 suite_name TEXT NOT NULL UNIQUE,
333 active BOOLEAN DEFAULT TRUE);
334 CREATE INDEX ON suite(codename);
335 CREATE INDEX ON suite(version);
336 INSERT INTO table_comments VALUES ('suite','Debian Release Suite (stable, testing, etc.)');
337 INSERT INTO column_comments VALUES ('suite','id','Suite id');
338 INSERT INTO column_comments VALUES ('suite','suite_name','Suite name');
339 INSERT INTO column_comments VALUES ('suite','version','Suite version; NULL if there is no appropriate version');
340 INSERT INTO column_comments VALUES ('suite','codename','Suite codename');
341 INSERT INTO column_comments VALUES ('suite','active','TRUE if the suite is still accepting uploads');
343 CREATE TABLE bin_associations (
344 id SERIAL PRIMARY KEY,
345 suite INT NOT NULL REFERENCES suite ON DELETE CASCADE ON UPDATE CASCADE,
346 bin INT NOT NULL REFERENCES bin_ver ON DELETE CASCADE ON UPDATE CASCADE,
347 created TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
348 modified TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL
350 INSERT INTO table_comments VALUES ('bin_associations','Binary <-> suite associations');
351 INSERT INTO column_comments VALUES ('bin_associations','id','Binary <-> suite association id');
352 INSERT INTO column_comments VALUES ('bin_associations','suite','Suite id (matches suite)');
353 INSERT INTO column_comments VALUES ('bin_associations','bin','Binary version id (matches bin_ver)');
354 INSERT INTO column_comments VALUES ('bin_associations','created','Time this binary package entered this suite');
355 INSERT INTO column_comments VALUES ('bin_associations','modified','Time this entry was modified');
357 CREATE TABLE src_associations (
358 id SERIAL PRIMARY KEY,
359 suite INT NOT NULL REFERENCES suite ON DELETE CASCADE ON UPDATE CASCADE,
360 source INT NOT NULL REFERENCES src_ver ON DELETE CASCADE ON UPDATE CASCADE,
361 created TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
362 modified TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL
364 INSERT INTO table_comments VALUES ('src_associations','Source <-> suite associations');
365 INSERT INTO column_comments VALUES ('src_associations','id','Source <-> suite association id');
366 INSERT INTO column_comments VALUES ('src_associations','suite','Suite id (matches suite)');
367 INSERT INTO column_comments VALUES ('src_associations','source','Source version id (matches src_ver)');
368 INSERT INTO column_comments VALUES ('src_associations','created','Time this source package entered this suite');
369 INSERT INTO column_comments VALUES ('src_associations','modified','Time this entry was modified');
373 CREATE TYPE bug_status_type AS ENUM ('pending','forwarded','pending-fixed','fixed','absent','done');
374 CREATE TABLE bug_status_cache (
375 id SERIAL PRIMARY KEY,
376 bug INT NOT NULL REFERENCES bug ON DELETE CASCADE ON UPDATE CASCADE,
377 suite INT REFERENCES suite ON DELETE CASCADE ON UPDATE CASCADE,
378 arch INT REFERENCES arch ON DELETE CASCADE ON UPDATE CASCADE,
379 status bug_status_type NOT NULL,
380 modified TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
381 asof TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL
383 CREATE UNIQUE INDEX ON bug_status_cache(bug,suite,arch);
384 CREATE INDEX ON bug_status_cache(bug);
385 CREATE INDEX ON bug_status_cache(status);
386 INSERT INTO table_comments VALUES ('bug_status_cache','Source <-> suite associations');
387 INSERT INTO column_comments VALUES ('bug_status_cache','id','Source <-> suite association id');
388 INSERT INTO column_comments VALUES ('bug_status_cache','bug','Source <-> suite association id');
389 INSERT INTO column_comments VALUES ('bug_status_cache','suite','Source <-> suite association id');
390 INSERT INTO column_comments VALUES ('bug_status_cache','arch','Source <-> suite association id');
391 INSERT INTO column_comments VALUES ('bug_status_cache','status','Source <-> suite association id');
392 INSERT INTO column_comments VALUES ('bug_status_cache','modified','Source <-> suite association id');
393 INSERT INTO column_comments VALUES ('bug_status_cache','asof','Source <-> suite association id');
397 CREATE TABLE message (
398 id SERIAL PRIMARY KEY,
404 subject TEXT NOT NULL DEFAULT '',
405 sent_date TIMESTAMP WITH TIME ZONE,
406 refs TEXT NOT NULL DEFAULT '',
408 is_spam BOOLEAN DEFAULT FALSE
410 INSERT INTO table_comments VALUES ('message','Messages sent to bugs');
411 INSERT INTO column_comments VALUES ('message','id','Message id');
412 INSERT INTO column_comments VALUES ('message','msgid','Message id header');
413 INSERT INTO column_comments VALUES ('message','from_complete','Complete from header of message');
414 INSERT INTO column_comments VALUES ('message','from_addr','Address(es) of From: headers');
415 INSERT INTO column_comments VALUES ('message','to_complete','Complete to header of message');
416 INSERT INTO column_comments VALUES ('message','to_addr','Address(es) of To: header');
417 INSERT INTO column_comments VALUES ('message','subject','Subject of the message');
418 INSERT INTO column_comments VALUES ('message','sent_date','Time/date message was sent (from Date header)');
419 INSERT INTO column_comments VALUES ('message','refs','Contents of References: header');
420 INSERT INTO column_comments VALUES ('message','spam_score','Spam score from spamassassin');
421 INSERT INTO column_comments VALUES ('message','is_spam','True if this message was spam and should not be shown');
423 CREATE INDEX ON message(msgid);
425 CREATE TABLE message_refs (
426 id SERIAL PRIMARY KEY,
427 message INT NOT NULL REFERENCES message ON DELETE CASCADE ON UPDATE CASCADE,
428 refs INT NOT NULL REFERENCES message ON DELETE CASCADE ON UPDATE CASCADE,
429 inferred BOOLEAN DEFAULT FALSE,
430 primary_ref BOOLEAN DEFAULT FALSE,
431 CONSTRAINT message_doesnt_reference_itself CHECK (message <> refs)
433 CREATE UNIQUE INDEX ON message_refs(message,refs);
434 CREATE INDEX ON message_refs(refs);
435 CREATE INDEX ON message_refs(message);
436 INSERT INTO table_comments VALUES ('message_refs','Message references');
437 INSERT INTO column_comments VALUES ('message_refs','message','Message id (matches message)');
438 INSERT INTO column_comments VALUES ('message_refs','refs','Reference id (matches message)');
439 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');
440 INSERT INTO column_comments VALUES ('message_refs','primary_ref','TRUE if this message->ref came from In-Reply-To: or similar.');
444 CREATE TABLE correspondent_full_name(
445 id SERIAL PRIMARY KEY,
446 correspondent INT NOT NULL REFERENCES correspondent ON DELETE CASCADE ON UPDATE CASCADE,
447 full_name TEXT NOT NULL
449 CREATE UNIQUE INDEX ON correspondent_full_name(correspondent,full_name);
451 INSERT INTO table_comments VALUES ('correspondent_full_name','Full names of BTS correspondents');
452 INSERT INTO column_comments VALUES ('correspondent_full_name','id','Correspondent full name id');
453 INSERT INTO column_comments VALUES ('correspondent_full_name','correpsondent','Correspondent ID (matches correspondent)');
454 INSERT INTO column_comments VALUES ('correspondent_full_name','full_name','Correspondent full name (includes e-mail address)');
456 CREATE TYPE message_correspondent_type AS ENUM ('to','from','envfrom','cc');
458 CREATE TABLE message_correspondent (
459 id SERIAL PRIMARY KEY,
460 message INT NOT NULL REFERENCES message ON DELETE CASCADE ON UPDATE CASCADE,
461 correspondent INT NOT NULL REFERENCES correspondent ON DELETE CASCADE ON UPDATE CASCADE,
462 correspondent_type message_correspondent_type NOT NULL DEFAULT 'to'
464 INSERT INTO table_comments VALUES ('message_correspondent','Linkage between correspondent and message');
465 INSERT INTO column_comments VALUES ('message_correspondent','message','Message id (matches message)');
466 INSERT INTO column_comments VALUES ('message_correspondent','correspondent','Correspondent (matches correspondent)');
467 INSERT INTO column_comments VALUES ('message_correspondent','correspondent_type','Type of correspondent (to, from, envfrom, cc, etc.)');
469 CREATE UNIQUE INDEX ON message_correspondent(message,correspondent,correspondent_type);
470 CREATE INDEX ON message_correspondent(correspondent);
471 CREATE INDEX ON message_correspondent(message);
473 CREATE TABLE bug_message (
474 id SERIAL PRIMARY KEY,
475 bug INT NOT NULL REFERENCES bug ON DELETE CASCADE ON UPDATE CASCADE,
476 message INT NOT NULL REFERENCES message ON DELETE CASCADE ON UPDATE CASCADE,
477 message_number INT NOT NULL,
479 offset_valid TIMESTAMP WITH TIME ZONE
481 INSERT INTO table_comments VALUES ('bug_mesage','Mapping between a bug and a message');
482 INSERT INTO column_comments VALUES ('bug_message','bug','Bug id (matches bug)');
483 INSERT INTO column_comments VALUES ('bug_message','message','Message id (matches message)');
484 INSERT INTO column_comments VALUES ('bug_message','message_number','Message number in the bug log');
485 INSERT INTO column_comments VALUES ('bug_message','bug_log_offset','Byte offset in the bug log');
486 INSERT INTO column_comments VALUES ('bug_message','offset_valid','Time offset was valid');