2 DROP TABLE bug_status_cache CASCADE;
3 DROP VIEW bug_package CASCADE;
4 DROP VIEW binary_versions CASCADE;
5 DROP VIEW bug_status CASCADE;
6 DROP TABLE bug_tag CASCADE;
7 DROP TABLE tag CASCADE;
8 DROP TABLE bug_user_tag CASCADE;
9 DROP TABLE user_tag CASCADE;
10 DROP TABLE severity CASCADE;
11 DROP TABLE bug CASCADE;
12 DROP TABLE src_pkg CASCADE;
13 DROP TABLE bug_ver CASCADE;
14 DROP TABLE src_ver CASCADE;
15 DROP TABLE arch CASCADE;
16 DROP TABLE bin_ver CASCADE;
17 DROP TABLE bin_pkg CASCADE;
18 DROP TABLE bug_blocks CASCADE;
19 DROP TABLE bug_merged CASCADE;
20 DROP TABLE bug_srcpackage CASCADE;
21 DROP TABLE bug_binpackage CASCADE;
22 DROP TABLE bug_affects_binpackage CASCADE;
23 DROP TABLE bug_affects_srcpackage CASCADE;
24 DROP TABLE suite CASCADE;
25 DROP TABLE bin_associations CASCADE;
26 DROP TABLE src_associations CASCADE;
27 DROP TABLE maintainer CASCADE;
28 DROP TABLE bug_message CASCADE;
29 DROP TABLE message_correspondent CASCADE;
30 DROP TABLE correspondent_full_name CASCADE;
31 DROP TABLE correspondent CASCADE;
32 DROP TABLE message_refs CASCADE;
33 DROP TABLE message CASCADE;
34 DROP TYPE message_correspondent_type CASCADE;
35 DROP TABLE table_comments CASCADE;
36 DROP TABLE column_comments CASCADE;
37 DROP TYPE bug_status_type CASCADE;
39 -- the following two tables are used to provide documentation about
40 -- the tables and columns for DBIx::Class::Schema::Loader
41 CREATE TABLE table_comments (
42 table_name TEXT NOT NULL,
43 comment_text TEXT NOT NULL
45 CREATE UNIQUE INDEX table_comments_table_name_idx ON table_comments(table_name);
46 CREATE TABLE column_comments (
47 table_name TEXT NOT NULL,
48 column_name TEXT NOT NULL,
49 comment_text TEXT NOT NULL
51 CREATE UNIQUE INDEX column_comments_table_name_column_name_idx ON column_comments(table_name,column_name);
54 CREATE TABLE correspondent (
55 id SERIAL PRIMARY KEY,
58 CREATE UNIQUE INDEX correspondent_addr_idx ON correspondent(addr);
59 INSERT INTO table_comments VALUES ('correspondent','Individual who has corresponded with the BTS');
60 INSERT INTO column_comments VALUES ('correspondent','id','Correspondent ID');
61 INSERT INTO column_comments VALUES ('correspondent','addr','Correspondent address');
63 CREATE TABLE maintainer (
64 id SERIAL PRIMARY KEY,
66 correspondent INT NOT NULL REFERENCES correspondent(id),
67 created TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
68 modified TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL
70 CREATE UNIQUE INDEX maintainer_name_idx ON maintainer(name);
71 CREATE INDEX maintainer_idx_correspondent ON maintainer(correspondent);
72 INSERT INTO table_comments VALUES ('maintainer','Package maintainer names');
73 INSERT INTO column_comments VALUES ('maintainer','id','Package maintainer id');
74 INSERT INTO column_comments VALUES ('maintainer','name','Name of package maintainer');
75 INSERT INTO column_comments VALUES ('maintainer','correspondent','Correspondent ID');
76 INSERT INTO column_comments VALUES ('maintainer','created','Time maintainer record created');
77 INSERT INTO column_comments VALUES ('maintainer','modified','Time maintainer record modified');
80 CREATE TABLE severity (
81 id SERIAL PRIMARY KEY,
82 severity TEXT NOT NULL,
83 ordering INT NOT NULL DEFAULT 5,
84 strong BOOLEAN DEFAULT FALSE,
85 obsolete BOOLEAN DEFAULT FALSE
87 CREATE UNIQUE INDEX severity_severity_idx ON severity(severity);
88 CREATE INDEX severity_ordering_idx ON severity(ordering);
89 INSERT INTO table_comments VALUES ('severity','Bug severity');
90 INSERT INTO column_comments VALUES ('severity','id','Severity id');
91 INSERT INTO column_comments VALUES ('severity','severity','Severity name');
92 INSERT INTO column_comments VALUES ('severity','ordering','Severity ordering (more severe severities have higher numbers)');
93 INSERT INTO column_comments VALUES ('severity','strong','True if severity is a strong severity');
94 INSERT INTO column_comments VALUES ('severity','obsolete','Whether a severity level is obsolete (should not be set on new bugs)');
98 id INTEGER NOT NULL PRIMARY KEY,
99 creation TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
100 log_modified TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
101 last_modified TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
102 archived BOOLEAN NOT NULL DEFAULT FALSE,
103 unarchived TIMESTAMP WITH TIME ZONE,
104 forwarded TEXT NOT NULL DEFAULT '',
105 summary TEXT NOT NULL DEFAULT '',
106 outlook TEXT NOT NULL DEFAULT '',
107 subject TEXT NOT NULL,
108 severity INT NOT NULL REFERENCES severity(id),
109 done INT REFERENCES correspondent(id),
110 done_full TEXT NOT NULL DEFAULT '',
111 owner INT REFERENCES correspondent(id),
112 owner_full TEXT NOT NULL DEFAULT '',
113 -- submitter would ideally be NOT NULL, but there are some ancient bugs which do not have submitters
114 submitter INT REFERENCES correspondent(id),
115 submitter_full TEXT NOT NULL DEFAULT '',
116 unknown_packages TEXT NOT NULL DEfAULT ''
118 CREATE INDEX bug_idx_owner ON bug(owner);
119 CREATE INDEX bug_idx_submitter ON bug(submitter);
120 CREATE INDEX bug_idx_done ON bug(done);
121 CREATE INDEX bug_idx_forwarded ON bug(forwarded);
122 CREATE INDEX bug_idx_last_modified ON bug(last_modified);
123 CREATE INDEX bug_idx_severity ON bug(severity);
124 CREATE INDEX bug_idx_creation ON bug(creation);
125 CREATE INDEX bug_idx_log_modified ON bug(log_modified);
127 INSERT INTO table_comments VALUES ('bug','Bugs');
128 INSERT INTO column_comments VALUES ('bug','id','Bug number');
129 INSERT INTO column_comments VALUES ('bug','creation','Time bug created');
130 INSERT INTO column_comments VALUES ('bug','log_modified','Time bug log was last modified');
131 INSERT INTO column_comments VALUES ('bug','last_modified','Time bug status was last modified');
132 INSERT INTO column_comments VALUES ('bug','archived','True if bug has been archived');
133 INSERT INTO column_comments VALUES ('bug','unarchived','Time bug was last unarchived; null if bug has never been unarchived');
134 INSERT INTO column_comments VALUES ('bug','forwarded','Where bug has been forwarded to; empty if it has not been forwarded');
135 INSERT INTO column_comments VALUES ('bug','summary','Summary of the bug; empty if it has no summary');
136 INSERT INTO column_comments VALUES ('bug','outlook','Outlook of the bug; empty if it has no outlook');
137 INSERT INTO column_comments VALUES ('bug','subject','Subject of the bug');
138 INSERT INTO column_comments VALUES ('bug','done','Individual who did the -done; empty if it has never been -done');
139 INSERT INTO column_comments VALUES ('bug','owner','Individual who owns this bug; empty if no one owns it');
140 INSERT INTO column_comments VALUES ('bug','submitter','Individual who submitted this bug; empty if there is no submitter');
141 INSERT INTO column_comments VALUES ('bug','unknown_packages','Package name if the package is not known');
145 CREATE TABLE bug_blocks (
146 id SERIAL PRIMARY KEY,
147 bug INT NOT NULL REFERENCES bug,
148 blocks INT NOT NULL REFERENCES bug,
149 CONSTRAINT bug_doesnt_block_itself CHECK (bug <> blocks)
151 CREATE UNIQUE INDEX bug_blocks_bug_id_blocks_idx ON bug_blocks(bug,blocks);
152 CREATE INDEX bug_blocks_bug_id_idx ON bug_blocks(bug);
153 CREATE INDEX bug_blocks_blocks_idx ON bug_blocks(blocks);
154 INSERT INTO table_comments VALUES ('bug_blocks','Bugs which block other bugs');
155 INSERT INTO column_comments VALUES ('bug_blocks','bug','Bug number');
156 INSERT INTO column_comments VALUES ('bug_blocks','blocks','Bug number which is blocked by bug');
159 CREATE TABLE bug_merged (
160 id SERIAL PRIMARY KEY,
161 bug INT NOT NULL REFERENCES bug,
162 merged INT NOT NULL REFERENCES bug,
163 CONSTRAINT bug_doesnt_merged_itself CHECK (bug <> merged)
165 CREATE UNIQUE INDEX bug_merged_bug_id_merged_idx ON bug_merged(bug,merged);
166 CREATE INDEX bug_merged_bug_id_idx ON bug_merged(bug);
167 CREATE INDEX bug_merged_merged_idx ON bug_merged(merged);
168 INSERT INTO table_comments VALUES ('bug_merged','Bugs which are merged with other bugs');
169 INSERT INTO column_comments VALUES ('bug_merged','bug','Bug number');
170 INSERT INTO column_comments VALUES ('bug_merged','merged','Bug number which is merged with bug');
172 CREATE TABLE src_pkg (
173 id SERIAL PRIMARY KEY,
175 pseduopkg BOOLEAN NOT NULL DEFAULT FALSE,
176 alias_of INT REFERENCES src_pkg ON UPDATE CASCADE ON DELETE CASCADE,
177 creation TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
178 disabled TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT 'infinity'::timestamp with time zone,
179 last_modified TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
180 obsolete BOOLEAN NOT NULL DEFAULT FALSE,
181 CONSTRAINT src_pkg_doesnt_alias_itself CHECK (id <> alias_of),
182 CONSTRAINT src_pkg_is_obsolete_if_disabled CHECK (
183 (obsolete IS FALSE AND disabled='infinity'::timestamp with time zone) OR
184 (obsolete IS TRUE AND disabled < 'infinity'::timestamp with time zone))
186 CREATE INDEX src_pkg_pkg ON src_pkg(pkg);
187 CREATE UNIQUE INDEX src_pkg_pkg_null ON src_pkg(pkg) WHERE disabled='infinity'::timestamp with time zone;
188 CREATE UNIQUE INDEX src_pkg_pkg_disabled ON src_pkg(pkg,disabled);
189 INSERT INTO table_comments VALUES ('src_pkg','Source packages');
190 INSERT INTO column_comments VALUES ('src_pkg','id','Source package id');
191 INSERT INTO column_comments VALUES ('src_pkg','pkg','Source package name');
192 INSERT INTO column_comments VALUES ('src_pkg','pseudopkg','True if this is a pseudo package');
193 INSERT INTO column_comments VALUES ('src_pkg','alias_of','Source package id which this source package is an alias of');
197 CREATE TABLE src_ver (
198 id SERIAL PRIMARY KEY,
199 src_pkg INT NOT NULL REFERENCES src_pkg
200 ON UPDATE CASCADE ON DELETE CASCADE,
201 ver debversion NOT NULL,
202 maintainer INT REFERENCES maintainer
203 ON UPDATE CASCADE ON DELETE SET NULL,
204 upload_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
205 based_on INT REFERENCES src_ver
206 ON UPDATE CASCADE ON DELETE CASCADE
208 CREATE UNIQUE INDEX src_ver_src_pkg_id_ver ON src_ver(src_pkg,ver);
209 INSERT INTO table_comments VALUES ('src_ver','Source Package versions');
210 INSERT INTO column_comments VALUES ('src_ver','id','Source package version id');
211 INSERT INTO column_comments VALUES ('src_ver','src_pkg','Source package id (matches src_pkg table)');
212 INSERT INTO column_comments VALUES ('src_ver','ver','Version of the source package');
213 INSERT INTO column_comments VALUES ('src_ver','maintainer','Maintainer id (matches maintainer table)');
214 INSERT INTO column_comments VALUES ('src_ver','upload_date','Date this version of the source package was uploaded');
215 INSERT INTO column_comments VALUES ('src_ver','based_on','Source package version this version is based on');
219 CREATE TABLE bug_ver (
220 id SERIAL PRIMARY KEY,
221 bug INT NOT NULL REFERENCES bug
222 ON UPDATE CASCADE ON DELETE RESTRICT,
224 src_pkg INT REFERENCES src_pkg
225 ON UPDATE CASCADE ON DELETE SET NULL,
226 src_ver INT REFERENCES src_ver
227 ON UPDATE CASCADE ON DELETE SET NULL,
228 found BOOLEAN NOT NULL DEFAULT TRUE,
229 creation TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
230 last_modified TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
232 CREATE INDEX bug_ver_src_pkg_id_idx ON bug_ver(src_pkg);
233 CREATE INDEX bug_ver_src_pkg_id_src_ver_id_idx ON bug_ver(src_pkg,src_ver);
234 CREATE INDEX bug_ver_src_ver_id_idx ON bug_ver(src_ver);
235 CREATE UNIQUE INDEX bug_ver_bug_ver_string_found_idx ON bug_ver(bug,ver_string,found);
236 INSERT INTO table_comments VALUES ('bug_ver','Bug versions');
237 INSERT INTO column_comments VALUES ('bug_ver','id','Bug version id');
238 INSERT INTO column_comments VALUES ('bug_ver','bug','Bug number');
239 INSERT INTO column_comments VALUES ('bug_ver','ver_string','Version string');
240 INSERT INTO column_comments VALUES ('bug_ver','src_pkg','Source package id (matches src_pkg table)');
241 INSERT INTO column_comments VALUES ('bug_ver','src_ver','Source package version id (matches src_ver table)');
242 INSERT INTO column_comments VALUES ('bug_ver','found','True if this is a found version; false if this is a fixed version');
243 INSERT INTO column_comments VALUES ('bug_ver','creation','Time that this entry was created');
244 INSERT INTO column_comments VALUES ('bug_ver','last_modified','Time that this entry was modified');
248 id SERIAL PRIMARY KEY,
251 CREATE UNIQUE INDEX arch_arch_key ON arch(arch);
252 INSERT INTO table_comments VALUES ('arch','Architectures');
253 INSERT INTO column_comments VALUES ('arch','id','Architecture id');
254 INSERT INTO column_comments VALUES ('arch','arch','Architecture name');
257 CREATE TABLE bin_pkg (
258 id SERIAL PRIMARY KEY,
261 CREATE UNIQUE INDEX bin_pkg_pkg_key ON bin_pkg(pkg);
262 INSERT INTO table_comments VALUES ('bin_pkg','Binary packages');
263 INSERT INTO column_comments VALUES ('bin_pkg','id','Binary package id');
264 INSERT INTO column_comments VALUES ('bin_pkg','pkg','Binary package name');
267 CREATE TABLE bin_ver(
268 id SERIAL PRIMARY KEY,
269 bin_pkg INT NOT NULL REFERENCES bin_pkg
270 ON UPDATE CASCADE ON DELETE CASCADE,
271 src_ver INT NOT NULL REFERENCES src_ver
272 ON UPDATE CASCADE ON DELETE CASCADE,
273 arch INT NOT NULL REFERENCES arch
274 ON UPDATE CASCADE ON DELETE CASCADE,
275 ver debversion NOT NULL
277 CREATE INDEX bin_ver_ver_idx ON bin_ver(ver);
278 CREATE UNIQUE INDEX bin_ver_bin_pkg_id_arch_idx ON bin_ver(bin_pkg,arch,ver);
279 CREATE INDEX bin_ver_src_ver_id_arch_idx ON bin_ver(src_ver,arch);
280 CREATE INDEX bin_ver_bin_pkg_id_idx ON bin_ver(bin_pkg);
281 CREATE INDEX bin_ver_src_ver_id_idx ON bin_ver(src_ver);
282 INSERT INTO table_comments VALUES ('bin_ver','Binary versions');
283 INSERT INTO column_comments VALUES ('bin_ver','id','Binary version id');
284 INSERT INTO column_comments VALUES ('bin_ver','bin_pkg','Binary package id (matches bin_pkg)');
285 INSERT INTO column_comments VALUES ('bin_ver','src_ver','Source version (matchines src_ver)');
286 INSERT INTO column_comments VALUES ('bin_ver','arch','Architecture id (matches arch)');
287 INSERT INTO column_comments VALUES ('bin_ver','ver','Binary version');
290 id SERIAL PRIMARY KEY,
291 tag TEXT NOT NULL UNIQUE,
292 obsolete BOOLEAN DEFAULT FALSE
294 INSERT INTO table_comments VALUES ('tag','Bug tags');
295 INSERT INTO column_comments VALUES ('tag','id','Tag id');
296 INSERT INTO column_comments VALUES ('tag','tag','Tag name');
297 INSERT INTO column_comments VALUES ('tag','obsolete','Whether a tag is obsolete (should not be set on new bugs)');
299 CREATE TABLE bug_tag (
300 bug INT NOT NULL REFERENCES bug,
301 tag INT NOT NULL REFERENCES tag
303 INSERT INTO table_comments VALUES ('bug_tag','Bug <-> tag mapping');
304 INSERT INTO column_comments VALUES ('bug_tag','bug','Bug id (matches bug)');
305 INSERT INTO column_comments VALUES ('bug_tag','tag','Tag id (matches tag)');
307 CREATE UNIQUE INDEX bug_tag_bug_tag ON bug_tag (bug,tag);
308 CREATE INDEX bug_tag_tag ON bug_tag (tag);
310 CREATE TABLE user_tag (
311 id SERIAL PRIMARY KEY,
313 correspondent INT NOT NULL REFERENCES correspondent(id)
315 INSERT INTO table_comments VALUES ('user_tag','User bug tags');
316 INSERT INTO column_comments VALUES ('user_tag','id','User bug tag id');
317 INSERT INTO column_comments VALUES ('user_tag','tag','User bug tag name');
318 INSERT INTO column_comments VALUES ('user_tag','correspondent','User bug tag correspondent');
320 CREATE UNIQUE INDEX user_tag_tag_correspondent ON user_tag(tag,correspondent);
321 CREATE INDEX user_tag_correspondent ON user_tag(correspondent);
323 CREATE TABLE bug_user_tag (
324 bug INT NOT NULL REFERENCES bug,
325 user_tag INT NOT NULL REFERENCES user_tag
327 INSERT INTO table_comments VALUES ('bug_user_tag','Bug <-> user tag mapping');
328 INSERT INTO column_comments VALUES ('bug_user_tag','bug','Bug id (matches bug)');
329 INSERT INTO column_comments VALUES ('bug_user_tag','tag','User tag id (matches user_tag)');
331 CREATE UNIQUE INDEX bug_user_tag_bug_tag ON bug_user_tag (bug,user_tag);
332 CREATE INDEX bug_user_tag_tag ON bug_user_tag (user_tag);
334 CREATE TABLE bug_binpackage (
335 bug INT NOT NULL REFERENCES bug,
336 bin_pkg INT NOT NULL REFERENCES bin_pkg ON UPDATE CASCADE ON DELETE CASCADE
338 CREATE UNIQUE INDEX bug_binpackage_id_pkg ON bug_binpackage(bug,bin_pkg);
339 INSERT INTO table_comments VALUES ('bug_binpackage','Bug <-> binary package mapping');
340 INSERT INTO column_comments VALUES ('bug_binpackage','bug','Bug id (matches bug)');
341 INSERT INTO column_comments VALUES ('bug_binpackage','bin_pkg','Binary package id (matches bin_pkg)');
343 CREATE TABLE bug_srcpackage (
344 bug INT NOT NULL REFERENCES bug,
345 src_pkg INT NOT NULL REFERENCES src_pkg ON UPDATE CASCADE ON DELETE CASCADE
347 CREATE UNIQUE INDEX bug_srcpackage_id_pkg ON bug_srcpackage(bug,src_pkg);
348 CREATE INDEX bug_srcpackage_idx_src_pkg ON bug_srcpackage(src_pkg);
350 INSERT INTO table_comments VALUES ('bug_srcpackage','Bug <-> source package mapping');
351 INSERT INTO column_comments VALUES ('bug_srcpackage','bug','Bug id (matches bug)');
352 INSERT INTO column_comments VALUES ('bug_srcpackage','src_pkg','Source package id (matches src_pkg)');
354 CREATE TABLE bug_affects_binpackage (
355 bug INT NOT NULL REFERENCES bug,
356 bin_pkg INT NOT NULL REFERENCES bin_pkg ON UPDATE CASCADE ON DELETE CASCADE
358 CREATE UNIQUE INDEX bug_affects_binpackage_id_pkg ON bug_affects_binpackage(bug,bin_pkg);
359 INSERT INTO table_comments VALUES ('bug_affects_binpackage','Bug <-> binary package mapping');
360 INSERT INTO column_comments VALUES ('bug_affects_binpackage','bug','Bug id (matches bug)');
361 INSERT INTO column_comments VALUES ('bug_affects_binpackage','bin_pkg','Binary package id (matches bin_pkg)');
363 CREATE TABLE bug_affects_srcpackage (
364 bug INT NOT NULL REFERENCES bug,
365 src_pkg INT NOT NULL REFERENCES src_pkg ON UPDATE CASCADE ON DELETE CASCADE
367 CREATE UNIQUE INDEX bug_affects_srcpackage_id_pkg ON bug_affects_srcpackage(bug,src_pkg);
368 INSERT INTO table_comments VALUES ('bug_affects_srcpackage','Bug <-> source package mapping');
369 INSERT INTO column_comments VALUES ('bug_affects_srcpackage','bug','Bug id (matches bug)');
370 INSERT INTO column_comments VALUES ('bug_affects_srcpackage','src_pkg','Source package id (matches src_pkg)');
372 CREATE VIEW bug_package (bug,pkg_id,pkg_type,package) AS
373 SELECT b.bug,b.bin_pkg,'binary',bp.pkg FROM bug_binpackage b JOIN bin_pkg bp ON bp.id=b.bin_pkg UNION
374 SELECT s.bug,s.src_pkg,'source',sp.pkg FROM bug_srcpackage s JOIN src_pkg sp ON sp.id=s.src_pkg UNION
375 SELECT b.bug,b.bin_pkg,'binary_affects',bp.pkg FROM bug_affects_binpackage b JOIN bin_pkg bp ON bp.id=b.bin_pkg UNION
376 SELECT s.bug,s.src_pkg,'source_affects',sp.pkg FROM bug_affects_srcpackage s JOIN src_pkg sp ON sp.id=s.src_pkg;
378 CREATE VIEW binary_versions (src_pkg, src_ver, bin_pkg, arch, bin_ver) AS
379 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,
380 svb.ver AS src_ver_based_on, spb.pkg AS src_pkg_based_on
381 FROM bin_ver b JOIN arch a ON b.arch = a.id
382 JOIN bin_pkg bp ON b.bin_pkg = bp.id
383 JOIN src_ver sv ON b.src_ver = sv.id
384 JOIN src_pkg sp ON sv.src_pkg = sp.id
385 LEFT OUTER JOIN src_ver svb ON sv.based_on = svb.id
386 LEFT OUTER JOIN src_pkg spb ON spb.id = svb.src_pkg;
389 id SERIAL PRIMARY KEY,
390 codename TEXT NOT NULL,
393 active BOOLEAN DEFAULT TRUE);
394 CREATE UNIQUE INDEX suite_idx_codename ON suite(codename);
395 CREATE UNIQUE INDEX suite_suite_name_key ON suite(suite_name);
396 CREATE UNIQUE INDEX suite_idx_version ON suite(version);
397 INSERT INTO table_comments VALUES ('suite','Debian Release Suite (stable, testing, etc.)');
398 INSERT INTO column_comments VALUES ('suite','id','Suite id');
399 INSERT INTO column_comments VALUES ('suite','suite_name','Suite name (testing, stable, etc.)');
400 INSERT INTO column_comments VALUES ('suite','version','Suite version; NULL if there is no appropriate version');
401 INSERT INTO column_comments VALUES ('suite','codename','Suite codename (sid, squeeze, etc.)');
402 INSERT INTO column_comments VALUES ('suite','active','TRUE if the suite is still accepting uploads');
404 CREATE TABLE bin_associations (
405 id SERIAL PRIMARY KEY,
406 suite INT NOT NULL REFERENCES suite ON DELETE CASCADE ON UPDATE CASCADE,
407 bin INT NOT NULL REFERENCES bin_ver ON DELETE CASCADE ON UPDATE CASCADE,
408 created TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
409 modified TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL
411 INSERT INTO table_comments VALUES ('bin_associations','Binary <-> suite associations');
412 INSERT INTO column_comments VALUES ('bin_associations','id','Binary <-> suite association id');
413 INSERT INTO column_comments VALUES ('bin_associations','suite','Suite id (matches suite)');
414 INSERT INTO column_comments VALUES ('bin_associations','bin','Binary version id (matches bin_ver)');
415 INSERT INTO column_comments VALUES ('bin_associations','created','Time this binary package entered this suite');
416 INSERT INTO column_comments VALUES ('bin_associations','modified','Time this entry was modified');
417 CREATE UNIQUE INDEX bin_associations_bin_suite ON bin_associations(bin,suite);
419 CREATE TABLE src_associations (
420 id SERIAL PRIMARY KEY,
421 suite INT NOT NULL REFERENCES suite ON DELETE CASCADE ON UPDATE CASCADE,
422 source INT NOT NULL REFERENCES src_ver ON DELETE CASCADE ON UPDATE CASCADE,
423 created TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
424 modified TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL
426 INSERT INTO table_comments VALUES ('src_associations','Source <-> suite associations');
427 INSERT INTO column_comments VALUES ('src_associations','id','Source <-> suite association id');
428 INSERT INTO column_comments VALUES ('src_associations','suite','Suite id (matches suite)');
429 INSERT INTO column_comments VALUES ('src_associations','source','Source version id (matches src_ver)');
430 INSERT INTO column_comments VALUES ('src_associations','created','Time this source package entered this suite');
431 INSERT INTO column_comments VALUES ('src_associations','modified','Time this entry was modified');
432 CREATE UNIQUE INDEX src_associations_source_suite ON src_associations(source,suite);
435 CREATE TYPE bug_status_type AS ENUM ('absent','found','fixed','undef');
436 CREATE TABLE bug_status_cache (
437 bug INT NOT NULL REFERENCES bug ON DELETE CASCADE ON UPDATE CASCADE,
438 suite INT REFERENCES suite ON DELETE CASCADE ON UPDATE CASCADE,
439 arch INT REFERENCES arch ON DELETE CASCADE ON UPDATE CASCADE,
440 status bug_status_type NOT NULL,
441 modified TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
442 asof TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL
444 CREATE UNIQUE INDEX bug_status_cache_bug_suite_arch_idx ON bug_status_cache(bug,suite,arch);
445 CREATE INDEX bug_status_cache_idx_bug ON bug_status_cache(bug);
446 CREATE INDEX bug_status_cache_idx_status ON bug_status_cache(status);
447 CREATE INDEX bug_status_cache_idx_arch ON bug_status_cache(arch);
448 CREATE INDEX bug_status_cache_idx_suite ON bug_status_cache(suite);
449 CREATE INDEX bug_status_cache_idx_asof ON bug_status_cache(asof);
450 INSERT INTO table_comments VALUES ('bug_status_cache','Bug Status Cache');
451 INSERT INTO column_comments VALUES ('bug_status_cache','bug','Bug number (matches bug)');
452 INSERT INTO column_comments VALUES ('bug_status_cache','suite','Suite id (matches suite)');
453 INSERT INTO column_comments VALUES ('bug_status_cache','arch','Architecture id (matches arch)');
454 INSERT INTO column_comments VALUES ('bug_status_cache','status','Status (bug status)');
455 INSERT INTO column_comments VALUES ('bug_status_cache','modified','Time that this status was last modified');
456 INSERT INTO column_comments VALUES ('bug_status_cache','asof','Time that this status was last calculated');
460 CREATE TABLE message (
461 id SERIAL PRIMARY KEY,
462 msgid TEXT NOT NULL DEFAULT '',
463 from_complete TEXT NOT NULL DEFAULT '',
464 to_complete TEXT NOT NULL DEFAULT '',
465 subject TEXT NOT NULL DEFAULT '',
466 sent_date TIMESTAMP WITH TIME ZONE,
467 refs TEXT NOT NULL DEFAULT '',
468 spam_score FLOAT NOT NULL DEFAULT 0,
469 is_spam BOOLEAN NOT NULL DEFAULT FALSE
471 INSERT INTO table_comments VALUES ('message','Messages sent to bugs');
472 INSERT INTO column_comments VALUES ('message','id','Message id');
473 INSERT INTO column_comments VALUES ('message','msgid','Message id header');
474 INSERT INTO column_comments VALUES ('message','from_complete','Complete from header of message');
475 INSERT INTO column_comments VALUES ('message','to_complete','Complete to header of message');
476 INSERT INTO column_comments VALUES ('message','subject','Subject of the message');
477 INSERT INTO column_comments VALUES ('message','sent_date','Time/date message was sent (from Date header)');
478 INSERT INTO column_comments VALUES ('message','refs','Contents of References: header');
479 INSERT INTO column_comments VALUES ('message','spam_score','Spam score from spamassassin');
480 INSERT INTO column_comments VALUES ('message','is_spam','True if this message was spam and should not be shown');
481 CREATE INDEX message_msgid_idx ON message(msgid);
482 CREATE UNIQUE INDEX message_msgid_from_complete_to_complete_subject_idx
483 ON message(msgid,from_complete,to_complete,subject);
484 CREATE INDEX message_subject_idx ON message(subject);
486 CREATE TABLE message_refs (
487 message INT NOT NULL REFERENCES message ON DELETE CASCADE ON UPDATE CASCADE,
488 refs INT NOT NULL REFERENCES message ON DELETE CASCADE ON UPDATE CASCADE,
489 inferred BOOLEAN DEFAULT FALSE,
490 primary_ref BOOLEAN DEFAULT FALSE,
491 CONSTRAINT message_doesnt_reference_itself CHECK (message <> refs)
493 CREATE UNIQUE INDEX message_refs_message_refs_idx ON message_refs(message,refs);
494 CREATE INDEX message_refs_idx_refs ON message_refs(refs);
495 CREATE INDEX message_refs_idx_message ON message_refs(message);
496 INSERT INTO table_comments VALUES ('message_refs','Message references');
497 INSERT INTO column_comments VALUES ('message_refs','message','Message id (matches message)');
498 INSERT INTO column_comments VALUES ('message_refs','refs','Reference id (matches message)');
499 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');
500 INSERT INTO column_comments VALUES ('message_refs','primary_ref','TRUE if this message->ref came from In-Reply-To: or similar.');
504 CREATE TABLE correspondent_full_name(
505 correspondent INT NOT NULL REFERENCES correspondent ON DELETE CASCADE ON UPDATE CASCADE,
506 full_name TEXT NOT NULL,
507 last_seen TIMESTAMP NOT NULL DEFAULT NOW()
509 CREATE UNIQUE INDEX correspondent_full_name_correspondent_full_name_idx
510 ON correspondent_full_name(correspondent,full_name);
511 CREATE INDEX correspondent_full_name_idx_full_name ON correspondent_full_name(full_name);
512 CREATE INDEX correspondent_full_name_idx_last_seen ON correspondent_full_name(last_seen);
513 INSERT INTO table_comments VALUES ('correspondent_full_name','Full names of BTS correspondents');
514 INSERT INTO column_comments VALUES ('correspondent_full_name','correspondent','Correspondent ID (matches correspondent)');
515 INSERT INTO column_comments VALUES ('correspondent_full_name','full_name','Correspondent full name (includes e-mail address)');
517 CREATE TYPE message_correspondent_type AS ENUM ('to','from','envfrom','cc','recv');
519 CREATE TABLE message_correspondent (
520 message INT NOT NULL REFERENCES message ON DELETE CASCADE ON UPDATE CASCADE,
521 correspondent INT NOT NULL REFERENCES correspondent ON DELETE CASCADE ON UPDATE CASCADE,
522 correspondent_type message_correspondent_type NOT NULL DEFAULT 'to'
524 INSERT INTO table_comments VALUES ('message_correspondent','Linkage between correspondent and message');
525 INSERT INTO column_comments VALUES ('message_correspondent','message','Message id (matches message)');
526 INSERT INTO column_comments VALUES ('message_correspondent','correspondent','Correspondent (matches correspondent)');
527 INSERT INTO column_comments VALUES ('message_correspondent','correspondent_type','Type of correspondent (to, from, envfrom, cc, etc.)');
529 CREATE UNIQUE INDEX message_correspondent_message_correspondent_correspondent_t_idx
530 ON message_correspondent(message,correspondent,correspondent_type);
531 CREATE INDEX message_correspondent_idx_correspondent ON message_correspondent(correspondent);
532 CREATE INDEX message_correspondent_idx_message ON message_correspondent(message);
534 CREATE TABLE bug_message (
535 bug INT NOT NULL REFERENCES bug ON DELETE CASCADE ON UPDATE CASCADE,
536 message INT NOT NULL REFERENCES message ON DELETE CASCADE ON UPDATE CASCADE,
537 message_number INT NOT NULL,
539 offset_valid TIMESTAMP WITH TIME ZONE
541 CREATE UNIQUE INDEX bug_message_bug_message_idx ON bug_message(bug,message);
542 CREATE INDEX bug_message_idx_bug_message_number ON bug_message(bug,message_number);
543 INSERT INTO table_comments VALUES ('bug_mesage','Mapping between a bug and a message');
544 INSERT INTO column_comments VALUES ('bug_message','bug','Bug id (matches bug)');
545 INSERT INTO column_comments VALUES ('bug_message','message','Message id (matches message)');
546 INSERT INTO column_comments VALUES ('bug_message','message_number','Message number in the bug log');
547 INSERT INTO column_comments VALUES ('bug_message','bug_log_offset','Byte offset in the bug log');
548 INSERT INTO column_comments VALUES ('bug_message','offset_valid','Time offset was valid');
550 CREATE VIEW bug_status --(id,bug_num,tags,subject,
551 -- severity,package,originator,log_modified,date,
552 -- last_modified, blocks, blockedby, mergedwith,
553 -- fixed_versions,found_versions)
557 string_agg(t.tag,',') AS tags,
558 b.subject AS subject,
559 (SELECT s.severity FROM severity s WHERE s.id=b.severity) AS severity,
560 (SELECT string_agg(package.package,',' ORDER BY package)
561 FROM (SELECT bp.pkg AS package
562 FROM bug_binpackage bbp
563 JOIN bin_pkg bp ON bbp.bin_pkg=bp.id
566 SELECT CONCAT('src:',sp.pkg) AS package
567 FROM bug_srcpackage bsp
568 JOIN src_pkg sp ON bsp.src_pkg=sp.id
569 WHERE bsp.bug=b.id) AS package
571 b.submitter_full AS originator,
572 b.log_modified AS log_modified,
574 b.last_modified AS last_modified,
575 string_agg(bb.blocks::text,' ' ORDER BY bb.blocks) AS blocks,
576 string_agg(bbb.bug::text,' ' ORDER BY bbb.bug) AS blockedby,
577 (SELECT string_agg(bug.bug::text,' ' ORDER BY bug.bug)
578 FROM (SELECT b.id AS bug
580 SELECT bm.merged AS bug FROM bug_merged bm WHERE bm.bug=b.id
582 SELECT bm.bug AS bug FROM bug_merged bm WHERE bm.merged=b.id) AS bug) AS merged,
583 (SELECT string_agg(bv.ver_string,' ') FROM bug_ver bv WHERE bv.bug=b.id AND bv.found IS TRUE)
585 (SELECT string_agg(bv.ver_string,' ') FROM bug_ver bv WHERE bv.bug=b.id AND bv.found IS TRUE)
588 LEFT JOIN bug_tag bt ON bt.bug=b.id
589 LEFT JOIN tag t ON bt.tag=t.id
590 LEFT JOIN bug_blocks bb ON bb.bug=b.id
591 LEFT JOIN bug_blocks bbb ON bbb.blocks=b.id