view database/schema/messages.sql @ 41:81851564f552

The initial description, how_to_repeat, and fix go in the first message. Storing them separately only creates a pile of special cases.
author David A. Holland
date Sun, 15 Jun 2014 17:55:56 -0400
parents 44c1509055c7
children e1017d556437
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'),
	posttime timestamp	not null,
	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),
	number_in_pr bigint	not null,
	who bigint		not null references users (id),
	parent_id bigint	null references messages (id),
	posttime timestamp	not null,
	mimetype text		not null,
	body text		not null,

	-- we don't keep these directly, they go into an admin log entry
	-- XXX: we may need to keep the external message-id
	--from_address text	not null,
	--mail_subject text	not null,
	--message_id text	not null,
	rawid bigint		null references rawmail (id)

	check (parent_id != id)
)
WITHOUT OIDS;

CREATE SEQUENCE next_attachid;

-- for patches and mime-attachments
CREATE TABLE attachments (
	id bigint		primary key default nextval('next_attachid'),
	number_in_pr bigint	not null,
	msgid bigint		not null references messages (id),
	mimetype text		not null,
	body text		not null
)
WITHOUT OIDS;