# pgplex/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.

Source: https://github.com/pgplex/pgschema
Indexed: commit 319b88c on 2026-09-11 by Repowise. Facts come from the source and git history, not from the maintainer.

## Facts

- Type: App
- Language: Go
- Stars: 1,087 at index time
- License: Apache-2.0
- Code health: 6.9/10, Fair
- Last commit: 2026-09-10
- Contributors: 26

## Install

From the README: https://github.com/pgplex/pgschema#installation

Build pgschema with Nix from the flake.
    nix build

Run pgschema with Nix.
    nix run

Pass arguments to pgschema through Nix, for example to run the plan command.
    nix run . -- plan

## How it 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.

- main.go: entry point
- .claude/agents/check.md: central file
- .claude/agents/debug.md: central file
- .claude/agents/dispatch.md: central file
- .claude/agents/implement.md: central file
Modules: testdata, internal, cmd, docs, .trellis, .claude, ir, root. 1,504 files, 78,716 lines, 2,775 symbols.

## Code health

- Score: 6.9/10 (Fair)
- Rank: #156 of 4,000+ indexed repos
- Hotspots: internal/diff/diff.go, internal/diff/table.go, ir/queries/queries.sql.go, ir/normalize.go, ir/inspector.go
- Lowest file: ir/inspector.go
- Dead code: 8 findings

## Maintenance

- Last commit 2026-09-10, first commit 2025-08-19, 501 commits
- 26 contributors, bus factor 1

## Security

- Security findings are shown to signed-in users at https://repowise.dev/repo/pgplex/pgschema/security

## More

- Page: https://repowise.dev/repo/pgplex/pgschema
- Ask this codebase: https://repowise.dev/repo/pgplex/pgschema/chat
- Docs: https://repowise.dev/repo/pgplex/pgschema/docs
- MCP (signs in with Repowise on first use):
    claude mcp add --transport http repowise https://api.repowise.dev/mcp/pgplex/pgschema
