jawbfl/dbdiff
DBDiff is a Laravel package that compares two database schemas and generates migration files for the differences, helping you sync environments, catch schema drift, and turn database changes into versioned migrations.
composer require --dev jawbfl/dbdiff. It shells out to PDO, so you also need the matching PDO driver (pdo_mysql for the common case) enabled in the PHP CLI you'll run it with.README.md (it doubles as the CLI reference), then the CLI entry point (dbdiff / bin/) and the src/ comparators. The CLI is a thin wrapper — the entry point tells you exactly which comparator and renderer classes are public API if you want to script it.--type=schema|data|all), which direction to emit (--include=up|down|both), and an output template. Confirm exact flag spelling against the README for your pinned version — this is a small project and flags have shifted between releases.ALTER script by hand. That single loop — dump, diff, review, apply — is 90% of how this tool earns its keep.schema.sql in the repo, restore it to a throwaway MySQL service in CI, and diff it against the schema built by your migrations. Treat any non-empty diff as a build failure. This catches "someone changed the table by hand" and "the migration doesn't match the model" long before deploy.build/predeploy.sql, and hand it to a reviewer. Use the up/down template so you get a rollback script in the same pass — the down half is usually the part people forget to write.--template option lets you wrap the generated statements in your own boilerplate (transaction guards, SET FOREIGN_KEY_CHECKS, header comments with the two DSNs and a timestamp). Keep one template per environment so the artifact is self-describing when it lands in a ticket.--type=data compares rows rather than structure. Wire this into a check that your seeders still match production for things like countries, plans, or feature flags — not for user tables.make schema-diff.--execute. That's a feature — but it means foreign-key ordering, DROP-before-ADD sequences, and destructive column changes are your responsibility to review. Always run the script against a restored copy first.source/target names rather than positional args.AUTO_INCREMENT counters, table comments, and default charset/collation differences generate diffs that don't matter. Normalize collations across environments or you'll train the team to ignore the output. --nocomments also keeps generated files stable in version control.utf8mb4_0900_* collations) may round-trip imperfectly or appear as spurious changes. MariaDB is close but not identical. Pin the MySQL/MariaDB version in CI to the one you run in production.ps. Prefer the config file, chmod 600 it, and give the account SELECT-only on both sides. The tool never needs write access.composer.json, commit the lockfile, and be prepared to fork. The codebase is small enough that patching a MySQL-8 parsing quirk yourself is realistic — the comparators under src/ are the place to look.How can I help you explore Laravel packages today?