quiet robot

Agent Playground

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.

View as Markdown

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 glanceNotes
CategorySafety
ShapeA loop with restore, then a person
PlanFree and up
Needs a Claude keyNo
Limits it comes with3 loops, 900 seconds, $0.05
Rehearse a database migration, as it is on the canvas.Load a sample (Run command), Save a restore point (Run command), Run the migration (Run command), Anything lost? (Run command), Restore, try the next one (Run command), Run it for real? (Approval), Write the plan (Run command), Not run (Output). Arrows: Load a sample to Save a restore point; Save a restore point to Run the migration; Run the migration to Anything lost?; Anything lost? to Restore, try the next one on Failed; Restore, try the next one to Run the migration; Anything lost? to Run it for real? on Passed; Run it for real? to Write the plan on Approved; Run it for real? to Not run on Denied.FailedPassedApprovedDenied>_ RUN COMMANDLoad a sample>_ RUN COMMANDSave a restore pointgo back here>_ RUN COMMANDRun the migrationno internet>_ RUN COMMANDAnything lost?no internet>_ RUN COMMANDRestore, try the next one✋ APPROVALRun it for real?>_ RUN COMMANDWrite the plan⚑ OUTPUTNot run
Rehearse a database migration, as it is on the canvas.
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.
A real run of the recipe, waiting at the approval for a person.

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.

NotesTypical1 in 10 runsAt most
Sandbox time$0.0016$0.0023$0.01
How long it takesabout 2 minutesabout 3 minutes900 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.

  • Agent PlaygroundQuickstart: build and run your first flow
  • Agent PlaygroundBlocks
  • Agent PlaygroundRecipes
  • SandboxesQuickstart: your first sandbox
  • SandboxesMCP server
  • SandboxesAPI reference