-- 沟通记录 —— 一单往来的**原件存档**。 -- -- 「跟客户、供应商往来的邮件和消息按单归档」这件事,从前只有一屏诚实的空态: -- 数据在 channel / event 里确有,按单的投影一直没做。现在有了落点。 -- -- 进来的那一封(direction='in')是**开案的那份料** —— 活动的入参就是它; -- 出去的(direction='out')是放行后系统真发出去的件。两向同表,按时刻排。 create table sys.task_comm ( id text primary key, task_id text not null, at timestamptz not null default now(), direction text not null, -- 'in' | 'out' channel text not null, -- 'mail' | 'im' | 'phone' | … party text not null default '',-- 对方(邮箱 / 账号 / 号码) subject text not null default '', body text not null default '', attachments jsonb not null default '[]'::jsonb, note text not null default '' ); create index task_comm_task_idx on sys.task_comm (task_id, at);