← All tools

pgplex/pgschema

Popularity 65 Updated Development & Build

Terraform-style, declarative Postgres schema migration. Agent friendly.

githubauto-collected

Installation

A directly usable install command is not verified yet. Check the project documentation or releases.

[!NOTE] pgplex: The Postgres Toolchain for Humans and Agents - pgconsole · pgschema · pgtui · pgparser Brought to you by Bytebase, open-source database DevSecOps platform.

<a href="https://www.star-history.com/?repos=pgplex%2Fpgschema&type=date&legend=top-left" <picture <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=pgplex/pgschema&type=date&theme=dark&legend=top-left" / <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=pgplex/pgschema&type=date&legend=top-left" / <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=pgplex/pgschema&type=date&legend=top-left" / </picture </a

pgschema is a CLI tool that brings Terraform-style declarative schema migration to PostgreSQL. Instead of writing migration files by hand, you declare the desired schema state and pgschema generates the migration plan automatically.

pgschema dump → edit schema.sql → pgschema plan → pgschema apply
  • Dump: Extract the current database schema as SQL files
  • Plan: Diff your edited schema against the live database, generate migration DDL
  • Apply: Execute with concurrent change detection, transaction-adaptive execution, and lock timeout control

See more details in the introduction blog post.

Watch in action:

Why pgschema

State-based, not migration-file-based

Tools like Flyway and Liquibase require you to write and number migration files manually. pgschema works like Terraform: you declare what the schema should look like, and it figures out the SQL to get there. No migration history table, no manual sequencing.

Deep Postgres support

pgschema is Postgres-only, which means it handles Postgres-specific objects that generic tools skip: row-level security policies, partitioned tables, partial indexes, constraint triggers, identity columns, domain types, default privileges, and column-level grants. See the full list below.

No shadow database required

Most state-based tools spin up a temporary "shadow" database to validate migrations. pgschema uses an embedded Postgres instance internally and cleans up after itself — no extra infrastructure needed.

When to choose pgschema

  • You want a fully free and open-source tool with no feature gating
  • You want to version-control your schema as plain SQL and apply changes declaratively
  • You need Postgres-specific features (RLS, partitioning, complex triggers) tracked in migrations
  • You want migration validation without provisioning a separate shadow database
  • You want a plan/preview step before applying changes, like terraform plan
  • You're migrating from a manual SQL workflow and want structure without an ORM

How it compares

| | pgschema | Flyway / Liquibase | Atlas | |---|---|---|---| | Pricing | Free and open source (Apache 2.0) | Free tier; advanced features paid | Free tier; advanced features paid | | Workflow | State-based (desired state) | Migration-file-based | State-based | | Database support | PostgreSQL only | Multi-database | Multi-database | | Postgres-specific objects | Auto-detected and diffed (RLS, partitioning, triggers, …) | You write the migration SQL manually | Auto-detected and diffed | | Shadow database | Not required | Not required | Required by default | | Migration history table | Not required | Required | Not required |