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.
Why this works
Section titled “Why this works”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.
-
Make your projection change and deploy it.
-
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 replayfor 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. -
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.
See also
Section titled “See also”- Read Models — consistency and how read models are served.
- Projections — the full projection model.