pgpm is a powerful and opinionated command-line interface (CLI) for managing PostgreSQL database schemas, migrations, and modules, akin to a package manager for your database. It is designed for modular PostgreSQL development, enabling the creation and management of reusable database packages with dependency resolution and semantic versioning. The tool features a deterministic migration engine, offering version-controlled, plan-driven deployments with rollback capabilities and idempotent execution. It supports recursive module resolution across workspaces and provides turnkey module-first workspaces ready for CI/CD, Docker, and end-to-end testing with TypeScript tooling. The current stable version is 4.16.3, and it appears to be actively maintained with a focus on robust and reproducible database development workflows.
npm install pgpmVerified import paths — ran on the pinned version, not inferred.
Demonstrates global installation, starting a local PostgreSQL instance via Docker, initializing a workspace and a module, adding a basic migration, and deploying changes to the database.
Consult the official `pgpm` release notes for your target version and update migration scripts or project configurations as specified. Back up your database and codebase before any major upgrade.
Use `eval "$(pgpm env)"` after `pgpm docker start` or manually set `PG*` environment variables in your shell. For CI/CD, configure these variables in your pipeline environment.
Ensure your `pgpm` workspace and module definitions conform to the latest recursive module resolution standards. Use `pgpm init` and `pgpm install` to correctly scaffold and manage module dependencies.
Always use `pgpm`'s migration system to introduce schema changes. If a mismatch occurs, investigate the differences in your migration files and the applied schema. You may need to revert, fix, and re-deploy, or in rare cases, manually synchronize the migration state, understanding the associated risks.
Verify that your PostgreSQL database is running and accessible. Check your `PGHOST`, `PGPORT`, `PGUSER`, `PGPASSWORD`, and `PGDATABASE` environment variables. If using Docker, ensure `pgpm docker start` was successful and `eval "$(pgpm env)"` was run.
Do NOT modify migration files after they have been deployed to a shared environment. If this occurred in development, revert the changes, or if necessary, reset your local database state and re-deploy. For production, a new 'reverting' migration or a data patch might be needed, with careful planning.
Ensure the module name is correct. If it's a public module, run `pgpm install @pgpm/my-module`. If it's a local module within your workspace, verify its `package.json` and directory structure. Check your `pgpm.json` configuration for correct module paths.
Run `pgpm deploy` to apply the pending migrations to your database. If you expect the database to be up-to-date, run `pgpm verify` to identify which migrations are pending or if there's a discrepancy.
No dependency data recorded yet.