Mercurial > ~dholland > hg > swallowtail > index.cgi
view database/schema/messages.sql @ 12:d4c3bd255653
"timestamp", not "date". from asau
author | David A. Holland |
---|---|
date | Thu, 19 Jul 2012 15:00:13 -0400 |
parents | 68cc276ac118 |
children | 5bf0d6f732c1 |
line wrap: on
line source
-- -- Messages. -- CREATE SEQUENCE next_rawmsgid; -- all incoming mail in original form, for reference -- (should be pruned periodically) CREATE TABLE rawmail ( id bigint primary key default nextval('next_rawmsgid'), data text not null ) WITHOUT OIDS; CREATE SEQUENCE next_msgid; -- comments CREATE TABLE messages ( id bigint primary key default nextval('next_msgid'), pr bigint not null references prs (id), who bigint not null references users (id), parent_id bigint null references messages (id), when timestamp not null, body text not null, -- we don't keep these directly, they go into an admin log entry --from_address text not null, --mail_subject text not null, --message_id text not null, rawid bigint null references rawmail (id) check (parent_id != commentid) ) WITHOUT OIDS; -- for patches and mime-attachments -- if msgid is null, attachment came with original PR CREATE TABLE attachments ( pr bigint not null references PRs (id), msgid bigint null references messages (id), mimetype text not null, body text not null ) WITHOUT OIDS; -- intended constraint: -- SELECT messages.pr, attachments.pr -- FROM messages, attachments -- WHERE messages.id = attachments.msgid AND messages.pr <> attachments.pr -- should always be empty. -- (XXX this is gross.)