Keep a mail entry per mail, never the body (issue 1517)

This commit is contained in:
jochen
2026-10-20 23:53:48 +02:00
parent d17b7e832d
commit 0d2d19daa0
12 changed files with 967 additions and 12 deletions
@@ -0,0 +1,61 @@
-- 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 mail_group (
id bigserial primary key,
label text not null default '',
created timestamptz not null default now());
create table mail_entry (
id bigserial primary key,
account text not null,
message_id text not null default '',
folder text not null,
date timestamptz not null,
sender_name text not null default '',
sender_address text not null default '',
subject text not null default '',
mail_group bigint references mail_group (id),
summary text not null default '' check (char_length(summary) <= 160),
mark text check (mark is null or mark in ('matters', 'scam warning', 'neither')),
why text not null default '',
due_date date,
told boolean not null default false);
create index mail_entry_account_date on mail_entry (account, date desc);
create table reading_lesson (
id bigserial primary key,
account text not null default '',
headers jsonb not null default '{}',
change text not null default '',
made timestamptz not null default now(),
undone boolean not null default false);
-- Heard but not yet read (novox/hq ADR 0459 §3, §12, issue 1518): headers only, kept until reading takes them,
-- in the order they were heard (id, a bigserial, orders arrival regardless of the mail's own date). A mail
-- heard twice is kept once: the unique key below is its account, folder, UIDVALIDITY and UID, the same
-- identity mesh-mail's own event carries for a message whose message id may be empty.
create table waiting_mail (
id bigserial primary key,
account text not null,
folder text not null,
message_id text not null default '',
uidvalidity bigint not null default 0,
uid bigint not null default 0,
date timestamptz not null,
sender jsonb not null default '[]',
subject text not null default '',
flags text[] not null default '{}',
size bigint not null default 0,
heard timestamptz not null default now(),
unique (account, folder, uidvalidity, uid));
-- The reader's own health (novox/hq ADR 0459 §12, issue 1519), kept across a restart: one row, singleton by
-- its fixed id. cause is "" while healthy, else one of refused, timed out, out of shape; since is the first
-- failure's own time, not the latest one.
create table reader_health (
id smallint primary key default 1,
healthy boolean not null default true,
cause text not null default '',
why text not null default '',
since timestamptz,
constraint reader_health_singleton check (id = 1));