Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Neon 10 min read How-to mediumAdept

Neon Twin: How to deploy a change tested in Neon to prod in RDS

Schema changes tested on Neon database branches can be promoted to an AWS RDS production Postgres database through GitHub Actions that run when a pull request merges. Neon's schema diff shows how a dev branch differs from main. From there, migrations are applied in one of two ways: hand-written dated .sql files that a workflow detects via git diff and runs with psql, or Prisma migrations applied with `prisma migrate deploy`. A follow-up pg_dump/pg_restore job then re-syncs the Neon Twin from production.

Related posts

  • Neon Twin: Move Dev/Test/Staging to Neon, Keep Production on RDS

    Neon mediumAdept

    A Neon Twin is a nightly-synced copy of an RDS Postgres production database kept in Neon for dev, test and staging, so teams get instant provisioning, branching and scale-to-zero without migrating production. A scheduled GitHub Actions workflow installs Postgres, runs pg_dump in custom format against RDS, then pg_restore with --clean, --if-exists, --no-owner and --no-acl into a Neon main branch, with per-engineer branches created from it. Caveats include GitHub Actions' 6-hour job limit (use self-hosted runners for large databases), IP allowlisting problems with GitHub's changing runner IPs, and SSL certificate handling. Co-locating both databases in the same AWS region speeds up the job and cuts egress costs.

  • A database for every preview environment using Neon, GitHub Actions, and Vercel

    Neon mediumAdept

    Neon's copy-on-write branching can give every pull request its own production-like Postgres database, avoiding the bottlenecks of shared staging or shared preview databases. Branches are isolated, are created in about a second regardless of database size, and bill only for unique data. A GitHub Actions pipeline creates a Neon branch per PR, runs Prisma migrations against it, deploys a Vercel preview wired to that branch, and comments the URLs on the PR. Merging applies migrations to the primary branch, deploys to production and deletes the preview branch.

  • Neon Twin: Automate Partial Data Dumps with Postgres and GitHub Actions

    Neon mediumAdept

    A scheduled GitHub Actions workflow can keep a Neon "Twin" refreshed with a partial copy of a production Postgres database. It installs a pinned Postgres version via apt, dumps the schema with pg_dump, extracts row subsets to CSV with psql \copy, then drops and recreates the target schema and restores it with pg_restore. When subsetting related tables, the selection queries must keep foreign keys intact and the restore must load parent tables first. Partial dumps can also reduce PII exposure by leaving out sensitive tables and columns.

  • Adopting Neon branching in CI/CD pipelines: a practical story by Shepherd

    Neon mediumAdept

    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. GitHub Actions call the Neon API to create a branch when a PR opens and delete it on merge. Changes then flow from per-developer and per-PR branches to staging and production, with Render pre-deploy commands applying migrations tracked in a dedicated timestamped table. The team credits branching with removing the cost and effort of keeping test instances synced with production, and notes that scale-to-zero means it no longer pays for idle databases.

  • Track Schema Changes Automatically in Your Pull Requests

    Neon mediumAdept

    Neon's Schema Diff GitHub Action compares the schema of a pull request's Neon child branch against its parent (or a specified base_branch) and posts the result as an SQL patch in a single PR comment. The comment is edited in place on new commits, and nothing is posted when the schemas match. A sample workflow creates a per-PR Neon branch with create-branch-action, runs migrations against it, posts the diff, and deletes the branch when the PR closes. The action also outputs a comment_url for further automation, such as Slack notifications.

The quest for software engineering knowledge.

Look:
Layout: