mesh/merge-gate out of date: judged against trunk e22326240833, the trunk is now 482232e8c51c; judged again on a recheck or when it is merged
mesh/repo-check out of date: judged against trunk e22326240833, the trunk is now 482232e8c51c; judged again on a recheck or when it is merged
mesh/delivery superseded: a newer head of the same pull request
ADR 0359 decided one module holds the operator's mail accounts. This is its first stage: an imap adapter that keeps IDLE on the inbox and polls the other folders read-only, indexes each message in its own database, keeps each attachment once by its SHA-256 in its bucket, and says every added, changed or removed message as a metadata-only event. Bodies and attachments are served only by its tools, to callers the trusted setting grants names. Its health waits for the account's own secret until it is given at the desk (issue 710).
47 lines
1.9 KiB
SQL
47 lines
1.9 KiB
SQL
-- The consolidated schema, through migration 0001: what a fresh database is given at once (the mesh's rule: a
|
|
-- numbered migration for the running store, and this for a fresh install).
|
|
create table folder (
|
|
account text not null,
|
|
name text not null,
|
|
uidvalidity bigint not null,
|
|
messages integer not null default 0,
|
|
synced timestamptz not null default now(),
|
|
primary key (account, name));
|
|
|
|
create table message (
|
|
account text not null,
|
|
folder text not null,
|
|
uid bigint not null,
|
|
uidvalidity bigint not null,
|
|
message_id text not null default '',
|
|
in_reply_to text not null default '',
|
|
date timestamptz not null,
|
|
sender jsonb not null default '[]',
|
|
recipients jsonb not null default '[]',
|
|
copied jsonb not null default '[]',
|
|
people text not null default '',
|
|
subject text not null default '',
|
|
size bigint not null default 0,
|
|
flags text[] not null default '{}',
|
|
attachments jsonb not null default '[]',
|
|
body text not null default '',
|
|
search tsvector generated always as (
|
|
to_tsvector('simple'::regconfig, subject || ' ' || people || ' ' || body)) stored,
|
|
primary key (account, folder, uid));
|
|
create index message_search on message using gin (search);
|
|
create index message_date on message (account, date desc);
|
|
|
|
create table account_state (
|
|
account text primary key,
|
|
state text not null,
|
|
why text not null default '',
|
|
heard timestamptz,
|
|
synced timestamptz,
|
|
said timestamptz not null default now());
|
|
|
|
create table outbox (
|
|
id bigserial primary key,
|
|
key text not null,
|
|
body jsonb not null,
|
|
made timestamptz not null default now());
|