2017 © Pedro Peláez
 

project compalex

Compalex is a lightweight script to compare two database schemas. It supports MySQL, MS SQL Server and PostgreSQL

image

dlevsha/compalex

Compalex is a lightweight script to compare two database schemas. It supports MySQL, MS SQL Server and PostgreSQL

  • Wednesday, October 11, 2017
  • by dlevsha
  • Repository
  • 14 Watchers
  • 168 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 34 Forks
  • 3 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

README

What is Compalex?

Compalex is a lightweight script to compare two database schemas. It supports MySQL, MS SQL Server and PostgreSQL., (*1)

Try demo or visit http://compalex.net/, (*2)

How to use

The easiest way to use Compalex is to use Docker., (*3)

You can build your own container using Dockerfile or use Docker Hub image:, (*4)

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, (*5)

DATABASE_DRIVER - database driver, possible value, (*6)

  • mysql - for MySQL database
  • pgsql - for PostgreSQL database
  • dblib - for Microsoft SQL Server database
  • oci - for Oracle database

DATABASE_HOST and DATABASE_HOST_SECONDARY - database host name or IP for first and second server, (*7)

If your compared DB run locally:, (*8)

  • for MacOS and Windows user: use host.docker.internal instead of localhost in DATABASE_HOST and DATABASE_HOST_SECONDARY param. Because we run script inside container we need to use Host machine IP for connection., (*9)

  • for Linux user: use --network host option and localhost in DATABASE_HOST and DATABASE_HOST_SECONDARY param., (*10)

If you connect to DB outside your machine (external IP) use: -e DATABASE_HOST='[Your external IP]'., (*11)

DATABASE_PORT and DATABASE_PORT_SECONDARY - database port for first and second server, (*12)

Default ports for DB:, (*13)

  • 3306 - Mysql
  • 5432 - PostgreSQL
  • 1433 - MSSQL
  • 1521 - Oracle

DATABASE_NAME and DATABASE_NAME_SECONDARY - first and second database name, (*14)

DATABASE_USER / DATABASE_PASSWORD and DATABASE_USER_SECONDARY / DATABASE_PASSWORD_SECONDARY - login and password to access your databases, (*15)

DATABASE_DESCRIPTION and DATABASE_DESCRIPTION_SECONDARY - server description (not necessary). For information only. These names will display as a database name., (*16)

You can also use docker-compose.yml., (*17)

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., (*18)

Compalex is only supported by PHP 5.4 and up with PDO extension., (*19)

Installation

$ git clone https://github.com/dlevsha/compalex.git
$ cd compalex

Open .environment. You'll see configuration params, (*20)

[ 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, (*21)

DATABASE_DRIVER - database driver, possible value, (*22)

  • mysql - for MySQL database
  • pgsql - for PostgreSQL database
  • dblib - for Microsoft SQL Server database
  • oci - for Oracle database

[ Primary connection params ] and [ Secondary connection params ]sections describes settings for first and second databases., (*23)

Where, (*24)

DATABASE_HOST and DATABASE_HOST_SECONDARY - database host name or IP for first and second server, (*25)

DATABASE_PORT and DATABASE_PORT_SECONDARY - database port for first and second server, (*26)

Default ports:, (*27)

  • 3306 - Mysql
  • 5432 - PostgreSQL
  • 1433 - MSSQL
  • 1521 - Oracle

DATABASE_NAME and DATABASE_NAME_SECONDARY - first and second database name, (*28)

DATABASE_USER / DATABASE_PASSWORD and DATABASE_USER_SECONDARY / DATABASE_PASSWORD_SECONDARY - login and password to access your databases, (*29)

DATABASE_DESCRIPTION and DATABASE_DESCRIPTION_SECONDARY - server description (not necessary). For information only. These names will display as a database name., (*30)

Inside compalex directory run, (*31)

$ php -S localhost:8000

Now open your browser and type http://localhost:8000/, (*32)

You'll see database schema of two compared databases., (*33)

-, (*34)

Database Compare Panel

You can run this script in terminal (for example, if you don't have direct connection to database)., (*35)

I recommend eLinks (free text-based console web browser) because it supports HTML-formatting and colors., (*36)

Install the script and run web-server as described above on your server., (*37)

Then run:, (*38)

$ elinks http://localhost:8000

You'll see database schema in your terminal, (*39)

Database schema in terminal, (*40)

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, (*41)

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., (*42)

LICENSE

Copyright (c) 2021, Levsha Dmitry, (*43)

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., (*44)

The Versions

11/10 2017

dev-master

9999999-dev https://github.com/dlevsha/compalex

Compalex is a lightweight script to compare two database schemas. It supports MySQL, MS SQL Server and PostgreSQL

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

compare database schemas compare databases database diff database schema diff

17/12 2015

0.4.0

0.4.0.0 https://github.com/dlevsha/compalex

Compalex is a lightweight script to compare two database schemas. It supports MySQL, MS SQL Server and PostgreSQL

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

compare database schemas compare databases database diff database schema diff