Previously: In Change Naming Conventions, we learned how to organize changes with nested paths. Now let's explore plan files and how pgpm generates them.
The plan file tracks every change in your module. pgpm can automatically generate it from your SQL files, or you can manage it manually with pgpm add.
Plan File Format
Every module has a pgpm.plan file:
Format: change_name [dependencies] timestamp author <email> # optional note
Two Workflows
Production: Add Changes Incrementally
pgpm updates the plan file automatically. Add changes like commits in version control.
Pre-Production: Generate from SQL
Write SQL first for more flexibility. Add -- requires: comments:
Then generate the plan:
pgpm scans your SQL files, builds the dependency graph, and updates pgpm.plan.
Note:
pgpm planregenerates the entire plan. In production, usepgpm addto append changes without regenerating history.
Key Takeaways
pgpm addadds changes manually to the planpgpm planauto-generates plans from-- requires:comments in SQL- Use
pgpm addfor production,pgpm planfor early development
