Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# This file contains configurable environment variables for the test runner

# Individual PHP Versions
PHP_VERSION_74=7.4
PHP_VERSION_83=8.3
PHP_VERSION_84=8.4
PHP_VERSION_85=8.5
Expand Down
32 changes: 29 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,32 @@ on:
branches: [ master ]

jobs:
# ── Unit tests (no DB needed — fast feedback) ────────────────────────────────
unit-tests:
name: Unit / PHP ${{ matrix.php-version }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-version: ['8.0', '8.3', '8.4', '8.5']

steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2
with:
php-version: ${{ matrix.php-version }}
extensions: pdo, pdo_sqlite, json
coverage: none

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run unit tests
run: ./scripts/run-tests.sh --unit

# ── MySQL matrix ────────────────────────────────────────────────────────────
test:
name: PHP ${{ matrix.php-version }} / MySQL ${{ matrix.mysql-version }}
Expand All @@ -15,7 +41,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['7.4', '8.3', '8.4', '8.5']
php-version: ['8.3', '8.4', '8.5']
mysql-version: ['8.0', '8.4', '9.3', '9.6']

env:
Expand Down Expand Up @@ -67,7 +93,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['7.4', '8.3', '8.4', '8.5']
php-version: ['8.3', '8.4', '8.5']

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -96,7 +122,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['7.4', '8.3', '8.4', '8.5']
php-version: ['8.3', '8.4', '8.5']
postgres-version: ['14', '15', '16', '17', '18']

env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ dist
.phpunit.cache
tests/logs/
.env
docs/
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

12 changes: 1 addition & 11 deletions DOCKER.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ Podman runs containers as your own user by default. If port binding below 1024 f
## Available Configurations

### PHP Versions
- PHP 7.4
- PHP 8.3
- PHP 8.4
- PHP 8.5
Expand All @@ -94,9 +93,6 @@ Podman runs containers as your own user by default. If port binding below 1024 f
## Services

### CLI Services (for running DBDiff)
- `cli-php74-mysql80` - PHP 7.4 with MySQL 8.0
- `cli-php74-mysql84` - PHP 7.4 with MySQL 8.4
- `cli-php74-mysql93` - PHP 7.4 with MySQL 9.3
- `cli-php83-mysql80` - PHP 8.3 with MySQL 8.0
- `cli-php83-mysql84` - PHP 8.3 with MySQL 8.4
- `cli-php83-mysql93` - PHP 8.3 with MySQL 9.3
Expand Down Expand Up @@ -133,9 +129,6 @@ docker-compose up -d db-mysql93 phpmyadmin-mysql93

### Run DBDiff with specific PHP/MySQL combination
```bash
# PHP 7.4 with MySQL 8.0
docker-compose run --rm cli-php74-mysql80 server1.php server2.php database1 database2

# PHP 8.3 with MySQL 8.0
docker-compose run --rm cli-php83-mysql80 server1.php server2.php database1 database2

Expand All @@ -160,9 +153,6 @@ docker-compose run --rm cli-php83-postgres16 \

### Run PHPUnit tests with specific combination
```bash
# Run tests with PHP 7.4 and MySQL 8.0
docker-compose run --rm cli-php74-mysql80 phpunit

# Run tests with PHP 8.3 and MySQL 8.0
docker-compose run --rm cli-php83-mysql80 phpunit

Expand Down Expand Up @@ -293,7 +283,7 @@ Default MySQL credentials (configurable via `.env`):
The project uses GitHub Actions to ensure full compatibility across all supported versions on every pull request.

**Matrix Grid:**
- **PHP**: 7.4, 8.3, 8.4, 8.5
- **PHP**: 8.3, 8.4, 8.5
- **MySQL**: 8.0, 8.4, 9.3, 9.6
- **PostgreSQL**: 16
- **SQLite**: bundled (runs in every MySQL CLI container via `pdo_sqlite`)
Expand Down
114 changes: 105 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@
## Pre-requisites
1. You will need to have access to the command-line (Terminal/CMD/PowerShell)
2. You will need to have git installed
3. You will need to have PHP installed (version 7.4.x, 8.3.x, 8.4.x, or 8.5.x)
3. You will need to have PHP installed (version 8.3.x, 8.4.x, or 8.5.x)
4. You will need to have Composer installed

_Note: Make a note of where `composer.phar` is installed as we will need it later on during Setup_

* PHP 7.4.x
* PHP 8.3.x
* PHP 8.4.x
* PHP 8.5.x
Expand Down Expand Up @@ -76,6 +75,55 @@ Use the `--supabase` shorthand flag — it sets `driver=pgsql` and enables SSL a
./dbdiff --supabase --server1=user:[email protected]:5432 server1.mydb:server1.mydb
```

## Compatible Database Variants

The databases below work with DBDiff's existing drivers with no code changes, because they speak standard MySQL or PostgreSQL wire protocols. **Unless otherwise noted, these have not been tested by the core team.** Feel free to open a PR to add official support.

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

| Database | Connection | Notes |
|---|---|---|
| MariaDB 10.x / 11.x | `--server1=user:pass@host:3306` | MySQL wire protocol; minor DDL dialect differences |
| AWS Aurora MySQL | `--server1=user:pass@cluster-endpoint:3306` | Standard MySQL protocol |
| PlanetScale | `--server1=user:pass@host:3306` | MySQL-compatible SaaS |
| Vitess / VTGate | `--server1=user:pass@vtgate-host:3306` | MySQL wire protocol via VTGate |
| Percona XtraDB Cluster | `--server1=user:pass@host:3306` | MySQL-compatible; Galera replication metadata ignored |
| TiDB | `--server1=user:pass@host:4000` | MySQL-compatible; default port 4000 |

### PostgreSQL-compatible — use `--driver=pgsql`

| Database | Connection | Notes |
|---|---|---|
| AWS Aurora PostgreSQL | `--server1-url postgres://user:pass@cluster:5432/db` | Standard pgsql connection |
| AWS RDS PostgreSQL | `--server1-url postgres://user:pass@host:5432/db` | Standard pgsql connection |
| [Neon](https://neon.tech) | `--server1-url postgres://user:[email protected]:5432/db` | Standard pgsql; see Neon Branching below |
| AlloyDB (Google Cloud) | `--server1-url postgres://user:pass@host:5432/db` | Google's Postgres-compatible offering |
| CockroachDB | `--server1-url postgresql://user:pass@host:26257/db` | Postgres wire protocol; some DDL differences |
| YugabyteDB | `--server1-url postgres://user:pass@host:5433/db` | Postgres-compatible YSQL layer |
| Multigres | `--server1-url postgres://user:pass@multigres-host:5432/db` | Transparent Postgres proxy; no changes needed |
| TimescaleDB | `--driver=pgsql` as normal | Postgres extension; hypertable DDL diffs natively |
| pgvector | `--driver=pgsql` as normal | `vector(N)` column types and HNSW/IVFFlat indexes diff natively |

### Neon Branching

Neon's instant copy-on-write branching lets you diff any two branches directly — each branch is an independent PostgreSQL endpoint:

```bash
./dbdiff \
--server1-url postgres://user:[email protected]/mydb \
--server2-url postgres://user:[email protected]/mydb \
--format=flyway --description=my_feature
```

### Dolt (Git for Databases)

[Dolt](https://github.com/dolthub/dolt) is a MySQL-compatible database with full Git-style branching. DBDiff's MySQL adapter connects to a Dolt server directly — each Dolt branch is exposed as a separate database:

```bash
# Start a Dolt server, then diff two branches
./dbdiff server1.main:server1.feature_add_users
```

## Installation
On the command-line, use `git` to clone the ssh version:

Expand Down Expand Up @@ -132,7 +180,7 @@ Please ensure you have one of the following installed locally, as well as a down

_Note: Please run these commands from the root of the DBDiff folder. Also the commands may need to be prepended with `sudo` on some systems._

### Docker Standalone DBDiff CLI with PHP 7.3
### Docker Standalone DBDiff CLI

```bash
# Build DBDiff CLI Image
Expand Down Expand Up @@ -299,12 +347,60 @@ The following comparisons run in exactly the following order:

## Compatible Migration Tools

| Project | Language / Package Manager | Description |
|---------|--------|-------------|
| [Simple DB Migrate](https://github.com/guilhermechapiewski/simple-db-migrate) | Python / PIP | Generic database migration tool inpired on Rails migrations |
| [Flyway](https://github.com/flyway/flyway) | Java / Maven | Database Migrations Made Easy |

Please do [let us know](https://akalsoftware.com/) if you're using any other migration tools with DBDiff, other than the ones listed here, so we can add it.
DBDiff supports multiple output formats via the `--format` flag. Add `--description=<slug>` to customise the generated file name.

| `--format` | Tool | Output file | `--include` support |
|---|---|---|---|
| `native` (default) | Plain SQL / any tool | `migration.sql` | `up`, `down`, `both` |
| `flyway` | [Flyway](https://flywaydb.org) | `V{timestamp}__{desc}.sql` | `up` required; `down` adds `U{ts}__{desc}.sql` (Flyway Teams) |
| `liquibase-xml` | [Liquibase](https://liquibase.com) | `changelog.xml` | Both directions in one file (`<sql>` + `<rollback>`) |
| `liquibase-yaml` | [Liquibase](https://liquibase.com) | `changelog.yaml` | Both directions in one file |
| `laravel` | [Laravel Migrations](https://laravel.com/docs/migrations) | `YYYY_MM_DD_HHMMSS_{desc}.php` | Both directions in one file (`up()`/`down()`) |

### Flyway

```bash
./dbdiff --format=flyway --description=add_users server1.mydb:server2.mydb
```

Move the generated `V{timestamp}__add_users.sql` into your Flyway `sql/` migrations directory, then run `flyway migrate`.

### Liquibase

```bash
# XML
./dbdiff --format=liquibase-xml --description=add_users server1.mydb:server2.mydb

# YAML
./dbdiff --format=liquibase-yaml --description=add_users server1.mydb:server2.mydb
```

Add the generated `changelog.xml` (or `.yaml`) to your Liquibase master changelog, then run `liquibase update`.

### Laravel

```bash
./dbdiff --format=laravel --description=add_users server1.mydb:server2.mydb
```

Move the generated `YYYY_MM_DD_HHMMSS_add_users.php` into `database/migrations/`, then run `php artisan migrate`.

### Simple DB Migrate

Use the bundled template with the legacy `--template` flag:

```bash
./dbdiff --template=templates/simple-db-migrate.tmpl server1.mydb:server2.mydb
```

| Project | Language | Description |
|---|---|---|
| [Flyway](https://github.com/flyway/flyway) | Java / Maven | Database migrations made easy |
| [Liquibase](https://github.com/liquibase/liquibase) | Java / Maven | Database changelog and migration tool |
| [Laravel Migrations](https://laravel.com/docs/migrations) | PHP / Composer | Schema migrations built into the Laravel framework |
| [Simple DB Migrate](https://github.com/guilhermechapiewski/simple-db-migrate) | Python / PIP | Rails-inspired database migration tool |

Please [let us know](https://akalsoftware.com/) if you're using DBDiff with other migration tools so we can add them here.

## Questions & Support 💡

Expand Down
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@
}
},
"prefer-stable": true,
"config": {
"platform": {
"php": "8.0"
}
},
"require": {
"php": ">=7.3",
"php": ">=8.0",
"ext-json": "*",
"aura/cli": "2.*@dev",
"symfony/console": "^5.4|^6.0|^7.0",
"symfony/yaml": "^5.1|^6.0|^7.0",
"illuminate/database": "^8|^9|^10|^11",
"illuminate/view": "^8|^9|^10|^11",
Expand Down
Loading