Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
21 lines
964 B
SQL
21 lines
964 B
SQL
-- F3 (go-live 2026-09): platform emails (document published, new findings)
|
|
-- go through an outbox, one row per recipient, so a relay outage delays mail
|
|
-- instead of losing it. The body is rendered when the row is sent, from kind,
|
|
-- locale and data, so a template fix reaches queued mail too.
|
|
CREATE TABLE mail_outbox (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
tenant_id UUID REFERENCES tenants(id) ON DELETE CASCADE,
|
|
kind TEXT NOT NULL,
|
|
recipient TEXT NOT NULL,
|
|
locale TEXT NOT NULL DEFAULT 'de',
|
|
data JSONB NOT NULL DEFAULT '{}'::jsonb,
|
|
idempotency_key TEXT NOT NULL UNIQUE,
|
|
attempts INT NOT NULL DEFAULT 0,
|
|
next_attempt_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
sent_at TIMESTAMPTZ,
|
|
last_error TEXT,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
);
|
|
|
|
CREATE INDEX mail_outbox_due ON mail_outbox (next_attempt_at) WHERE sent_at IS NULL;
|