# DBLab vs pg-schema-diff: plan an online change, then run it on a clone

> pg-schema-diff by Stripe diffs a target schema against PostgreSQL and plans online DDL with hazards. DBLab runs the plan on a full-size clone and measures its locks.

Checked on 2026-11-18. Page: https://postgres.ai/compare/dblab-vs-pg-schema-diff. All comparisons: https://postgres.ai/compare.

## Short answer

pg-schema-diff is an open-source Go library and CLI from Stripe. You describe the schema you want in plain DDL; it diffs it against a database and generates a plan that uses online operations such as concurrent index builds and NOT VALID constraints, with hazards for anything risky. It validates the plan on a temporary database that has the same schema but no data. DBLab does not plan or deploy changes; it gives you a full-size clone. Together: generate the plan with pg-schema-diff and apply it to a DBLab clone to see its duration and locks on real data before production.

## What DBLab adds to pg-schema-diff

1. **Runs the migration on full-size data.**
   - DBLab: DB Migration Checker applies pending migrations to a full-size clone in CI and collects statistics from the run. ([DB Migration Checker](https://postgres.ai/docs/database-lab/db-migration-checker))
   - pg-schema-diff: pg-schema-diff validates a plan on a temporary database with an identical schema: the code creates the schema in an empty database and runs the plan there with timeouts ignored, so validation does not use your data. [4][3]
2. **Measures the locks a migration holds.**
   - DBLab: The checker fails a migration that holds a dangerous lock longer than a limit, 10 seconds by default. ([DB Migration Checker](https://postgres.ai/docs/database-lab/db-migration-checker))
   - pg-schema-diff: pg-schema-diff marks statements with hazards such as ACQUIRES_ACCESS_EXCLUSIVE_LOCK and INDEX_BUILD and sets a lock_timeout per statement. The hazards are predicted at plan time; the README says not all migrations will be lock-free. [1][2]
3. **Run it again from the same state.**
   - DBLab: On a clone, reset returns the data to the snapshot, so a migration can be run again. ([How to reset a DBLab clone](https://postgres.ai/docs/dblab-howtos/cloning/reset-clone))
   - pg-schema-diff: pg-schema-diff applies a plan to the database you point it at, and its README example warns that a failed statement may leave the database in a dirty state. The sources we reviewed do not describe resetting data between runs. [1][5]

## Try a clone before you install anything

```
dblab clone create --username dev --password "$PASSWORD" --id test
```

The public demo runs DBLab Engine: open it with the token demo-token, create a clone and connect to it. DBLab Engine is open source, so the next step is a machine of your own.

- [Open the DBLab demo](https://demo.dblab.dev)
- [Install DBLab Engine](https://postgres.ai/docs/dblab-howtos/administration/install-dle-manually)

## Side by side

| | DBLab | pg-schema-diff |
|---|---|---|
| What it is | Thin clones of a full-size PostgreSQL database, used to run a schema change on real data before it ships. DBLab does not write, order or deploy migrations. | A Go library and CLI that computes the differences between Postgres schemas and generates the SQL to migrate from one to the other with minimal downtime and locks. The desired schema is defined in plain DDL. The README says the project is in its early stages. [1] |
| Runs the change on full-size data | Runs on full-size data: yes. DB Migration Checker applies pending migrations to a full-size clone in CI and collects statistics from the run. | Runs on full-size data: partly. Plan validation runs the migration against a temporary database with the same schema as the original and checks that it reaches the target schema. The code creates that schema in an empty database and runs the plan with timeouts ignored, so validation does not test against your data. [1][3][4] |
| Lock and downtime risk | Measures locks: yes. Measured on the clone: the checker fails a migration that holds a dangerous lock longer than a limit, 10 seconds by default. | Measures locks: partly. Predicted at plan time, not measured. Statements carry hazards such as ACQUIRES_ACCESS_EXCLUSIVE_LOCK, ACQUIRES_SHARE_LOCK, INDEX_BUILD and DELETES_DATA, and the plan sets lock_timeout and statement_timeout for each statement. The README says not all migrations are lock-free and some may need downtime. [1][2] |
| Static review and lint rules | Lint rules: no. None. DBLab runs the change; it does not lint SQL. | Lint rules: partly. The sources we reviewed do not describe lint rules for SQL you write; pg-schema-diff writes the SQL itself. Its review step is the hazard list attached to each generated statement, which apply checks against the hazards you allow. [1][2][5] |
| Writing, versioning and deploying migrations | Deploys migrations: no. Not provided. Keep your migration tool; a clone is an ordinary PostgreSQL server that any tool can connect to. | Deploys migrations: yes. Declarative: dump an existing schema, edit the DDL files, then plan and apply against a database by connection string. Library users apply the plan themselves; the README leaves plan application up to the user. Renames are treated as a drop and an add, and of custom types only enums are supported. [1][4] |
| Approvals and audit trail | Approval workflow: no. Not a change-approval system. DBLab EE adds SSO, user management and audit for access to clones. | Approval workflow: partly. apply fails if the plan contains hazards not listed in --allow-hazards, and prompts for confirmation unless --skip-confirm-prompt is set. The README suggests a second user may approve a plan before it is applied. An audit trail is not documented in the sources we reviewed. [1][5] |
| Rollback | Not provided for production. On a clone, reset returns the data to the snapshot, so a migration can be run again. | Not documented in the sources we reviewed. Statements marked DELETES_DATA warn that a change removes data. [1][2] |
| CI integration | The checker runs in CI; the documented example uses GitHub Actions. Any pipeline can also create clones through the API or CLI. | Not documented in the sources we reviewed. pg-schema-diff is a CLI and a Go library that connect to Postgres by connection string. [1][4] |
| Open source and hosting | Open source: yes. Open source under Apache 2.0, self-hosted in any cloud or on-premises. | Open source: yes. Open source under the MIT license, from Stripe. Install the CLI with Homebrew or go install, or use it as a Go library. Version 1.0.9 was released on August 6, 2026. [1][2][6] |

## What pg-schema-diff does that DBLab does not

- Declarative: you keep the target schema as DDL files, and pg-schema-diff works out the statements to get there. DBLab does not write or order migrations.
- Plans use online operations: concurrent index builds, new indexes built before old ones are dropped, CHECK and foreign key constraints added NOT VALID then validated, NOT NULL via a check constraint.
- Each plan statement carries its own statement_timeout and lock_timeout, and risky statements carry hazards such as ACQUIRES_ACCESS_EXCLUSIVE_LOCK, INDEX_BUILD or DELETES_DATA.
- apply refuses a plan whose hazards are not listed in --allow-hazards, and asks for confirmation before it runs.
- It is a Go library as well as a CLI, so it can be built into your own deploy tooling.

## Pricing

| Product | Plan | List price | Notes |
|---|---|---|---|
| DBLab | DBLab Engine | Free | Open source, Apache 2.0; you run it |
| DBLab | DBLab SE | From $62/month | Billed hourly by machine size, plus your own cloud costs; 2,000 GiB limit; single user |
| DBLab | DBLab EE | Custom | Annual contract, from $0.2662 per 100 GiB per hour; unlimited database size, SSO |
| pg-schema-diff | Open source | Free | MIT license [1] |

DBLab prices: https://postgres.ai/pricing.

## Using both

pg-schema-diff produces the statements; DBLab shows what they do on real data. Point pg-schema-diff plan or apply at a DBLab clone with --from-dsn: the plan is generated against the clone's schema and applied with its own lock and statement timeouts to a full-size copy of the data. You see how long the concurrent index builds and constraint validations take and whether any statement hits a timeout. Reset the clone and try again. Then run apply against production, which plans again from the production schema. pg-schema-diff lists PostgreSQL 14 to 17 as supported, so the clone should run one of those versions.

## Questions

### Is pg-schema-diff open source?

Yes. Stripe publishes it on GitHub under the MIT license, as a CLI and a Go library. The README says the project is in its early stages and the maintainers have limited time to review direct code contributions. [1]

### Does pg-schema-diff test a migration on real data?

Not by itself. Plan validation runs the plan on a temporary database with an identical schema and no data, and checks that the result matches the target schema. To see duration and locks on real data, apply the plan to a full-size copy such as a DBLab clone. [3][4]

### Which PostgreSQL versions does pg-schema-diff support?

14, 15, 16 and 17. The README says 13 and older are not supported. [1]

### Can I use DBLab and pg-schema-diff together?

Yes. A DBLab clone is an ordinary PostgreSQL server, so pg-schema-diff can plan and apply against it by connection string. Run the plan on the clone to measure it, reset the clone, then run apply against production. [1]

## Sources for DBLab

- [DB Migration Checker](https://postgres.ai/docs/database-lab/db-migration-checker)
- [How to reset a DBLab clone](https://postgres.ai/docs/dblab-howtos/cloning/reset-clone)
- [DBLab Engine](https://postgres.ai/docs/database-lab)
- [Database migration testing](https://postgres.ai/products/database-migration-testing)

## Sources for pg-schema-diff

1. [pg-schema-diff repository and README](https://github.com/stripe/pg-schema-diff)
2. [pg-schema-diff Go package docs: diff](https://pkg.go.dev/github.com/stripe/pg-schema-diff/pkg/diff)
3. [pg-schema-diff source: plan generator and validation](https://raw.githubusercontent.com/stripe/pg-schema-diff/main/pkg/diff/plan_generator.go)
4. [pg-schema-diff source: plan command](https://raw.githubusercontent.com/stripe/pg-schema-diff/main/cmd/pg-schema-diff/plan_cmd.go)
5. [pg-schema-diff source: apply command](https://raw.githubusercontent.com/stripe/pg-schema-diff/main/cmd/pg-schema-diff/apply_cmd.go)
6. [pg-schema-diff releases](https://github.com/stripe/pg-schema-diff/releases)

## How we compare

These pages compare what each product does for PostgreSQL; other databases and the rest of the stack are out of scope. What we say about the other product comes from its own documentation, pricing page, changelog or source repository, read on the date shown; each row cites its source. "Not documented" means we did not find it in those sources, not that the product cannot do it. Prices are list prices and the billing units differ, so they are not a total-cost comparison. Product names are trademarks of their owners.
