---
title: "Postgres for Ephemeral Environments: A Method to Keep Data Persistent"
description: "Neon branches, which are copy-on-write clones of a Postgres database, can provide pre-seeded databases for ephemeral PR environments."
url: "https://swe.quest/articles/postgres-for-ephemeral-environments-a-method-to-keep-data-persistent-5ef8547c6782b2cb"
canonical: "https://neon.com/blog/postgres-for-ephemeral-environments"
source: "Neon"
published: "2025-01-07"
difficulty: "easy"
kind: "How-to"
reading_minutes: 7
tags: ["postgres","deployment","ci-cd","testing"]
---

# Postgres for Ephemeral Environments: A Method to Keep Data Persistent

A post on [Neon](https://swe.quest/sources/neon.md), published 2025-01-07, 7 min read, How-to. Original: [https://neon.com/blog/postgres-for-ephemeral-environments](https://neon.com/blog/postgres-for-ephemeral-environments)

## Summary

Neon branches, which are copy-on-write clones of a Postgres database, can provide pre-seeded databases for ephemeral PR environments. Because a branch references the parent's data pages instead of copying them, it is created in seconds whatever the dataset size. Persistent dev and test environments suffer from configuration drift, seed-data maintenance, shared-environment conflicts and idle cost. Ephemeral environments fix most of this but still stall on loading seed data into each database. The proposed workflow keeps sanitized seed data in one main branch and has GitHub Actions create a child branch per pull request, reset it from the parent when needed and delete it on merge, with scale-to-zero limiting cost.

Written by swe.quest, not by the author.

**Difficulty:** Easy: no special background needed; explains what something is and why it matters

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Deployment](https://swe.quest/tags/deployment.md) (Reliability & operations)
- [CI/CD](https://swe.quest/tags/ci-cd.md) (Reliability & operations)
- [Testing](https://swe.quest/tags/testing.md) (Engineering practices)

## Prerequisites

- PostgreSQL basics ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- CI/CD pipelines ([easy posts on CI/CD](https://swe.quest/tags/ci-cd.md?difficulty=easy))

## Keywords

Neon, Neon branching, PostgreSQL, GitHub Actions, copy-on-write

## Related posts

- [Practical Guide to Database Branching](https://swe.quest/articles/practical-guide-to-database-branching-8aa2f63325bcfecb.md): Neon · 2025-12-04 · Medium · 9 min read · PostgreSQL, Databases, CI/CD, Schema migrations, Testing
  Neon's copy-on-write storage makes Postgres database branches instant and cheap: each branch shares the parent's base data, gets its own autoscaling compute that scales to zero, and can be created from any point within the history retention window.
- [Branching Postgres databases with the Neon API](https://swe.quest/articles/branching-postgres-databases-with-the-neon-api-3faf0de941bc811a.md): Neon · 2022-12-07 · Medium · 3 min read · PostgreSQL, CI/CD, Testing
  Neon branches are copy-on-write clones of a Postgres database that can be created and deleted through the Neon API, giving CI pipelines an isolated copy of production data for end-to-end tests.
- [Adopting Neon branching in CI/CD pipelines: a practical story by Shepherd](https://swe.quest/articles/adopting-neon-branching-in-ci-cd-pipelines-a-practical-story-by-shepherd-7c4ee09d2fb5431a.md): Neon · 2024-07-11 · Medium · 5 min read · CI/CD, PostgreSQL, Schema migrations, Testing, Serverless
  Shepherd, an insurtech startup that moved its Alchemist pricing engine from SQLite to Postgres, uses Neon's copy-on-write database branches to give every pull request an ephemeral test database.
- [Beyond Docker Compose: An Alternative for Deploying Postgres for Testing](https://swe.quest/articles/beyond-docker-compose-an-alternative-for-deploying-postgres-for-testing-119ea8d590b0c90d.md): Neon · 2025-02-24 · Medium · 8 min read · PostgreSQL, Testing, Containers, CI/CD
  Docker Compose with the official Postgres image gives each developer and CI run an isolated test database, but it struggles with production-like seed data, leftover state between runs, and RAM/CPU overhead.
- [Fullstack preview environments using Neon and Qovery](https://swe.quest/articles/fullstack-preview-environments-using-neon-and-qovery-5ddb9f5e7c2f931c.md): Neon · 2023-08-11 · Medium · 8 min read · PostgreSQL, CI/CD, Deployment, Serverless
  Each Qovery preview environment can get its own isolated Postgres database by using a Qovery lifecycle job that creates a copy-on-write Neon branch on the environment's Start event and deletes it on Delete.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
