pgmt — PostgreSQL Schema-as-Code
Edit database objects like code. pgmt tracks dependencies, applies changes instantly, and generates production-ready migrations.
Status: Alpha — API may change. Production use requires careful evaluation.

One function changed. pgmt detected 3 dependent views, dropped them in the right order, applied the update, and recreated everything — automatically.
Quick Start
# Initialize (new project or from existing database)
# Edit schema files, then apply to dev
# Generate migration when ready to ship
# Deploy to production
Watch Mode
Edit a schema file, save — your dev database updates instantly. No migration files during development, no manual dependency management. The database finally works like the rest of your development environment.
Production Migrations
When you're done iterating, pgmt migrate new generates an explicit SQL migration file. You review it, edit it if needed, and deploy it. Nothing touches production without your approval.
Multi-section migrations handle the hard stuff — concurrent indexes, data backfills, different timeouts — all in one file with per-section retries:
-- pgmt:section name="add_column" timeout="5s"
users ADD COLUMN verified BOOLEAN;
-- pgmt:section name="backfill" mode="autocommit" timeout="30m"
UPDATE users SET verified = false WHERE verified IS NULL;
-- pgmt:section name="add_index" mode="non-transactional" retry_attempts="10"
(verified);
Documentation
- Quick Start — Get up and running
- Adopt Existing Database — Import existing schema
- CLI Reference — All commands and options
- Blog — Why schema-as-code?
Requirements
- PostgreSQL 13+ (tested on 13–18)
- Rust 1.74+ for building from source
Contributing
See the contributing guide for details.
License
MIT — see LICENSE.