ProductHow it worksPricingBlogDocsLoginFind Your First Bug
A preview environment's database moving through create, live, and merge stages, then being deleted, with nothing carried forward into production
TestingPreview EnvironmentsTest Data Isolation

What Happens to Preview Environment Data After You Merge?

Tom Piaggio
Tom PiaggioCo-Founder at Autonoma
Preview environment data after merge is discarded, not promoted. A well-run preview environment and its database are torn down the moment the pull request merges or closes, so whatever was created, seeded, or mutated during review never reaches production. The code merges. The data does not.

Every team that adopts per-pull-request environments eventually asks a version of the same question, usually right after their first real merge: where did all that test data just go? It's a fair thing to wonder. A preview can accumulate real activity fast: seeded fixtures, a manually clicked-through checkout flow, a QA reviewer's throwaway account. None of it should still exist an hour after merge, and in a well-run setup, none of it does.

The Short Answer

Nothing persists. When a pull request merges or is closed, its preview environment and any database it provisioned get deleted, not archived and not migrated anywhere. The commit that ships is the code. The data that lived inside the preview while the PR was open never travels with it, because the two were never the same thing to begin with.

That distinction is worth sitting with. A preview environment's database is a byproduct of testing that one PR, not a draft of production. It exists so a reviewer or an automated test can click through a real, running application without touching anyone else's data. Once the PR merges, the code that mattered goes out through the normal deploy pipeline. The preview's database already did its job, and it has nothing further to contribute once that job is done.

The Preview Environment Data Lifecycle

Every preview moves through the same four stages, whether it's backed by a fresh seed, a branched copy, or one of the safer production-shaped patterns teams reach for when they need more realism than a static fixture, a pattern covered in more depth in ephemeral, per-PR environments with tests built in.

StageWhat happensData state
CreatePR opens, environment provisionedFresh, seeded, or branched copy
LiveTests and reviewers use itMutated by whatever runs against it
Merge or closePR merges, or is closed unmergedEnvironment marked for teardown
DiscardedEnvironment and database deletedNothing carried forward
PR opensCreateTests and reviewLivePR mergesMergeTorn downDiscardedProduction is deployed from the merged commit, never from this database

Four stages, one direction. The database that made review possible has nothing left to do once the PR is gone.

What Should Persist After a Merge? (Nothing, by Default)

By default, nothing should carry over, and that's a deliberate property of the design, not a gap in it. Preview data is throwaway on purpose: a seeded fixture set, a synthetic dataset, or a masked or branched copy of production, built to make the preview behave realistically for the duration of one PR. None of those is the source of truth. Production is.

Promoting preview data would invert that relationship. A database mutated by whatever a reviewer clicked, whatever a flaky test half-completed, or whatever a manual QA pass left in a weird state has no business becoming part of production's history. The PR's actual output, the thing that's supposed to persist, is the code diff that got reviewed and merged. The data was only ever there to prove that diff worked. This is really the same underlying question the wider preview environment data isolation discussion covers: isolation matters not just while a PR is open, but at the moment it closes, when the boundary either holds and the preview disappears cleanly, or it doesn't and something lingers that shouldn't.

How Autonoma Turns Teardown Into a Guarantee, Not an Assumption

The gap that causes most of the failure modes below isn't a missing policy. Almost every team already intends to delete preview data after merge. The gap is that intention isn't automation, and automation that only sometimes runs is functionally the same as not having it: the PRs that get closed instead of merged, the branch someone abandoned mid-review, the environment a script was supposed to clean up but silently didn't.

We built our platform around treating teardown as a guarantee tied to the pull request's own lifecycle, not a separate job someone has to remember to trust. At Autonoma, PreviewKit is our managed preview-environments product: it provisions, routes, and tears down full-stack, isolated per-PR previews, including their database isolation. Autonoma's integrated web E2E testing runs against those previews, with Planner setting up database state and Diffs Agent keeping the relevant tests aligned as the PR changes.

Diagram showing a merged commit moving from an isolated preview environment to production while the preview database is deleted

A merge promotes the reviewed code, not the temporary database state that made the review possible.

If the default is deletion, the natural follow-up is whether deletion itself is ever the risky move, and is it safe to delete preview environment data is worth reading on its own: the short version is that the risk almost always runs the other way, toward keeping preview data around longer than it needs to exist, not toward tearing it down too soon.

Failure Modes: Orphaned Preview Data

None of this is theoretical when teardown isn't reliable. An environment that outlives its PR doesn't just sit there harmlessly. It keeps its database running, which is a cost line that never stops accruing for work that finished weeks ago. It keeps whatever credentials and secrets it was issued live and reachable, on infrastructure nobody is actively watching anymore.

If that environment was seeded from a cloned production snapshot, the exposure gets worse: real or near-real customer data can sit behind a low-trust preview URL long after the reason for provisioning it disappeared. Multiply one forgotten environment across a team that ships dozens of PRs a week and you get branch sprawl, a growing set of half-abandoned environments that expand your attack surface without adding any value, each one a small, unmonitored copy of your stack that a leaky link or a stale credential could turn into an actual incident.

The Quotable Version

Preview environment data after a merge is gone, and it's supposed to be. A pull request's environment and its database exist to prove the code works, not to become a draft of production. When the PR merges or closes, that data is torn down along with it: nothing promoted, nothing archived, nothing left running that someone has to remember to clean up later. The teams that get burned aren't the ones who deleted preview data too aggressively. They're the ones whose teardown quietly stopped happening at all. PreviewKit, Autonoma's managed preview-environments product, makes that lifecycle part of the per-PR environment: it provisions the isolated stack, runs integrated web E2E tests against it, and tears it down when the PR merges or closes.

FAQ

No. The merged commit is deployed through the normal production deployment path. The preview database existed only for review and testing, so a well-run preview lifecycle deletes it when the pull request merges or closes instead of promoting its temporary state.

By default, no preview data should persist. Seeded fixtures, test-created accounts, and reviewer changes are temporary state for one pull request. The production database remains the source of truth.

The same teardown rule should apply. A closed pull request no longer needs its preview environment or its database, so both should be removed to avoid orphaned resources, retained credentials, and stale preview data.

Related articles

A production database branching into three safe testing paths: a masked copy, a small subset, and synthetic data generated from the schema shape

How to Test With Real Production Data Safely

How to test with real production data safely: mask PII in a copy, pull a referential subset, or generate synthetic data from the schema shape.

Disposable tenant for testing lifecycle: created, seeded with test data, tested against, then torn down leaving no residue

Disposable Tenants: Spin Up, Test, Throw Away

A disposable tenant for testing is spun up for one test run, seeded, tested against, and torn down. How the workflow works and when to use it.

Two test runs writing to the same table, one scoped to tenant A and one to tenant B, with a tenant_id boundary keeping each test's rows from being visible to the other

How to Isolate Test Data Per Tenant

How to isolate test data per tenant in a multi-tenant SaaS app: tenant-scoped queries, seed factories, a fresh tenant per test, and clean teardown.

Three parallel test runs writing to one shared database, with one run's leftover row causing another run's assertion to fail

The Shared-State Problem in Test Environments (and How to Kill It)

The shared-state problem: parallel tests or previews writing to one database, making failures non-deterministic. Three fixes, and which one fits your team.