# Old events must still decode

Principle `old-events-must-still-decode`. Retained data needs compatibility rules before recovery depends on it.

Also searched as: schema evolution, replay compatibility.

Historical records remain useful only while consumers can translate their versions. A deployment can break recovery without changing newly produced data.

> Schema evolution ensures that the consumer can translate it to a familiar version.

Source: [Q12](/bibliography#q12); [B5](/bibliography#b5-building-event-driven-microservices), [B14](/bibliography#b14-refactoring-databases).

## Failure it prevents

A new consumer cannot decode already-accepted work.

## Our Effect 4.0.5 reading

Schema.decodeUnknownEffect validates a representation. Define supported versions and transformations; the decoder does not choose the compatibility policy.

Source: `packages/effect/src/Schema.ts`, `packages/effect/src/persistence/PersistedQueue.ts`.

## How to check

Keep old payload fixtures. Decode and restore them with the proposed consumer before removing old representations. This is our proposed verification, not a quoted procedure.

Continue with [Shared schemas need a transition period](/principles/schema-changes-need-a-transition), [Replay needs stable inputs](/principles/replay-needs-stable-inputs).

Connect this to [the existing rat-stack guidance](https://ratstack.sh/lore/schemas-define-the-boundary).

Use [the durability skill](/skills/durability) for the full review. Return to [the durability index](/principles/durability).

## Skills
- [Durability starts with a recovery record](/principles/durability)

## Sources
- Bellemare, Adam. *Building Event-Driven Microservices: Leveraging Organizational Data at Scale*. O’Reilly, 2020. [Link](https://www.oreilly.com/library/view/building-event-driven-microservices/9781492057888/). ([b5-building-event-driven-microservices](/bibliography#b5-building-event-driven-microservices))
- Ambler, Scott W.; Sadalage, Pramod J. *Refactoring Databases: Evolutionary Database Design*. Addison-Wesley, 2006. [Link](https://www.amazon.com/Refactoring-Databases-Evolutionary-paperback-Addison-Wesley/dp/0321774515). ([b14-refactoring-databases](/bibliography#b14-refactoring-databases))

## References
- [Effect contributors. Effect 4.0.5. Schema.ts](https://github.com/Effect-TS/effect/blob/7f524e25cfb49a71ac39b0f44278d08d40dda5de/packages/effect/src/Schema.ts). Pinned source for our Effect mapping, not a claim from the book.
- [Effect contributors. Effect 4.0.5. persistence/PersistedQueue.ts](https://github.com/Effect-TS/effect/blob/7f524e25cfb49a71ac39b0f44278d08d40dda5de/packages/effect/src/persistence/PersistedQueue.ts). Pinned source for our Effect mapping, not a claim from the book.
