---
title: "Keep the history of changing values with · Agent Wranglers"
url: https://agentwranglers.se/playbook/data-engineering/loading-and-change-data-capture/snapshot-history
id: DEN-34
level: Recommended
updated: 2026-10-22
build: a2a6bdfed830
tokens: 1037
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Keep the history of changing values with snapshots

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Loading and change data capture](https://agentwranglers.se/playbook/data-engineering/loading-and-change-data-capture.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-27.

- ID: DEN-34
- Level: Recommended
- Chapter: [Loading and change data capture](https://agentwranglers.se/playbook/data-engineering/loading-and-change-data-capture.md)
- Rule: For source columns that the app overwrites and reports need as they were, such as a customer's plan, take a snapshot on every load. Keep each version with the time it became valid and the time it stopped.
- Check: Change a test customer's plan in the staging source and run the load. The snapshot holds two rows for that customer whose periods do not overlap, and exactly one is current. A model test fails on any key with two current rows.
- How: A load copies today's value, so last quarter's revenue by plan would use today's plans. This kind of history is called a type 2 slowly changing dimension. A transformation tool such as dbt has snapshots that build it. Use the timestamp strategy with an `updated_at` column, or compare listed columns when there is none. Record deletes as their own version. Snapshots cannot be rebuilt from the source, so protect them as [Rehearse restoring a dropped warehouse table](https://agentwranglers.se/playbook/data-engineering/warehouse-and-models/warehouse-restore.md) says. Personal columns in snapshots still follow [Erase people from the warehouse within the month](https://agentwranglers.se/playbook/data-engineering/personal-data-in-the-warehouse/warehouse-erasure.md). When the app already keeps [row history](https://agentwranglers.se/playbook/data/schema-design/row-history.md), load that table instead.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### YAML example

```yaml
snapshots:
  - name: customer_plans
    relation: source('app', 'customers')
    config:
      unique_key: id
      strategy: timestamp
      updated_at: updated_at
      hard_deletes: new_record
```

### SQL example

```sql
-- Revenue by the plan each customer had on the day of the order
SELECT c.plan, sum(o.amount) AS revenue
FROM orders o
JOIN customer_plans c
  ON c.id = o.customer_id
 AND o.ordered_at >= c.dbt_valid_from
 AND o.ordered_at < coalesce(c.dbt_valid_to, '9999-12-31')
GROUP BY c.plan;
```

## Sources

- [dbt snapshots](https://docs.getdbt.com/docs/build/snapshots)

## Related rules

- DEN-33 [Rehearse restoring a dropped warehouse table](https://agentwranglers.se/playbook/data-engineering/warehouse-and-models/warehouse-restore.md) in Data engineering
- DEN-25 [Erase people from the warehouse within the month](https://agentwranglers.se/playbook/data-engineering/personal-data-in-the-warehouse/warehouse-erasure.md) in Data engineering
- DAT-76 [Keep the history of records that settle disputes](https://agentwranglers.se/playbook/data/schema-design/row-history.md) in Data and databases

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/data-engineering/loading-and-change-data-capture/snapshot-history">Agent Wranglers data engineering playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Run pipeline steps by their dependencies](https://agentwranglers.se/playbook/data-engineering/loading-and-change-data-capture/pipeline-dependencies.md)
- Next: [Commit stream offsets in the same transaction as the data](https://agentwranglers.se/playbook/data-engineering/loading-and-change-data-capture/exactly-once-sinks.md)
- [Loading and change data capture](https://agentwranglers.se/playbook/data-engineering/loading-and-change-data-capture.md)
