comparison database/schema/messages.sql @ 8:68cc276ac118

SQL material from old tree, split up for accessibility.
author David A. Holland
date Sun, 19 Feb 2012 19:54:48 -0500
parents
children d4c3bd255653
comparison
equal deleted inserted replaced
7:c013fb703183 8:68cc276ac118
1 --
2 -- Messages.
3 --
4
5 CREATE SEQUENCE next_rawmsgid;
6
7 -- all incoming mail in original form, for reference
8 -- (should be pruned periodically)
9 CREATE TABLE rawmail (
10 id bigint primary key default nextval('next_rawmsgid'),
11 data text not null
12 )
13 WITHOUT OIDS;
14
15 CREATE SEQUENCE next_msgid;
16
17 -- comments
18 CREATE TABLE messages (
19 id bigint primary key default nextval('next_msgid'),
20 pr bigint not null references prs (id),
21 who bigint not null references users (id),
22 parent_id bigint null references messages (id),
23 when date not null,
24 body text not null,
25
26 -- we don't keep these directly, they go into an admin log entry
27 --from_address text not null,
28 --mail_subject text not null,
29 --message_id text not null,
30 rawid bigint null references rawmail (id)
31
32 check (parent_id != commentid)
33 )
34 WITHOUT OIDS;
35
36 -- for patches and mime-attachments
37 -- if msgid is null, attachment came with original PR
38 CREATE TABLE attachments (
39 pr bigint not null references PRs (id),
40 msgid bigint null references messages (id),
41 mimetype text not null,
42 body text not null
43 )
44 WITHOUT OIDS;
45
46 -- intended constraint:
47 -- SELECT messages.pr, attachments.pr
48 -- FROM messages, attachments
49 -- WHERE messages.id = attachments.msgid AND messages.pr <> attachments.pr
50 -- should always be empty.
51 -- (XXX this is gross.)
52