---
title: Recipe: Rehearse a database migration · Agent Playground docs
description: Runs a migration on a copy of the data, checks nothing was lost, restores and retries if it was, then asks a person. What it does, when to use it, how to make it yours, and what a run costs.
url: https://www.quietrobot.ai/docs/playground/recipes/migration-rehearsal
---

# Recipe: Rehearse a database migration

Runs a migration on a copy of the data, checks nothing was lost, restores and retries if it was, then asks a person. What it does, when to use it, how to make it yours, and what a run costs.

Rehearses a database change on a copy of the data: saves a restore point, runs the change, checks nothing was lost, restores and tries the next version if it was, and asks a person before anything is run for real.

| At a glance | |
|---|---|
| **Category** | Safety |
| **Shape** | A loop with restore, then a person |
| **Plan** | Free and up |
| **Needs a Claude key** | No |
| **Limits it comes with** | 3 loops, 900 seconds, $0.05 |

```flow
{"title": "Rehearse a database migration, as it is on the canvas.", "nodes": [["load", "run", "Load a sample"], ["backup", "run", "Save a restore point", "go back here"], ["migrate", "run", "Run the migration", "no internet"], ["check", "run", "Anything lost?", "no internet"], ["restore", "run", "Restore, try the next one"], ["approve", "approval", "Run it for real?"], ["plan", "run", "Write the plan"], ["held", "end", "Not run"]], "edges": [["load", "backup"], ["backup", "migrate"], ["migrate", "check"], ["check", "restore", "Failed"], ["restore", "migrate"], ["check", "approve", "Passed"], ["approve", "plan", "Approved"], ["approve", "held", "Denied"]]}
```

<figure class="shot">
  <img class="art-light" src="/docs/playground/recipes/migration-rehearsal-light.webp" alt="The Rehearse a database migration recipe in the builder after a run, with each step's result on the canvas and the run's steps listed on the right." width="1440" height="900" loading="lazy">
  <img class="art-dark" src="/docs/playground/recipes/migration-rehearsal-dark.webp" alt="" width="1440" height="900" loading="lazy">
  <figcaption>A real run of the recipe, waiting at the approval for a person.</figcaption>
</figure>

## When to use it

* Changing the structure of a database you can't afford to break.
* Any risky change you'd like to rehearse on a copy first: a bulk edit, an import, a cleanup.
* You want a written plan of a change that's already been proven on real-looking data.

## Run it

1. Open **Agent Playground** in the dashboard and find **Rehearse a database migration** under **Start from a recipe**. In the builder, **Recipes** in the toolbar lists them too.
2. Choose **Use this recipe**. It becomes a flow of your own, so changing it never changes the recipe.
3. Choose **Simulate** to see the forecast, then **Run**.
4. When the run waits for a person, approve or deny it from the banner, from **Approvals**, or from the approval email.

**What you'll see:** The first version of the change loses data, **Anything lost?** catches it, the data is restored, and the next version passes every check. Then the run waits at **Run it for real?**. Approve and `plan.md` is written with the change that passed. Nothing runs outside the sandbox.

## Make it yours

1. Load a recent, anonymized copy of your data in **Load a sample**.
2. Put your change in **Run the migration**.
3. Write checks that matter to you in **Anything lost?**: row counts, totals of money columns, a few known records.
4. Keep **No internet for this step** on the migration and the checks, so a rehearsal can never touch the real database.
5. Keep the approval. Have the last step write the plan, or hand it to the person who runs changes on the real database.

## What a run costs

These are the builder's own forecast for the recipe as it comes, with its limits, rounded. **Simulate** shows the same numbers for your version, and they change as you change the flow.

| | Typical | 1 in 10 runs | At most |
|---|---|---|---|
| **Sandbox time** | $0.0016 | $0.0023 | $0.01 |
| **How long it takes** | about 2 minutes | about 3 minutes | 900 seconds |

A typical run uses $0.0016 of sandbox time, so about 610 runs cost $1, and every plan includes $5 of usage a month. The time includes a person taking a minute or two to answer the approval. The clock, and the sandbox, keep running while the run waits. **At most** is the most a run could cost with these limits: it stops at $0.05 or 900 seconds, whichever comes first.

## Related

* [Tutorial 2: Ask a person before anything real happens](https://www.quietrobot.ai/docs/playground/tutorials/approvals-and-limits)
* [Tutorial 3: Keep trying until it works](https://www.quietrobot.ai/docs/playground/tutorials/loops)
* [Safety recipes](https://www.quietrobot.ai/docs/playground/recipes/safety)
* [All recipes](https://www.quietrobot.ai/docs/playground/recipes)
