dlevsha/compalex
Composer 安装命令:
composer create-project dlevsha/compalex
包简介
Compalex is a lightweight script to compare two database schemas. It supports MySQL, MS SQL Server and PostgreSQL
README 文档
README
What is Compalex?
Compalex is a lightweight script to compare two database schemas. It supports MySQL, MS SQL Server and PostgreSQL.
Try demo or visit http://compalex.net/
How to use
The easiest way to use Compalex is to use Docker.
You can build your own container using Dockerfile or use Docker Hub image:
docker run -it -e DATABASE_DRIVER='mysql' \ -e DATABASE_ENCODING='utf8' \ -e SAMPLE_DATA_LENGTH='100' \ -e DATABASE_HOST='host.docker.internal' \ -e DATABASE_PORT='3306' \ -e DATABASE_NAME='compalex_dev' \ -e DATABASE_USER='root' \ -e DATABASE_PASSWORD='password' \ -e DATABASE_DESCRIPTION='Developer database' \ -e DATABASE_HOST_SECONDARY='host.docker.internal' \ -e DATABASE_PORT_SECONDARY='3306' \ -e DATABASE_NAME_SECONDARY='compalex_prod' \ -e DATABASE_USER_SECONDARY='root' \ -e DATABASE_PASSWORD_SECONDARY='password' \ -e DATABASE_DESCRIPTION_SECONDARY='Production database' \ -p 8000:8000 dlevsha/compalex
You need to change variables for your own
DATABASE_DRIVER - database driver, possible value
mysql- for MySQL databasepgsql- for PostgreSQL databasedblib- for Microsoft SQL Server databaseoci- for Oracle database
DATABASE_HOST and DATABASE_HOST_SECONDARY - database host name or IP for first and second server
If your compared DB run locally:
-
for MacOS and Windows user: use
host.docker.internalinstead oflocalhostinDATABASE_HOSTandDATABASE_HOST_SECONDARYparam. Because we run script inside container we need to use Host machine IP for connection. -
for Linux user: use
--network hostoption andlocalhostinDATABASE_HOSTandDATABASE_HOST_SECONDARYparam.
If you connect to DB outside your machine (external IP) use: -e DATABASE_HOST='[Your external IP]'.
DATABASE_PORT and DATABASE_PORT_SECONDARY - database port for first and second server
Default ports for DB:
3306- Mysql5432- PostgreSQL1433- MSSQL1521- Oracle
DATABASE_NAME and DATABASE_NAME_SECONDARY - first and second database name
DATABASE_USER / DATABASE_PASSWORD and DATABASE_USER_SECONDARY / DATABASE_PASSWORD_SECONDARY - login and password to access your databases
DATABASE_DESCRIPTION and DATABASE_DESCRIPTION_SECONDARY - server description (not necessary). For information only. These names will display as a database name.
You can also use docker-compose.yml.
version: "3.7"
services:
compalex:
image: dlevsha/compalex
container_name: compalex
environment:
- DATABASE_DRIVER=mysql
- DATABASE_ENCODING=utf8
- SAMPLE_DATA_LENGTH=100
- DATABASE_HOST=host.docker.internal
- DATABASE_PORT=3306
- DATABASE_NAME=compalex_dev
- DATABASE_USER=root
- DATABASE_PASSWORD=password
- DATABASE_DESCRIPTION=Developer database
- DATABASE_HOST_SECONDARY=host.docker.internal
- DATABASE_PORT_SECONDARY=3306
- DATABASE_NAME_SECONDARY=compalex_prod
- DATABASE_USER_SECONDARY=root
- DATABASE_PASSWORD_SECONDARY=password
- DATABASE_DESCRIPTION_SECONDARY=Production database
ports:
- "8000:8000"
Requirements
If you prefer use Compalex as PHP script please read instruction bellow.
Compalex is only supported by PHP 5.4 and up with PDO extension.
Installation
$ git clone https://github.com/dlevsha/compalex.git
$ cd compalex
Open .environment. You'll see configuration params
[ Main settings ] ; Possible DATABASE_DRIVER: 'mysql', 'pgsql', 'dblib', 'oci'. ; Please use 'dblib' for Microsoft SQL Server DATABASE_DRIVER = mysql DATABASE_ENCODING = utf8 SAMPLE_DATA_LENGTH = 100 [ Primary connection params ] DATABASE_HOST = localhost DATABASE_PORT = 3306 DATABASE_NAME = compalex_dev DATABASE_USER = root DATABASE_PASSWORD = DATABASE_DESCRIPTION = Developer database [ Secondary connection params ] DATABASE_HOST_SECONDARY = localhost DATABASE_PORT_SECONDARY = 3306 DATABASE_NAME_SECONDARY = compalex_prod DATABASE_USER_SECONDARY = root DATABASE_PASSWORD_SECONDARY = DATABASE_DESCRIPTION_SECONDARY = Production database
where
DATABASE_DRIVER - database driver, possible value
mysql- for MySQL databasepgsql- for PostgreSQL databasedblib- for Microsoft SQL Server databaseoci- for Oracle database
[ Primary connection params ] and [ Secondary connection params ]sections describes settings for first and second databases.
Where
DATABASE_HOST and DATABASE_HOST_SECONDARY - database host name or IP for first and second server
DATABASE_PORT and DATABASE_PORT_SECONDARY - database port for first and second server
Default ports:
3306- Mysql5432- PostgreSQL1433- MSSQL1521- Oracle
DATABASE_NAME and DATABASE_NAME_SECONDARY - first and second database name
DATABASE_USER / DATABASE_PASSWORD and DATABASE_USER_SECONDARY / DATABASE_PASSWORD_SECONDARY - login and password to access your databases
DATABASE_DESCRIPTION and DATABASE_DESCRIPTION_SECONDARY - server description (not necessary). For information only. These names will display as a database name.
Inside compalex directory run
$ php -S localhost:8000
Now open your browser and type http://localhost:8000/
You'll see database schema of two compared databases.
You can run this script in terminal (for example, if you don't have direct connection to database).
I recommend eLinks (free text-based console web browser) because it supports HTML-formatting and colors.
Install the script and run web-server as described above on your server.
Then run:
$ elinks http://localhost:8000
You'll see database schema in your terminal
Sometimes you have only SSH access to remote database server and you can't open port for external connections. In this case you can use port forwarding via SSH
ssh -L 1522:localhost:1521 [user name]@[remote host 1]
ssh -L 1523:localhost:1521 [user name]@[remote host 2]
This command will forward 1521 port from remote servers to local 1522 and 1523 respectively.
LICENSE
Copyright (c) 2021, Levsha Dmitry
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
dlevsha/compalex 适用场景与选型建议
dlevsha/compalex 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 45 次下载、GitHub Stars 达 440, 最近一次更新时间为 2015 年 10 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「compare database schemas」 「compare databases」 「database diff」 「database schema diff」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dlevsha/compalex 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dlevsha/compalex 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dlevsha/compalex 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Database schema management, for CodeIgniter 4
PHP Semantic Versioning Parser and Comparator
Store your language lines in the database, yaml or other sources
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Small class for checking ip addresses
统计信息
- 总下载量: 45
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 440
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-10-31

