PHPackages                             jawbfl/dbdiff - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. jawbfl/dbdiff

ActiveProject[Database &amp; ORM](/categories/database)

jawbfl/dbdiff
=============

v2.0.1(3mo ago)73216159[39 issues](https://github.com/DBDiff/DBDiff/issues)[16 PRs](https://github.com/DBDiff/DBDiff/pulls)MITPHPPHP &gt;=7.3CI passing

Since Apr 6Pushed 1mo ago37 watchersCompare

[ Source](https://github.com/DBDiff/DBDiff)[ Packagist](https://packagist.org/packages/jawbfl/dbdiff)[ RSS](/packages/jawbfl-dbdiff/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)DependenciesVersions (21)Used By (0)

[![DBDiff logo](https://avatars3.githubusercontent.com/u/12562465?s=200&v=4)](https://dbdiff.github.io/DBDiff/)

 [![Build Status](https://github.com/DBDiff/DBDiff/actions/workflows/tests.yml/badge.svg)](https://github.com/DBDiff/DBDiff/actions/workflows/tests.yml) [![Total Downloads](https://camo.githubusercontent.com/44de1558412511677f7046ccce0697c1ab0d0c67f66479de04db57cb6b2dee45/68747470733a2f2f706f7365722e707567782e6f72672f6462646966662f6462646966662f646f776e6c6f616473)](https://packagist.org/packages/dbdiff/dbdiff) [![Monthly Downloads](https://camo.githubusercontent.com/45a338856206d971bb110172d2dc731787a04da99a7d3a4c407488bbb7ccff46/68747470733a2f2f706f7365722e707567782e6f72672f6462646966662f6462646966662f642f6d6f6e74686c79)](https://packagist.org/packages/dbdiff/dbdiff) [![](https://camo.githubusercontent.com/fd662b08e30002a39a03dfff5c3ac8b95b2d9a43f80b2f013592cb6b45ecb643/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f6462646966662f6462646966662e737667)](https://github.com/dbdiff/dbdiff/graphs/contributors) [![License](https://camo.githubusercontent.com/431277db80dec69bc9f5fbe3dbb39401d051a05ba30202e2088829f8bc6ccae4/68747470733a2f2f706f7365722e707567782e6f72672f6462646966662f6462646966662f6c6963656e7365)](https://packagist.org/packages/dbdiff/dbdiff)

 **DBDiff** is an automated database schema and data diff tool. It compares two databases, local or remote, and produces a migration file of the differences automatically.

 When used alongside a [compatible database migration tool](#compatible-migration-tools), it can help enable database version control within your team or enterprise.

Features
--------

[](#features)

- Compares two databases (local or remote) and generates SQL migrations automatically
- Diffs schema changes, data changes, or both — with deterministic, predictable output
- Up and down SQL generated in the same file
- Supports MySQL, PostgreSQL, and SQLite via `--driver`
- [Supabase](https://supabase.com)-ready via `--supabase` one-flag shorthand
- Works with [Flyway, Liquibase, Laravel Migrations, and more](#compatible-migration-tools)
- Ignore specific tables or fields via a YAML config file
- Unicode / UTF-8 aware
- Fast — tested on databases with millions of rows
- Runs on Windows, Linux and macOS (command-line / Terminal)

Supported Databases
-------------------

[](#supported-databases)

*Other versions may work but are not actively tested. PRs to add official support are welcome.*

### MySQL

[](#mysql)

VersionStatusMySQL 8.0.x✅ SupportedMySQL 8.4.x (LTS)✅ SupportedMySQL 9.3.x (Innovation)✅ SupportedMySQL 9.6.x (Innovation)✅ Supported### PostgreSQL

[](#postgresql)

Use `--driver=pgsql` (or `driver: pgsql` in your `.dbdiff` config).

VersionStatusPostgreSQL 14.x✅ SupportedPostgreSQL 15.x✅ SupportedPostgreSQL 16.x (LTS)✅ SupportedPostgreSQL 17.x✅ SupportedPostgreSQL 18.x✅ Supported### SQLite

[](#sqlite)

Use `--driver=sqlite`. The file path is passed as the database name:

```
./dbdiff --driver=sqlite server1./path/to/source.db:server1./path/to/target.db
```

SQLite 3.x is supported (any version supported by the installed `pdo_sqlite` PHP extension).

### Supabase

[](#supabase)

`--supabase` sets `driver=pgsql` and enables SSL automatically:

```
./dbdiff --supabase --server1=user:pass@db.xxx.supabase.co:5432 server1.mydb:server1.mydb
```

Compatible Database Variants
----------------------------

[](#compatible-database-variants)

The databases below work with DBDiff's existing drivers with no code changes. **Unless otherwise noted, these have not been tested by the core team.** PRs to add official support are welcome.

### MySQL-compatible — `--driver=mysql` (default)

[](#mysql-compatible----drivermysql-default)

DatabaseNotesMariaDB 10.x / 11.xMySQL wire protocol; minor DDL dialect differencesAWS Aurora MySQLStandard MySQL protocolPlanetScaleMySQL-compatible SaaSVitess / VTGateMySQL wire protocol via VTGatePercona XtraDB ClusterMySQL-compatible; Galera replication metadata ignoredTiDBMySQL-compatible; default port 4000### PostgreSQL-compatible — `--driver=pgsql`

[](#postgresql-compatible----driverpgsql)

DatabaseNotesAWS Aurora PostgreSQLStandard pgsql connectionAWS RDS PostgreSQLStandard pgsql connection[Neon](https://neon.tech)Standard pgsql; supports branch diffing (see below)AlloyDB (Google Cloud)Google's Postgres-compatible offeringCockroachDBPostgres wire protocol; some DDL differencesYugabyteDBPostgres-compatible YSQL layerMultigresTransparent Postgres proxy; no changes neededTimescaleDBPostgres extension; hypertable DDL diffs nativelypgvector`vector(N)` columns and HNSW/IVFFlat indexes diff natively### Neon Branching

[](#neon-branching)

Neon's copy-on-write branching lets you diff any two branches directly:

```
./dbdiff \
  --server1-url postgres://user:pass@main-branch.hostname.neon.tech/mydb \
  --server2-url postgres://user:pass@feature-branch.hostname.neon.tech/mydb \
  --format=flyway --description=my_feature
```

### Dolt (Git for Databases)

[](#dolt-git-for-databases)

[Dolt](https://github.com/dolthub/dolt) is a MySQL-compatible database with Git-style branching. Each branch is exposed as a separate database:

```
./dbdiff server1.main:server1.feature_add_users
```

Installation
------------

[](#installation)

The quickest way to get started is to download a pre-built release directly from [**GitHub Releases**](https://github.com/DBDiff/DBDiff/releases/latest) — no PHP, Node, or Composer required:

MethodAvailable on Releases?Best for[Pre-built binary](#pre-built-binaries)✅ YesQuickest start — zero dependencies[PHAR](#phar)✅ YesSingle portable file; requires PHP ≥ 8.1[npm](#npm)✅ Yes (via registry)Node.js projects or CI pipelines[Docker](#docker)—Isolated environments or testing[Composer (source)](#composer-source-install)—Contributing to DBDiff or PHP integration> **PHP requirement:** Pre-built binaries, npm packages, and Docker images bundle PHP 8.3 — no system PHP needed. The PHAR and Composer installs require **PHP ≥ 8.1** on your system.

Pre-built Binaries
------------------

[](#pre-built-binaries)

Download from [**GitHub Releases**](https://github.com/DBDiff/DBDiff/releases/latest). No PHP, Node, or Composer required.

PlatformAssetLinux x64 (glibc)`dbdiff-linux-x64`Linux x64 (Alpine / musl)`dbdiff-linux-x64-musl`Linux arm64 (glibc)`dbdiff-linux-arm64`Linux arm64 (Alpine / musl)`dbdiff-linux-arm64-musl`macOS Apple Silicon`dbdiff-darwin-arm64`macOS Intel`dbdiff-darwin-x64`Windows x64`dbdiff-win32-x64.exe`Windows arm64`dbdiff-win32-arm64.exe`After downloading, make it executable (Linux/macOS) and optionally move it to your `PATH`:

```
chmod +x dbdiff-linux-x64
sudo mv dbdiff-linux-x64 /usr/local/bin/dbdiff
dbdiff --version
```

npm
---

[](#npm)

```
npm install -g @dbdiff/cli
dbdiff --version
```

The correct platform binary is selected automatically at install time. Supported: Linux x64/arm64 (glibc + musl), macOS x64/arm64, Windows x64/arm64.

PHAR
----

[](#phar)

Download `dbdiff.phar` from [**GitHub Releases**](https://github.com/DBDiff/DBDiff/releases/latest). Requires PHP ≥ 8.1.

```
chmod +x dbdiff.phar
sudo mv dbdiff.phar /usr/local/bin/dbdiff
dbdiff --version
```

To build a PHAR locally from source, see [Building a PHAR](#building-a-phar).

Docker
------

[](#docker)

Pre-built multi-arch images (linux/amd64 + linux/arm64) are published to GHCR on every release.

### Pull and run (no build required)

[](#pull-and-run-no-build-required)

```
docker pull ghcr.io/dbdiff/dbdiff
docker run --rm ghcr.io/dbdiff/dbdiff --version
docker run --rm ghcr.io/dbdiff/dbdiff --driver=mysql \
  --server1=user:pass@host:3306 server1.mydb:server1.mydb
```

### Image variants

[](#image-variants)

Tag patternRegistryDescription`latest`, `{version}`, `slim-{version}`GHCR**Slim** — PHAR + PHP Alpine (~120 MB). For production use / CI.`full`, `full-{version}`GHCR**Full** — Composer source install (~600 MB). For development and cross-version testing.### Build locally

[](#build-locally)

```
# Slim image (requires dist/dbdiff.phar — run `vendor/bin/box compile` first)
docker build -f docker/Dockerfile.slim -t dbdiff:slim .
docker run --rm dbdiff:slim --version

# Full image (Composer install from source — no PHAR needed)
docker build -f docker/Dockerfile -t dbdiff:full .
```

See [DOCKER.md](DOCKER.md) for cross-version testing, Podman usage, and start.sh flags.

Composer Source Install
-----------------------

[](#composer-source-install)

```
git clone https://github.com/DBDiff/DBDiff.git
cd DBDiff
composer install --optimize-autoloader
```

Or as a project dependency:

```
composer require "dbdiff/dbdiff:@dev"
```

Or globally:

```
composer global require "dbdiff/dbdiff:@dev"
```

After installing from source, continue with [Setup](#setup).

Setup
-----

[](#setup)

*For source installs (git clone / Composer) only. Binaries, PHAR, npm, and Docker do not require these steps.*

1. Create a `.dbdiff` config file — see [File Examples](#file-examples)
2. Run: `./dbdiff server1.db1:server1.db2`

Expected output:

```
ℹ Now calculating schema diff for table `foo`
ℹ Now generating UP migration
ℹ Writing migration file to /path/to/dbdiff/migration.sql
✔ Completed

```

Command-Line API
----------------

[](#command-line-api)

*Flags always override settings in `.dbdiff`.*

FlagDescription`--server1=user:pass@host:port`Source connection. Omit if using only one server.`--server2=user:pass@host:port`Target connection (if different from server1).`--driver=mysql|pgsql|sqlite`Database driver. Defaults to `mysql`.`--supabase`Shorthand for `--driver=pgsql` + SSL.`--format=native|flyway|liquibase-xml|liquibase-yaml|laravel`Output format. Defaults to `native`.`--description=`Slug used in generated filenames.`--template=`Custom output template.`--type=schema|data|all`What to diff. Defaults to `schema`.`--include=up|down|all`Directions to include. Defaults to `up`.`--nocomments=true`Strip comment headers from output.`--config=`Config file path. Defaults to `.dbdiff`.`--output=`Output file path. Defaults to `migration.sql`.`server1.db1:server2.db2`Databases to compare. Or a single table: `server1.db1.table1:server2.db2.table1`.Usage Examples
--------------

[](#usage-examples)

### MySQL (default)

[](#mysql-default)

```
./dbdiff server1.db1:server2.db2
```

### MySQL — data diff only

[](#mysql--data-diff-only)

```
./dbdiff server1.dev.table1:server2.prod.table1 --nocomments=true --type=data
```

### MySQL — Flyway format with output path

[](#mysql--flyway-format-with-output-path)

```
./dbdiff --format=flyway --description=add_users --include=all \
  server1.db1:server2.db2 --output=./sql/
```

### PostgreSQL

[](#postgresql-1)

```
./dbdiff --driver=pgsql --server1=user:pass@localhost:5432 server1.staging:server1.production
```

### Supabase

[](#supabase-1)

```
./dbdiff --supabase --server1=postgres:pass@db.xxxx.supabase.co:5432 \
  server1.staging:server1.production
```

### SQLite

[](#sqlite-1)

```
./dbdiff --driver=sqlite server1./var/db/v1.db:server1./var/db/v2.db
```

File Examples
-------------

[](#file-examples)

A single `dbdiff.yml` file in your project root configures both the diff command and the migration runner. Copy [`dbdiff.yml.example`](dbdiff.yml.example) to get started.

Auto-detected filenames, in priority order:

FilenameNotes`.dbdiff`Legacy — still supported for backwards compatibility`dbdiff.yml`**Recommended** — YAML syntax highlighting, single file for everything`.dbdiff.yml`Hidden-file variant`dbdiff.yaml``.yaml` extension variantYou can also pass any filename explicitly: `./dbdiff --config=myconfig.yml server1.db:server2.db`

### `dbdiff.yml`

[](#dbdiffyml)

```
# ── Diff command (./dbdiff server1.db:server2.db) ─────────────────────────
server1:
  user: user
  password: password
  port: 3306      # MySQL: 3306 | PostgreSQL: 5432
  host: localhost
server2:
  user: user
  password: password
  port: 3306
  host: host2
driver: mysql     # mysql | pgsql | sqlite
type: all
include: all
nocomments: true
tablesToIgnore:
  - table1
  - table2
fieldsToIgnore:
  table1:
    - field1
    - field2

# ── Migration runner (dbdiff migrate:up) ──────────────────────────────────
database:
  driver: mysql
  host: localhost
  port: 3306
  name: mydb
  user: root
  password: secret

migrations:
  dir: ./migrations
  history_table: _dbdiff_migrations
```

How Does the Diff Work?
-----------------------

[](#how-does-the-diff-work)

Comparisons run in this order:

### Overall

[](#overall)

- Checks both databases exist and are accessible
- Compares database collation between source and target

### Schema

[](#schema)

- Detects differences in column count, name, type, collation or attributes
- New columns in the source are added to the target

### Data

[](#data)

- Compares table storage engine, collation, and row count
- Records changed rows and missing rows per table

Compatible Migration Tools
--------------------------

[](#compatible-migration-tools)

DBDiff supports multiple output formats via `--format`. Use `--description=` to customise generated filenames.

`--format`ToolLanguageOutputNotes`native` (default)Plain SQLAny`migration.sql`Up, down, or both`flyway`[Flyway](https://flywaydb.org)Java`V{ts}__{desc}.sql`Down adds `U{ts}__{desc}.sql` (Flyway Teams)`liquibase-xml`[Liquibase](https://liquibase.com)Java`changelog.xml`Both directions in one file`liquibase-yaml`[Liquibase](https://liquibase.com)Java`changelog.yaml`Both directions in one file`laravel`[Laravel Migrations](https://laravel.com/docs/migrations)PHP`YYYY_MM_DD_HHMMSS_{desc}.php``up()`/`down()` methods*(template)*[Simple DB Migrate](https://github.com/guilhermechapiewski/simple-db-migrate)PythoncustomUse `--template=templates/simple-db-migrate.tmpl`[Let us know](https://akalsoftware.com/) if you're using DBDiff with other tools so we can add them here.

Building a PHAR
---------------

[](#building-a-phar)

PHARs are built automatically and attached to every [GitHub Release](https://github.com/DBDiff/DBDiff/releases). To build locally from source:

```
composer install
vendor/bin/box compile
```

Output: `dist/dbdiff.phar` — rename and move to `/usr/local/bin/dbdiff` if desired.

> `box.json` is pre-configured with GZ compression and `check-requirements: false` so the PHAR works correctly when stitched with the static micro SAPI runtime used in the pre-built binaries.

Releasing 🚀
-----------

[](#releasing-)

### Automated (recommended)

[](#automated-recommended)

1. Go to **GitHub Actions → Release DBDiff → Run workflow**
2. Enter the version number (e.g. `2.1.0` — no `v` prefix)
3. The workflow will:
    - Build the PHAR with Box
    - Build self-contained binaries for all 8 platforms via static-php-cli
    - Publish all `@dbdiff/cli-*` packages to npm (skips any already published)
    - Create or update the GitHub Release with all assets
    - Create the git tag (skipped if it already exists)

### Manual / local

[](#manual--local)

```
# Build PHAR + tag
scripts/release.sh v2.1.0
git push origin v2.1.0

# Build Linux binaries locally (requires Podman or Docker)
SKIP_PHAR=1 scripts/release-binaries.sh 2.1.0

# Upload assets to an existing GitHub Release
gh release upload v2.1.0 --clobber \
  dist/dbdiff.phar \
  packages/@dbdiff/cli-linux-x64/dbdiff \
  packages/@dbdiff/cli-linux-x64-musl/dbdiff \
  packages/@dbdiff/cli-linux-arm64/dbdiff \
  packages/@dbdiff/cli-linux-arm64-musl/dbdiff

# Update the Homebrew tap formula
scripts/update-homebrew-formula.sh 2.1.0 ../homebrew-dbdiff
```

Cross-Version Testing
---------------------

[](#cross-version-testing)

Test DBDiff locally against any combination of PHP and MySQL:

```
# Single combination
./start.sh 8.3 8.0

# All 16 combinations in parallel
./start.sh all all --parallel
```

The CI matrix: **6 PHP × 4 MySQL = 24 jobs**, plus dedicated jobs for SQLite and PostgreSQL.

See [DOCKER.md](DOCKER.md) for flags covering fast restarts, recording fixtures, and CI usage.

Questions &amp; Support 💡
-------------------------

[](#questions--support-)

- Open a [new issue](https://github.com/dbdiff/dbdiff/issues/new/choose) or check [existing ones](https://github.com/dbdiff/dbdiff/issues)
- For commercial support enquiries, [get in touch](https://akalsoftware.com/)

Contributions 💖
---------------

[](#contributions-)

Please read the [Contributing Guide](https://github.com/dbdiff/dbdiff/blob/master/.github/CONTRIBUTING.md) before submitting a PR.

[![](https://camo.githubusercontent.com/fd662b08e30002a39a03dfff5c3ac8b95b2d9a43f80b2f013592cb6b45ecb643/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f6462646966662f6462646966662e737667)](https://github.com/dbdiff/dbdiff/graphs/contributors)

Feedback 💬
----------

[](#feedback-)

Could you spare 2 minutes to share your feedback?

License
-------

[](#license)

[MIT](http://opensource.org/licenses/MIT)

Made with 💖 by
[![Akal Logo](images/akal-logo.svg)](https://akalsoftware.com/)

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance85

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community25

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 82.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~949 days

Total

3

Last Release

90d ago

Major Versions

v1.0.0 → v2.0.02026-02-09

### Community

---

Top Contributors

[![jasdeepkhalsa](https://avatars.githubusercontent.com/u/41632?v=4)](https://github.com/jasdeepkhalsa "jasdeepkhalsa (140 commits)")[![jawb](https://avatars.githubusercontent.com/u/1163113?v=4)](https://github.com/jawb "jawb (21 commits)")[![webian](https://avatars.githubusercontent.com/u/462601?v=4)](https://github.com/webian "webian (2 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (2 commits)")[![desyncr](https://avatars.githubusercontent.com/u/1857707?v=4)](https://github.com/desyncr "desyncr (1 commits)")[![jijoel](https://avatars.githubusercontent.com/u/3487641?v=4)](https://github.com/jijoel "jijoel (1 commits)")[![plashenkov](https://avatars.githubusercontent.com/u/2331932?v=4)](https://github.com/plashenkov "plashenkov (1 commits)")[![amontalban](https://avatars.githubusercontent.com/u/941928?v=4)](https://github.com/amontalban "amontalban (1 commits)")

### Embed Badge

![Health badge](/badges/jawbfl-dbdiff/health.svg)

```
[![Health](https://phpackages.com/badges/jawbfl-dbdiff/health.svg)](https://phpackages.com/packages/jawbfl-dbdiff)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.3k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M543](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M209](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
