Your schema files are the source of truth. pgmt tracks dependencies, applies changes instantly, and generates production-ready migrations.
One function changed. pgmt detected 3 dependent views, dropped them in the right order, applied the update, and recreated everything — automatically.
# Shell (macOS/Linux)
curl -fsSL https://pgmt.dev/install.sh | sh
# npm
npm install -g @pgmt/pgmt
# Cargo (from source)
cargo install pgmt# Initialize (new project or from existing database)
pgmt init
pgmt init --dev-url postgres://localhost/my_existing_db
# Edit schema files, then apply to dev
pgmt apply
# Generate migration when ready to ship
pgmt migrate new "add user analytics"
# Deploy to production
pgmt migrate apply --target-url $PROD_DATABASE_URL
# Provision a brand-new environment (demo, staging, DR) from a baseline
pgmt migrate provision --target-url $NEW_ENV_DATABASE_URLEdit 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.
$ pgmt apply --watch
👀 Watching schema/ for changes...
schema/functions/calculate_score.sql changed
📋 8 changes
✓ Drop view public.executive_dashboard
...
✓ Create view public.executive_dashboard
✅ Applied 8 changesWhen 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"
ALTER TABLE 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"
CREATE INDEX CONCURRENTLY idx_users_verified ON users(verified);- Quick Start — Get up and running
- Adopt Existing Database — Import existing schema
- CLI Reference — All commands and options
- Blog — Why schema-as-code?
- Changelog — Notable changes in each release
- PostgreSQL 13+ (tested on 13–18)
- Rust 1.85+ for building from source
./scripts/test-setup.sh # One-time setup
cargo test # Run testsSee the contributing guide for details.
MIT — see LICENSE.