An API to Track Database Schema Changes
Neon's Schema Diff feature now has a `compare_schema` API endpoint, available on all plans, that takes two Neon branch IDs and returns a unified diff of their Postgres schemas. The goal is to let AI agents such as Replit Agent and CI/CD pipelines check schema differences programmatically. Optional LSN or timestamp parameters pin a branch to a point in time, but the two are mutually exclusive. The suggested workflow is to apply schema changes on a branch holding a copy of production data, use the API to track discrepancies, then run the migration in production once it has been tested.
Related posts
- 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.
- Neon Twin: How to deploy a change tested in Neon to prod in RDS
Neon mediumAdept
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.
- Behind Modem.dev’s Product Velocity
Neon mediumAdept
Modem, a startup building an AI agent that centralizes user feedback from Slack, Discord and GitHub, uses Neon Postgres branching as its development workflow. Every PR with a migration gets its own database branch, where the migration is applied and a schema diff is posted to the PR. The process is repeated against a fresh branch at merge time to catch conflicting migrations, and each Vercel preview runs on an ephemeral branch with automatic cleanup. Two practical tips: script branching through the Neon CLI so coding agents can drive it, and tag OAuth refresh tokens with the originating branch so preview environments can't invalidate production tokens.
- 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.
- 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.