Skip to content

Rebuild a read model

Goal: you changed a projection (added a property, fixed a mapping) and the existing read model still reflects the old logic. You want it rebuilt from the events.

Read models are derived data — the event log is the source of truth. So a read model is always disposable: Chronicle can replay the events through the projection and produce it again from scratch. You never migrate a read model in place; you rebuild it.

  1. Make your projection change and deploy it.

  2. Replay the observer so it reprocesses the event sequence from the beginning and rewrites its read model. Use the Cratis CLI to trigger a replay:

    Terminal window
    cratis chronicle observers replay <observer-id>

    See cratis chronicle observers replay for the full command reference. The Chronicle Workbench can also replay an observer, and clear an observer’s quarantine, from its observers view for a user who is allowed to.

  3. Query the read model and confirm it reflects the new logic.

  • A rebuild reprocesses all matching events, so for very large streams it takes time proportional to the history. Plan rebuilds of big projections accordingly.
  • Reducers rebuild the same way — they’re also derived from events.