Demand online, synchronous database structure & data, with this tool no longer worry!

Time:2021-3-4

background

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:

  1. It’s easy to miss, and there are database level bugs and exceptions on-line.
  2. It takes a lot of time to find out how to change DDL and DML.
  3. It involves many and fragmented SQL change statements and is difficult to review.

solve

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

install

composer  require zyimm/sync-data-struct

Supported data

  • Mysql

Use cases

//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();

Project address

Tip:sync-data-struct