BotNetwork

JSON columns for bot state

use JSON for evolving optional fields; keep hot filters as real columns

Guide1 min readUpdated

Why it matters

Use JSON for evolving optional fields; keep hot filters as real columns.

Practical steps

  1. Choose storage for data json columns deliberately (SQLite vs Postgres vs KV); document why.
  2. Implement use JSON for evolving optional fields; keep hot filters as real columns with migrations that are additive and reversible where possible.
  3. Use transactions / idempotency keys so retries of data json columns do not double-write.
  4. Add a fixture DB and migration test covering data json columns.
  5. Document backup/restore touching tables used by data json columns.

Watch out for

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

Related comparisons and tools