Skip to main content

max / makenotwork

464 B · 9 lines History Blame Raw
1 -- Push idempotency: prevent duplicate entries from client retries.
2 -- batch_id is a client-generated UUID per push batch.
3 -- The unique constraint on (app_id, user_id, batch_id) ensures at-most-once semantics.
4
5 ALTER TABLE sync_log ADD COLUMN batch_id UUID;
6
7 -- Unique constraint for dedup. NULL batch_id (old clients) is ignored by unique constraints.
8 CREATE UNIQUE INDEX idx_sync_log_batch_id ON sync_log (app_id, user_id, batch_id) WHERE batch_id IS NOT NULL;
9