FREEDOM251

Freedom251 › Database Schema Comparison Tools

pg-schema-diff

Free plan Self-hosted

Visit pg-schema-diff Alternatives

pg-schema-diff's own site

What pg-schema-diff is

pg-schema-diff is a free, self-hosted tool for comparing Postgres schemas and generating SQL migrations. It moves a database toward a desired schema defined in plain DDL, and its command-line interface can also dump an existing database schema as a starting point. The tool uses native Postgres operations for online migrations where possible, including concurrent index builds and online index replacement. Before a plan is applied, it warns about dangerous operations and validates the plan against a temporary database; hazards must be approved when applying a plan. The project describes its partition support as strong. pg-schema-diff is available as a command-line tool and a Go library, installable through Homebrew or the Go toolchain. It supports Postgres 14, 15, 16, and 17. Its migration support has boundaries: only enum types are supported, object renames are treated as a drop followed by an addition, and some migrations may need downtime. Stateful online migration techniques such as shadow tables are not supported. Applications using the library are responsible for applying generated plans. The repository lists the MIT license.

Who it suits

It suits developers and database operators who need to compare Postgres schemas and generate SQL migrations toward a desired schema. It is aimed at teams able to run a self-hosted CLI or use a Go library and work within its supported Postgres versions and migration limits.

What it does well

  • Free and self-hosted.
  • Generates SQL migrations from schema comparisons.
  • Supports declarative target schemas in plain DDL.
  • Uses native online operations where possible.
  • Validates plans against a temporary database.
  • Available as a CLI and Go library.

What to know first

  • Postgres 13 and earlier are unsupported.
  • Only enum types are supported.
  • Some migrations may require downtime.
  • Shadow-table migration techniques are not supported.

Getting started

  1. Install the CLI with Homebrew or the Go toolchain, or use the Go library.
  2. Connect the CLI to Postgres with a connection string.
  3. Dump an existing database schema to use as a starting point, or define the desired schema in plain DDL.
  4. Generate and review the migration plan; approve any hazards when applying it.

Verdict

Choose pg-schema-diff if you need a free, self-hosted way to compare Postgres schemas and create SQL migration plans. Look elsewhere if you need Postgres 13 or earlier, broader type support, or stateful online migration techniques such as shadow tables.

Questions

Is pg-schema-diff free?

Yes. It is free and has a free plan.

Which Postgres versions does it support?

It supports Postgres 14, 15, 16, and 17. Postgres 13 and earlier are unsupported.

How can I install or use it?

It is available as a command-line tool and a Go library. The CLI can be installed with Homebrew or the Go toolchain.

Is pg-schema-diff open source?

The repository lists the project under the MIT license.

What migration limits should I know about?

Only enum types are supported, and renaming an object is treated as dropping it and adding a new one. Some migrations may require downtime, and shadow-table techniques are not supported.

Does the library apply generated plans?

Applications using the library are responsible for applying generated plans.

Facts from pg-schema-diff's own pages

Applying library plans
Applications using the library are responsible for applying generated plans; the README suggests considering an advisory lock or a second approver. · github.com, 8 Oct 2026
Database setup
The CLI connects to Postgres using a connection string and can dump an existing database schema as a starting point. · github.com, 8 Oct 2026
Database versions
The project supports Postgres versions 14, 15, 16, and 17; versions 13 and older are unsupported. · github.com, 8 Oct 2026
Declarative migrations
It migrates a database to a desired schema defined in plain DDL. · github.com, 8 Oct 2026
Delivery
It is available as a command-line tool and a Go library, installable with Homebrew or the Go toolchain. · github.com, 8 Oct 2026
Downtime caveat
Some migrations may require downtime, and stateful online migration techniques such as shadow tables are not supported. · github.com, 8 Oct 2026
Hazard warnings
The tool warns operators about dangerous operations, and hazards must be approved when applying a plan. · github.com, 8 Oct 2026
Interfaces
The project provides a CLI and a Go library, installable through Homebrew or the Go toolchain. · github.com, 8 Oct 2026
License
The repository lists the project under the MIT license. · github.com, 8 Oct 2026
Maker headquarters
Stripe lists its dual headquarters in San Francisco and Dublin. · stripe.com, 8 Oct 2026
Migration limits
Only enum types are supported, and renaming an object is treated as dropping it and adding a new one. · github.com, 8 Oct 2026
Migration safety
It warns operators about dangerous operations and validates plans against a temporary database before they are applied. · github.com, 8 Oct 2026
Online migrations
It uses native Postgres operations for online migrations wherever possible, including concurrent index builds. · github.com, 8 Oct 2026
Online operations
It uses native Postgres operations for online migrations where possible, including concurrent index builds and online index replacement. · github.com, 8 Oct 2026
Partitions
The project describes its partition support as strong. · github.com, 8 Oct 2026
Purpose
pg-schema-diff compares Postgres schemas and generates SQL migrations to move between them with minimal downtime and locks. · github.com, 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. · github.com, 8 Oct 2026
Support
The contribution guide says maintainers will try to respond to bug reports, feature requests, and questions within one week. · github.com, 8 Oct 2026
Supported versions
The project supports Postgres versions 14, 15, 16, and 17; versions 13 and earlier are unsupported. · github.com, 8 Oct 2026
Support status
The project describes itself as early stage and says it has limited capacity to review direct code contributions. · github.com, 8 Oct 2026

Where pg-schema-diff stands on Freedom251

Look at these too