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
GitHub Actions
GitHub Actions Example Repository
Complete example repository with workflows and sample PRs
Plan GitHub Actions
Generates migration plan on pull requests
Apply GitHub Actions
Applies migrations after merge
Example PR
Live example with plan comments
Plan GitHub Actions
Handles modular schema files
Apply GitHub Actions
Applies modular migrations
Example PR
Multi-file schema changes
- Plan Workflow
- Apply Workflow
.github/workflows/pgschema-plan.yml
GitLab CI
Demonstrates a complete workflow for reviewing and applying schema changes through merge requests..gitlab-ci.yml
Azure Pipelines
Demonstrates a complete workflow for reviewing and applying schema changes through pull requests.azure-pipelines.yml