定制 phlib/schemadiff 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

phlib/schemadiff

Composer 安装命令:

composer require phlib/schemadiff

包简介

Schema Diff: Show difference between MySQL databases

README 文档

README

Code Checks Codecov Latest Stable Version Total Downloads Licence

MySQL Schema Diff, a Symfony Console tool for displaying differeance between two schemas. This can be useful by showing differences between production and development. It's then up to the developer to create some kind of migration scripts.

Install

Via Composer

Single project

$ composer require phlib/schemadiff

Globally

$ composer global require phlib/schemadiff

Command Line Usage

If you install schemadiff globally

And add this to your PATH in your ~/.bash_profile

export PATH=~/.composer/vendor/bin:$PATH

Then you can run schemadiff like this

$ schemadiff --help
$ schemadiff h=127.0.0.1,u=user,p=pass,D=db1 h=127.0.0.1,u=user,p=pass,D=db2

Otherwise run it from your project

$ ./vendor/bin/schemadiff --help
$ ./vendor/bin/schemadiff h=127.0.0.1,u=user,p=pass,D=db1 h=127.0.0.1,u=user,p=pass,D=db2

PHP Usage

<?php

$pdo = new \PDO('mysql:...', $username, $password);
$schemaInfo1 = \Phlib\SchemaDiff\SchemaInfoFactory::fromPdo($pdo, 'db1');
$schemaInfo2 = \Phlib\SchemaDiff\SchemaInfoFactory::fromPdo($pdo, 'db2');

$schemaDiff = new \Phlib\SchemaDiff\SchemaDiff(
    new Symfony\Component\Console\Output\StreamOutput(STDOUT)
);
$different = $schemaDiff->diff($schemaInfo1, $schemaInfo2);

exit($different ? 1 : 0);

Example Ouput

Output shows difference between the schemas. Example 1

As the database names could be the same on different hosts, the DSN position is included. Example 2

Testing different copies match a tempalte database. Example 3

License

This package is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses/.

统计信息

  • 总下载量: 10.21k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 4
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0
  • 更新时间: 2017-02-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固