---
title: "Test migrations on a copy of production · Agent Wranglers"
url: https://agentwranglers.se/playbook/data/migrations/test-migrations
updated: 2026-10-20
licence: "All rights reserved"
---

# Test migrations on a copy of production data

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Required
- Chapter: [Migrations](https://agentwranglers.se/playbook/data/migrations)
- Rule: Run each migration on a recent copy of production data before it reaches production, and time it.
- How: Restore last night's backup to a staging database on the production side, so personal data never leaves it. Or use a [masked copy](https://agentwranglers.se/playbook/data/personal-data/masked-copies). Run the pending migrations and the test suite. Production data finds the rows that break a new constraint, and the time shows how long locks last.
- Check: The deploy pipeline shows a passed migration run on the copy, with its duration, before the production step.

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers data playbook: https://agentwranglers.se/playbook/data/migrations/test-migrations`.

- Previous: [Keep migrations from locking tables](https://agentwranglers.se/playbook/data/migrations/lock-safe-migrations)
- Next: [Fix production data with reviewed scripts](https://agentwranglers.se/playbook/data/migrations/data-fixes)
- [Migrations](https://agentwranglers.se/playbook/data/migrations)
