The Debrief

Give Your Coding Agent a Database Branch

3 min read

The Short Version

A coding agent adds a unique constraint. The migration passes on its local database, where every email address is unique. In production, ten years of imports say otherwise. The agent can show you green tests and still have learned almost nothing about whether the migration will run.

On December 2, AWS announced database branching in preview for Aurora PostgreSQL 17 and later in Ohio, Frankfurt and Mumbai. A developer or CI job can give a pull request its own writable branch of a database. The branch starts by sharing the parent's storage pages and stores its own changes as it goes. It gets a separate endpoint and its own serverless compute, and Aurora deletes it when its configured lifetime expires. AWS announcement · How branches work

Keep the mess that makes the test useful

The good part is that two pull requests can both try a migration without taking turns on a shared staging database. The better part is that the agent gets to see the shape of the problem: duplicates, old status values, and records created before the current validation rules existed. A fixture can reproduce any one of those cases once you know about it. A realistic dataset helps surface the ones you didn't think to write down.

I'd have CI create the branch, run the proposed migration, and attach a short report to the pull request: which checks passed, how many records needed a backfill, and which assumptions failed. Keep the migration file and the report, then drop the branch. AWS's example also applies the migration separately via the deployment pipeline after testing. A successful rehearsal confirms that the script worked on that branch. It doesn't tell you how long it will lock a busy production table; a branch has different compute and doesn't reproduce live traffic. AWS testing workflow · Branch limitations

A separate endpoint is only one boundary

Aurora branches inherit database roles and existing dynamic masking policies. Sharing storage pages doesn't anonymize the records, and a branch expiring doesn't recall data that already ended up in a transcript or CI log. In the email example, the agent needs to know that duplicates exist. It rarely needs to see somebody's actual address. A sanitized source that preserves duplicates can do the job. If you're relying on masking instead, test what the job's actual database role can see, and only bring aggregate results back into the agent's context. AWS branching and inherited controls

I'd start with one migration that has failed on real data before. Give the test runner a branch credential with no production access, keep the deployment credential in the release pipeline, and check that the new test catches the old failure without printing a single customer record. Once that works, you have a place where an agent can be wrong, find out why, and try again before anybody ships its SQL.