Developers in the development of various needs, the structure of the database and data changes, each time the development is completed, online will synchronize the database structure & data, so need to find out the need to synchronize the database DDL and DML statements, less change is OK. Once the data changes involve many tables, the fragmentation has the following problems:
- It’s easy to miss, and there are database level bugs and exceptions on-line.
- It takes a lot of time to find out how to change DDL and DML.
- It involves many and fragmented SQL change statements and is difficult to review.
If you can, there is a tool that can compare the local database development environment with the waiting synchronization development environment database. The tool automatically compares the differences between DML and DDL corresponding to two libraries, and generates SQL statements at the same time. Developers can send the generated statements to DBA for execution! Can also facilitate their own inspection!
Sync data struct is a toolkit used to compare the data structure differences between two databases and generate updated DDL. It is convenient to compare the differences between two databases for data structure synchronization
composer require zyimm/sync-data-struct
//set error error_reporting(E_ALL); ini_set('display_errors', true); //autoload include '../vendor/autoload.php'; //db $config = [ //Local database 'local' => [ 'host' => 'mysql', 'username' => 'root', 'passwd' => '123456', 'dbname' => 'local' ], //Database to be synchronized 'dev' => [ 'host' => 'mysql', 'username' => 'root', 'passwd' => '123456', 'dbname' => 'dev' ] ]; $handle = new \Zyimm\dbStructSync\Sync($config); //Output change SQL statement echo $handle->executeSync()->toHtml();