---
title: "pgroll — Zero-Downtime PostgreSQL Migrations | Xata"
description: "Open source tool for zero-downtime, reversible PostgreSQL schema migrations. Multi-version schemas, automated backfills, and instant rollbacks. 6,300+ GitHub stars."
source: "https://xata.io/open-source/pgroll"
---

Zero-downtime, reversible
schema migrations
=================

pgroll makes PostgreSQL schema changes safe by default. No table locks, instant rollbacks, and multi-version schema support — so old and new clients work simultaneously.

[View on GitHub](https://github.com/xataio/pgroll)[Read the docs](https://pgroll.com)

## Schema changes shouldn't be scary

Traditional migration tools force trade-offs between safety and speed. pgroll eliminates that trade-off.

### The problem

- **Table locking.** ALTER TABLE commands can lock large tables for minutes or hours, blocking all reads and writes.

- **Deployment windows.** Schema changes are risky enough that teams delay them to off-peak hours, slowing iteration.

- **Rollback complexity.** Rolling back a migration typically means writing another migration. Under pressure, this goes wrong.

### The pgroll way

- **Online migrations.** All schema changes are performed online. No table locks, no downtime, no maintenance windows.

- **Instant rollback.** Rolling back means dropping views and temporary columns. One command, instant effect, no data loss.

- **Simple workflow.** Old and new schemas are available simultaneously. No multi-step deployment choreography, no temporary compatibility code.

How it works

## The expand-and-contract pattern

pgroll automates a proven pattern for safe schema evolution. Two schema versions coexist, giving you a graceful migration window.

### Multi-version schemas

pgroll uses PostgreSQL views to present two versions of the schema simultaneously. Old clients keep working while new clients use the updated schema — no coordination required.

### Expand-and-contract pattern

Automates the expand-and-contract pattern. Hidden columns are added during expand, old columns dropped during contract. Complex multi-step migrations become a single operation.

### Automated data backfills

Handles data conversion and backfills automatically. No one-time scripts, no manual data manipulation — pgroll manages the entire lifecycle of the migration.

Quickstart

## Get started in five steps

Available via Homebrew, Go install, or prebuilt binaries. Single binary, no external dependencies.

Run pgroll init to set up the internal schema pgroll uses to manage migrations. Non-destructive — works with existing schemas.

Define your schema change as a JSON migration file. pgroll validates it before execution.

pgroll start creates the new schema version alongside the old one. Both are live and serving traffic.

When ready, pgroll complete drops the old version. Or pgroll rollback reverts instantly. Either way, zero downtime.

## Works with any Postgres

pgroll supports PostgreSQL 14.0 and later. Use it with AWS RDS, Aurora, GCP Cloud SQL, Azure Database, Supabase, Neon, or self-hosted instances.

6,300+ GitHub stars

Apache 2.0 license

Single Go binary

Postgres 14+

## Branch your database in seconds

[Get started](https://console.xata.io/signup)[Get in Touch](https://cal.com/team/xata/xata-sales)
