Download the PHP package apetab/php-mysql-diff without Composer
On this page you can find all versions of the php package apetab/php-mysql-diff. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-mysql-diff
PHP MySQL Diff
MySQL Schema Diff - Comparison / Migration Script Generation
Why not mysqldiff
from MySQL Utilities?
MySQL Utilities includes a similar tool, mysqldiff
, that is absolutely horrible! The purpose of this project is to provide a tool that is simple to use, reliable and fast.
Installation
To install PHP MySQL Diff, install Composer and issue the following command:
Then, make sure you have ~/.composer/vendor/bin in your PATH, and you're good to go:
Update
You can update PHP MySQL Diff through this command:
Usage
Database Creation Scripts
PHP MySQL Diff works with database creations scripts created by mysqldump
, which is part of the MySQL distribution. In order to generate a database creation script, use the following command:
This tool may not work with creation scripts generated by other means because it relies on finely tuned regular expressions that could not work if the file format is different.
I chose to work with database creation scripts instead of working by connecting to the databases directly because it's more portable that way and you can work offline. In the future, I might develop the option to fetch the information directly from the database INFORMATION_SCHEMA
table.
Diff
where from
is the path to the initial database creation script and to
is the path to the target database creation script.
Ignore Tables
Use the -i
option to ignore tables during comparison. The file format is a list of regular expressions to match the table names to be ignored, one per line.
Example:
Output File
The output will be like this:
▲ = only present in the TO database
► = different definitions between FROM and TO databases
▼ = only present in the FROM database
Migration Script
where from
is the path to the initial database creation script and to
is the path to the target database creation script.
Ignore Tables
Use the -i
option to ignore tables during comparison. The file format is a list of regular expressions to match the table names to be ignored, one per line.
Example:
Output File
If the -o
option is not used, the migration script will be output to the stdout
.
The output (with the -o
option) will be like this:
and the migration script will look like this:
Display Progress
For long running migrations, it is recommended to use the -p
option to display the progress of the running migration.
Contribute
Feel free to send your contributions as PR. Make sure you update/write new tests to support your contribution. Please follow PSR-2.