fix(sqlitestore): move idempotency from separate table to events column #193

Closed
opened 2026-03-06 20:25:22 +00:00 by ash · 0 comments
Owner

Problem

Postgres stores idempotency keys as a column on the events table — atomic, clean, single lookup. SQLite uses a separate idempotency_keys table with comma-separated event IDs — fragile, non-atomic, inconsistent with pgstore.

The idempotency_keys table is always empty unless someone explicitly uses AppendWithOptions. Store parity rule says both backends must behave the same way.

What to do

  1. Add idempotency_key TEXT column to SQLite events table (migration)
  2. Add index: CREATE INDEX idx_events_idempotency_key ON events(stream_type, stream_id, idempotency_key) WHERE idempotency_key IS NOT NULL
  3. Update AppendWithOptions to write idempotency_key to the events row
  4. Update idempotency check to query events table directly (like pgstore)
  5. Drop idempotency_keys table in migration (or leave it for backward compat)
  6. Update conformance tests to verify both backends behave identically

Store parity

Ref: #139

## Problem Postgres stores idempotency keys as a column on the events table — atomic, clean, single lookup. SQLite uses a separate `idempotency_keys` table with comma-separated event IDs — fragile, non-atomic, inconsistent with pgstore. The `idempotency_keys` table is always empty unless someone explicitly uses `AppendWithOptions`. Store parity rule says both backends must behave the same way. ## What to do 1. Add `idempotency_key TEXT` column to SQLite events table (migration) 2. Add index: `CREATE INDEX idx_events_idempotency_key ON events(stream_type, stream_id, idempotency_key) WHERE idempotency_key IS NOT NULL` 3. Update `AppendWithOptions` to write idempotency_key to the events row 4. Update idempotency check to query events table directly (like pgstore) 5. Drop `idempotency_keys` table in migration (or leave it for backward compat) 6. Update conformance tests to verify both backends behave identically ## Store parity Ref: #139
ash closed this issue 2026-03-06 20:29:52 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ash/eskit#193
No description provided.