pgmi Documentation#
pgmi is a PostgreSQL-native deployment tool that loads your project files into session temp tables and lets your deploy.sql drive everything — transactions, execution order, and logic. These docs cover the session API, CLI, deployment patterns, testing, security, and operational guides.
Recommended Reading Order#
New to pgmi? Start here:
- Quickstart — Deploy your first project
- Why pgmi — Understand the philosophy
- Session API — Learn the session API
- Trade-offs — Understand the honest costs
Migrating from another tool?
- Coming from other tools — Flyway, Liquibase, psql migration guides
- Quickstart — See pgmi in action
Writing deploy.sql?
- deploy.sql guide — Patterns cookbook (data ingestion, environment branching, multi-phase)
- Session API — Views, columns, and functions reference
Setting up production?
- Connections — Connection architecture (cloud auth, SSL, poolers)
- Security — Secrets and CI/CD patterns
- CI/CD — Deploy from GitHub Actions and other pipelines
- Production — Performance and rollback strategies
- CLI reference — All flags and exit codes
Adding tests?
- Testing
—
CALL pgmi_test()and fixtures
Using the advanced template?
- Script metadata
— Script tracking with
<pgmi-meta> - MCP integration — AI assistant integration
Quick Answers#
| Question | Answer |
|---|---|
| Which view should I use? | pgmi_plan_view for deployment, pgmi_source_view for introspection — see Session API |
| How do I access CLI parameters? | current_setting('pgmi.key', true) — see Session API |
| How do I run tests? | CALL pgmi_test() in deploy.sql — see Testing |
| What’s the difference between templates? | Basic = small migration scaffold, Advanced = richer reference app — both production-capable; see Quickstart |
| How do I filter which files run? | WHERE clause on pg_temp.pgmi_plan_view — see Session API |
| What exit codes does pgmi use? | 0=success, 13=SQL error, etc. — see CLI reference |
All Documentation#
Getting Started#
- Quickstart — Your first deployment (install, configure, deploy, verify)
- Why pgmi — When pgmi’s approach makes sense (and when it doesn’t)
- Coming from other tools — Migration guides from Flyway, Liquibase, and raw psql
Reference#
- CLI reference — Complete CLI reference (commands, flags, exit codes, error messages)
- Configuration — pgmi.yaml schema and precedence rules
- Session API
— Session views and functions (
pg_temp.pgmi_*)
Guides#
- deploy.sql guide — deploy.sql authoring patterns (data ingestion, environment branching, multi-phase)
- Connections — Connection architecture (cloud auth, SSL, poolers, IaC)
- Trade-offs — Honest limitations and who should use pgmi
Features#
- Testing — Database testing with automatic rollback
- Script metadata — Script tracking with UUIDs, idempotency, sort keys
- Security — Secrets handling and CI/CD patterns
- MCP integration — Model Context Protocol for AI assistants
Operations#
- CI/CD — Deploy from GitHub Actions and other pipelines
- Production — Performance, rollback strategies, monitoring
Recipes (advanced, opt-in)#
- Semantic MCP curation — Surface the relevant subset of agent tools by embedding similarity (provider-abstracted; for tool-overload scale)
AI Integration#
pgmi ai # Overview for AI assistants
pgmi ai skills # List embedded skills
pgmi ai skill pgmi-sql # Load SQL conventionsSee CLI.md#pgmi-ai for details.