Skip to content

Replay a projection

You changed how a read model is built — added a field, fixed a mapping, reshaped the projection — and now the existing read model is out of date. Because the events are still the source of truth, you don’t migrate the read model: you replay the observer and let it rebuild from history.

Projections, reducers, and reactors are all observers. List them and grab the id of the one whose read model you changed:

Terminal window
cratis chronicle observers list --type projection

Use -q to get just the ids if you want to script it:

Terminal window
cratis chronicle observers list --type projection -q
Terminal window
cratis chronicle observers replay <OBSERVER_ID>

The command asks for confirmation first — replay re-processes every event the observer subscribes to. In an automated pipeline, skip the prompt:

Terminal window
cratis chronicle observers replay <OBSERVER_ID> --yes

Replay runs in the background. Watch the health view refresh until the observer reaches the tail:

Terminal window
cratis chronicle diagnose --watch

Or check the observer’s sequence position directly:

Terminal window
cratis chronicle observers show <OBSERVER_ID>

The observer’s sequence number matches the event log tail and its read model reflects the new shape. Spot-check the rebuilt data with read-models or by reading the events it was built from.