Prisma database schema and migrations
Find a file
WessCoby 16d7473122 Newsletter delivery: message_id and bounced_at (MAI-191)
The correlation key and the async marker for asynchronous bounce
ingestion.

message_id is what makes a DSN attributable to one send. A DSN identifies
the original message by Message-ID and nothing else usable; matching on
the recipient address would be wrong, because the same address
legitimately receives every issue — an old bounce could suppress a
current send, and a resend to a repaired mailbox would read as fresh.

UNIQUE rather than a plain index: a DSN resolving to two rows could
suppress against the wrong one and there is no safe way to choose.
Nullable because a delivery is written queued before anything is handed
to the MTA, and rows predating the column have nothing to backfill — a
synthetic id would be a value no DSN can ever match, which is worse than
null.

bounced_at keeps the two kinds of bounce distinguishable: a row rejected
at handoff never reaches sent, so sent_at is null, while one accepted and
bounced later has both. Without it the per-issue report would silently
rewrite an accepted delivery as rejected. It is also the idempotency key —
a replayed DSN finds it set and stops.

Both additive and nullable, so nothing is backfilled and no existing row
changes meaning. Applied to local dev only; the other three databases are
the owner's to migrate.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018UPQokJPGUCoFfzBtNp3zJ
2026-08-22 02:42:18 +00:00
migrations Newsletter delivery: message_id and bounced_at (MAI-191) 2026-08-22 02:42:18 +00:00
schema Newsletter delivery: message_id and bounced_at (MAI-191) 2026-08-22 02:42:18 +00:00
.gitignore Add schema.dbml to .gitignore 2026-07-02 19:41:03 +00:00