pgschema
pgschema is an open-source CLI tool that brings Terraform-style declarative schema migration to PostgreSQL. Instead of writing numbered migration files, you declare the desired schema state in SQL, and pgschema automatically diffs and generates the migration DDL. It handles Postgres-specific objects like row-level security, partitioning, and triggers without requiring a shadow database.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | pgplex/pgschema |
| Owner | pgplex |
| Primary language | Go |
| License | Apache-2.0 — OSI-approved |
| Stars | 967 |
| Forks | 58 |
| Open issues | 5 |
| Latest release | v1.12.0 (2026-07-06) |
| Last updated | 2026-07-08 |
| Source | https://github.com/pgplex/pgschema |
What pgschema is
Written in Go, pgschema provides dump/plan/apply workflow for PostgreSQL schema management. It uses an embedded Postgres instance for validation, supports concurrent change detection and transaction-adaptive execution, and covers 14+ schema object types across Postgres versions 14–18. No migration history table or ORM required; schema versioning via plain SQL files.
Get the pgschema source
Clone the repository and explore it locally.
git clone https://github.com/pgplex/pgschema.gitcd pgschema# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Embedded Postgres instance used for validation; ensure build environment has sufficient disk and memory for temporary schema snapshots.
- Requires explicit schema dump and edit cycle; teams must establish clear ownership and review process for schema.sql changes before applying to production.
- Concurrent change detection and lock timeout control are built in, but production apply strategy (transaction mode, rollback handling) should be tested in staging first.
- No migration rollback capability; treat schema.sql as forward-only (similar to Terraform state). Downtime planning for breaking changes (column drops, type changes) is manual.
- CLI-centric; integration into existing CD pipelines (GitHub Actions, GitLab CI, etc.) requires scripting and environment variable management for credentials.
When to avoid it — and what to weigh
- Multi-database environments requiring vendor-agnostic tooling — pgschema is Postgres-only. If your organization manages schema migrations across MySQL, SQL Server, Oracle, or other databases, tools like Atlas or Liquibase are better fits.
- Windows-native deployments without WSL/virtualization — pgschema does not support native Windows; only WSL or Linux VMs are supported. Teams bound to Windows Server or desktop environments will face friction.
- Regulatory environments requiring formal audit trails and fine-grained access control — pgschema itself provides no built-in audit logging, data masking, or multi-role access controls. Organizations with strict compliance or data governance requirements should evaluate Bytebase or equivalent platforms.
- Projects requiring long-term commercial support or SLA guarantees — pgschema is community-supported and sponsored by Bytebase as a free offering with no guarantees. Vendors offering paid support tiers (Flyway, Liquibase) may be more appropriate for mission-critical systems.
License & commercial use
Licensed under Apache License 2.0 (Apache-2.0), a permissive OSI-approved license allowing commercial use, modification, and distribution under the terms stated in the license.
Apache-2.0 permits commercial use without restriction. However, pgschema itself is free and community-supported; no commercial support contract is available from the project. Organizations requiring SLAs, dedicated support, or commercial indemnification should seek vendor-backed alternatives or negotiate support separately. Sponsored by Bytebase (a commercial platform), but pgschema has no current monetization model.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Strong |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Strong |
| Assessment confidence | High |
pgschema itself does not provide audit logging, role-based access control, or data masking. Credentials passed via environment variables or CLI flags; ensure secrets are not committed to version control or exposed in CI/CD logs. Embedded Postgres instance cleans up after validation, but temporary files should be managed securely in production environments. No formal security audit data provided; assess risk based on use case (non-sensitive schema changes lower risk than sensitive data environments).
Alternatives to consider
Atlas
State-based, multi-database support, covers Postgres features. Requires shadow database by default; free tier available with paid advanced features.
Flyway
Migration-file-based, multi-database, widely adopted. Requires manual migration writing and sequencing; free tier with commercial options.
Liquibase
Migration-file-based, multi-database, large ecosystem. Requires manual sequencing; feature-gated pricing model.
Build on pgschema with DEV.co software developers
Try pgschema today—no shadow database, no migration history tables, just declarative schema management in plain SQL. Perfect for teams already using GitOps and infrastructure-as-code practices.
Talk to DEV.coRelated open-source tools
Surfaced by semantic similarity across the DEV.co open-source index.
Related on DEV.co
Explore the category and the services that help you build with it.
pgschema FAQ
Does pgschema require a shadow database?
Can pgschema handle Postgres-specific features like row-level security and partitioning?
Is there a rollback or undo mechanism?
Can pgschema be used in a CI/CD pipeline without manual review?
Software development & web development with DEV.co
Adopting pgschema is usually one piece of a larger software development effort. As a software development agency, DEV.co provides software development services and web development expertise — pairing senior software developers and web developers with your team to design, build, and operate open-source devops software in production.
Ready to streamline your Postgres schema workflow?
Try pgschema today—no shadow database, no migration history tables, just declarative schema management in plain SQL. Perfect for teams already using GitOps and infrastructure-as-code practices.