Skip to main content
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

GitHub Actions

GitHub Actions Example Repository

Complete example repository with workflows and sample PRs
Single-file Schema Workflow

Plan GitHub Actions

Generates migration plan on pull requests

Apply GitHub Actions

Applies migrations after merge

Example PR

Live example with plan comments
Modular Multi-file Schema Workflow

Plan GitHub Actions

Handles modular schema files

Apply GitHub Actions

Applies modular migrations

Example PR

Multi-file schema changes
Example GitHub Actions Workflows
.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