repowiserepowise

App

pgplex / pgschema

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

★ 1,087stars on GitHubGoApache-2.0

This connects Repowise to pgplex/pgschema's code. It does not install pgschema.

Repowise maps public repos from their source. Not affiliated with pgplex. What is Repowise?

github.com/pgplex/pgschemaIndexed at 319b88c

What is pgschema?

pgschema is a CLI tool that brings Terraform-style declarative schema migration to PostgreSQL. You declare the desired schema state in SQL files, and pgschema generates the migration plan that moves a live database to that state. It is written in Go and can also manage config data such as lookup table rows, settings, and feature flags. To install it, run nix build and follow the steps below. Its code health is 6.9 out of 10 (Fair), ranked #145 of 4,000+ indexed repos. The last commit to pgschema was on Sep 10, 2026, and 26 people have contributed.

As of commit 319b88c, indexed Sep 11, 2026. What it is comes from a model reading the README; the rest is measured from the source and git history, not from the maintainer.

For agentspgschema.md

Repo facts: type, license, health, rank, contributors
pgschema facts
TypeApp
LicenseApache-2.0
Code health6.9 / 10 (Fair)
Health rank#145 of 4,000+ indexed repos
Last commitSep 10, 2026
Contributors26
Bus factor1
Size1,504 files, 78,716 lines

Install pgschema

Commands copied from the README

  1. 1Build pgschema with Nix from the flake.
    nix build
  2. 2Run pgschema with Nix.
    nix run
  3. 3Pass arguments to pgschema through Nix, for example to run the plan command.
    nix run . -- plan

Full install notes on GitHub

Explore pgschema

Ask about this code in your agent

This connects Repowise to pgschema's code. It does not install pgschema. To install pgschema, use the install steps.

Useful if you want to change or fork pgschema: your agent can ask how it is put together and get answers that cite its files.

Ask about pgschema

Answers come from pgschema's README and source, with the files they cite. Two free answers a day without an account.

Want this for your own codebase? Map your repo free

About this page

Get a page like this for your own codebase

Repowise built this map of pgplex/pgschema from its source and git history. It parses every symbol, draws the dependency graph, scores each file's health from complexity, duplication, coverage and churn, finds hotspots and owners in the history, and writes documentation for every module. Your coding agent reads the same index over MCP, so its answers cite real files.

Free for 2 public repos, with a page like this one. No card. See how Repowise works

Prefer local? pip install repowise && repowise init indexes your own checkout, no account needed. Star Repowise on GitHub

pgplex/pgschema FAQ

What is pgschema?

pgschema is a CLI tool that brings Terraform-style declarative schema migration to PostgreSQL. You declare the desired schema state and pgschema generates the migration plan automatically.

How does pgschema work?

pgschema dumps the current schema as SQL files, which you edit to the desired state. The plan command diffs the edited schema against the live database, and the apply command executes the resulting DDL.

How do I install pgschema?

pgschema is built and run with Nix using its flake, via nix build or nix run. Windows is not supported, so use WSL or a Linux VM instead. See the install steps

What language is pgschema written in?

pgschema is written in Go, with a small number of shell scripts and Python files.

How is the pgschema code organized?

The cmd directory handles command plumbing, ir inspects and normalizes PostgreSQL catalog objects, and internal/diff computes the differences. main.go is the single entry point.

When should I use pgschema?

Use pgschema when you want to version-control your schema as plain SQL and apply changes declaratively. It suits teams that need Postgres-specific features such as RLS and partitioning tracked in migrations.

What license does pgschema use?

pgschema uses the Apache-2.0 license.

Code health

6.8out of 10Fair

Hotspots average 2.7, the place fixes pay off most.

On the leaderboards:#14 of 28 Go repos

Key features of pgschema

  • Declares the desired schema state and generates the migration plan automatically, instead of requiring hand-written migration files.
  • Supports Postgres-specific objects such as row-level security policies, partitioned tables, partial indexes, constraint triggers, identity columns, and column-level grants.
  • Uses an embedded Postgres instance to validate changes, so no separate shadow database is needed.
  • Manages config data rows listed in pgschema.toml as CSV files and diffs them by primary key.
  • Provides a plan step to preview changes before apply, and apply runs with concurrent change detection and lock timeout control.

How pgplex/pgschema works

The entry point main.go starts the program and hands control to the command layer in cmd, which parses CLI input and loads configuration and ignore rules. The ir directory inspects the live PostgreSQL catalog and normalizes objects such as tables and functions into a stable internal representation, with ir/inspector.go and ir/normalize.go doing this work. The internal/diff directory, including internal/diff/diff.go, compares the desired schema with that representation to decide which changes are needed. The internal/color package then colorizes the plan output, and the testutil directory supplies Postgres test instances and fixtures for integration tests.

The codebase has 1,504 files and 2,775 symbols in 7 modules, led by Go, Shell and Python. Code health is 6.8 out of 10, rated fair.