BotNetwork

Idempotent upserts for bot state

upsert on natural keys from platform event ids

Guide1 min readUpdated

Why it matters

Upsert on natural keys from platform event ids.

Practical steps

  1. Choose storage for data idempotent upserts deliberately (SQLite vs Postgres vs KV); document why.
  2. Implement upsert on natural keys from platform event ids with migrations that are additive and reversible where possible.
  3. Use transactions / idempotency keys so retries of data idempotent upserts do not double-write.
  4. Add a fixture DB and migration test covering data idempotent upserts.
  5. Document backup/restore touching tables used by data idempotent upserts.

Watch out for

  • Copy-pasting outdated snippets for data idempotent upserts without re-reading current official docs.
  • Shipping data idempotent upserts to production without a staging rehearsal and a documented rollback.

Related comparisons and tools