pgschema integrates seamlessly with GitOps workflows, providing a declarative approach to database schema management that fits naturally into your existing CI/CD pipelines.
The typical workflow follows a review-then-apply pattern that ensures all schema changes are properly reviewed before being applied to production.
1
Development Phase
Developers modify schema files in their feature branch
Schema changes are committed alongside application code
The desired state is expressed declaratively in SQL files
2
Pull/Merge Request Review
When a PR/MR is opened, CI automatically runs pgschema plan
The plan output shows exactly what changes will be applied
The plan is posted as a comment on the PR/MR for review
Reviewers can see:
What tables, indexes, functions will be added/modified/dropped
The exact SQL statements that will be executed
Whether changes can run in a transaction
Any potentially destructive operations
3
Approval and Merge
Once reviewers approve the schema changes
The PR/MR is merged to the target branch (e.g., main, production)
4
Deployment Phase
After merge, CD pipeline automatically runs pgschema apply
The apply command uses the reviewed plan to execute migrations
Schema changes are applied to the target database
The deployment includes safety checks for concurrent modifications