pg-schema-diff
pg-schema-diff is a free, self-hosted tool that compares Postgres schemas and generates SQL migrations to reach a target schema defined in plain DDL.
What pg-schema-diff is
pg-schema-diff is a free, self-hosted tool that compares Postgres schemas and generates SQL migrations to reach a target schema defined in plain DDL. Its CLI can also dump an existing database schema as a starting point. Where possible, it uses native Postgres operations for online changes, including concurrent index builds and online index replacement. Before application, it warns about hazardous operations and checks plans against a temporary database; hazards require approval when applying a plan. The project describes its partition support as strong. It is available as a command-line tool and Go library, installable with Homebrew or the Go toolchain. Supported database versions are Postgres 14 through 17; version 13 and earlier are unsupported. Only enum types are supported, and an object rename is handled as a drop and addition. Some changes may require downtime, and stateful online methods such as shadow tables are not supported. Applications using the library must apply generated plans themselves. The repository uses the MIT license.
Good
- Free and self-hosted
- Generates SQL migrations from plain DDL schemas
- Warns about hazardous operations and validates plans
- Available as a CLI and Go library
- Describes partition support as strong
Watch out
- Supports Postgres 14 through 17 only
- Object renames become a drop and addition
- Some migrations may require downtime
- Library users must apply generated plans
Who it suits
It suits teams managing Postgres schema changes who want SQL migration plans and online operations where possible. It can be used through a CLI or integrated as a Go library.
Verdict
pg-schema-diff offers schema comparison, migration generation, and safeguards for hazardous plans. Its version support and migration limitations matter, especially where renames or downtime-sensitive changes are involved.
The facts
Each one read from pg-schema-diff's own pages, with the date it was checked.
Money
- Applying library plans
- Applications using the library are responsible for applying generated plans; the README suggests considering an advisory lock or a second approver.checked 8 Oct 2026
What it does
- Database setup
- The CLI connects to Postgres using a connection string and can dump an existing database schema as a starting point.checked 8 Oct 2026
- Database versions
- The project supports Postgres versions 14, 15, 16, and 17; versions 13 and older are unsupported.checked 8 Oct 2026
- Declarative migrations
- It migrates a database to a desired schema defined in plain DDL.checked 8 Oct 2026
- Delivery
- It is available as a command-line tool and a Go library, installable with Homebrew or the Go toolchain.checked 8 Oct 2026
- Downtime caveat
- Some migrations may require downtime, and stateful online migration techniques such as shadow tables are not supported.checked 8 Oct 2026
- Hazard warnings
- The tool warns operators about dangerous operations, and hazards must be approved when applying a plan.checked 8 Oct 2026
- Interfaces
- The project provides a CLI and a Go library, installable through Homebrew or the Go toolchain.checked 8 Oct 2026
- License
- The repository lists the project under the MIT license.checked 8 Oct 2026
- Migration limits
- Only enum types are supported, and renaming an object is treated as dropping it and adding a new one.checked 8 Oct 2026
- Migration safety
- It warns operators about dangerous operations and validates plans against a temporary database before they are applied.checked 8 Oct 2026
- Online migrations
- It uses native Postgres operations for online migrations wherever possible, including concurrent index builds.checked 8 Oct 2026
- Online operations
- It uses native Postgres operations for online migrations where possible, including concurrent index builds and online index replacement.checked 8 Oct 2026
- Partitions
- The project describes its partition support as strong.checked 8 Oct 2026
- Purpose
- pg-schema-diff compares Postgres schemas and generates SQL migrations to move between them with minimal downtime and locks.checked 8 Oct 2026
- Security reporting
- The security policy directs vulnerability reports to Stripe’s Vulnerability Disclosure and Reward Program and asks reporters not to open public issues or pull requests.checked 8 Oct 2026
- Support
- The contribution guide says maintainers will try to respond to bug reports, feature requests, and questions within one week.checked 8 Oct 2026
- Supported versions
- The project supports Postgres versions 14, 15, 16, and 17; versions 13 and earlier are unsupported.checked 8 Oct 2026
- Support status
- The project describes itself as early stage and says it has limited capacity to review direct code contributions.checked 8 Oct 2026
The company
- Maker headquarters
- Stripe lists its dual headquarters in San Francisco and Dublin.checked 8 Oct 2026
Alternatives to pg-schema-diff
- 1
dbForge Studio for PostgreSQL
Free planLinuxmacOSWindows7.5From $89.95 a year - 2

GitHub CodeQL
Free planWebExtensionLinuxmacOS7.5From $30 a month - 3
driftcurve
Free planOpen sourceWebAPISelf-hosted7.1Free plan - 4

Skeema
Free planLinuxmacOSWindows6.9From $649 a year - 5
SQL Delta
Windows6.8$185 one-time - 6

Altova DiffDog
Windows6.3$189 one-time
