Skip to main content

max / makenotwork

657 B · 10 lines History Blame Raw
1 -- Idempotency key for internally-created replies, mirroring threads.external_ref
2 -- (m021). The internal `POST /internal/threads/{id}/posts` path is server→server
3 -- and retry-prone (network blip, MNW-side retry, or a replayed request); without
4 -- a dedup key a retry inserts a duplicate reply. The unique index makes a repeat
5 -- insert with the same ref a no-op (ON CONFLICT DO NOTHING in the mutation),
6 -- matching the thread path. Partial so user-facing replies (external_ref NULL)
7 -- are unconstrained.
8 ALTER TABLE posts ADD COLUMN external_ref TEXT;
9 CREATE UNIQUE INDEX idx_posts_external_ref ON posts (external_ref) WHERE external_ref IS NOT NULL;
10