pg-schema-diff
github.com
- Free plan
- Self-hosted
What pg-schema-diff is
pg-schema-diff is a free, self-hosted tool for comparing Postgres schemas and producing SQL migrations toward a desired design. The target schema can be defined in plain DDL, and its command-line interface can dump an existing database schema as a starting point. The project uses native Postgres operations for online migrations where possible, including concurrent index builds and online index replacement. It warns about hazardous operations and validates migration plans against a temporary database before application; hazards require approval when applying a plan. pg-schema-diff is available as a CLI and a Go library, installable through Homebrew or the Go toolchain. It supports Postgres 14, 15, 16, and 17, while versions 13 and earlier are unsupported. Only enum types are supported, and renaming an object is handled as dropping it and adding another. Some migrations may still require downtime, and shadow-table techniques are not supported. Library users must apply generated plans themselves. The repository uses the MIT license and describes the project as early stage.
Who it suits
pg-schema-diff suits teams managing self-hosted Postgres databases that want declarative SQL migrations and schema drift detection. It requires operators to handle plan application and unsupported migration cases.
Good to know, and what to watch
- Generates SQL migrations from schema differences
- Validates plans against a temporary database
- Warns about dangerous operations before application
- Supports concurrent index builds where possible
- Offers both CLI and Go library interfaces
- Postgres 13 and earlier are unsupported
- Only enum types are supported
- Renames become a drop and a new object
- Some migrations may require downtime
The verdict
pg-schema-diff provides guarded, declarative migrations for supported Postgres versions. Check its migration limits and operational responsibilities before adopting it.
What the maker publishes
- Applying library plans
- Applications using the library are responsible for applying generated plans; the README suggests considering an advisory lock or a second approver. source
- Database setup
- The CLI connects to Postgres using a connection string and can dump an existing database schema as a starting point. source
- Database versions
- The project supports Postgres versions 14, 15, 16, and 17; versions 13 and older are unsupported. source
- Declarative migrations
- It migrates a database to a desired schema defined in plain DDL. source
- Delivery
- It is available as a command-line tool and a Go library, installable with Homebrew or the Go toolchain. source
- Downtime caveat
- Some migrations may require downtime, and stateful online migration techniques such as shadow tables are not supported. source
- Hazard warnings
- The tool warns operators about dangerous operations, and hazards must be approved when applying a plan. source
- Interfaces
- The project provides a CLI and a Go library, installable through Homebrew or the Go toolchain. source
- License
- The repository lists the project under the MIT license. source
- Maker headquarters
- Stripe lists its dual headquarters in San Francisco and Dublin. source
- Migration limits
- Only enum types are supported, and renaming an object is treated as dropping it and adding a new one. source
- Migration safety
- It warns operators about dangerous operations and validates plans against a temporary database before they are applied. source
- Online migrations
- It uses native Postgres operations for online migrations wherever possible, including concurrent index builds. source
- Online operations
- It uses native Postgres operations for online migrations where possible, including concurrent index builds and online index replacement. source
- Partitions
- The project describes its partition support as strong. source
- Purpose
- pg-schema-diff compares Postgres schemas and generates SQL migrations to move between them with minimal downtime and locks. source
- 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. source
- Support
- The contribution guide says maintainers will try to respond to bug reports, feature requests, and questions within one week. source
- Supported versions
- The project supports Postgres versions 14, 15, 16, and 17; versions 13 and earlier are unsupported. source
- Support status
- The project describes itself as early stage and says it has limited capacity to review direct code contributions. source
Checked against the maker's pages on 8 Oct 2026.