{"id":17189437,"url":"https://github.com/dlevsha/compalex","last_synced_at":"2025-04-04T10:09:06.523Z","repository":{"id":43406045,"uuid":"41806188","full_name":"dlevsha/compalex","owner":"dlevsha","description":"Lightweight script to compare two database","archived":false,"fork":false,"pushed_at":"2022-03-03T02:54:07.000Z","size":94,"stargazers_count":434,"open_issues_count":6,"forks_count":123,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-03-28T09:08:52.825Z","etag":null,"topics":["compared-databases","database-management","database-migrations","database-schema","database-structure","mssql-diff","mysql-diff","mysqldiff","pgsql-http","postgresql-diff"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dlevsha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-02T14:30:56.000Z","updated_at":"2025-01-20T14:46:07.000Z","dependencies_parsed_at":"2022-07-15T01:30:36.995Z","dependency_job_id":null,"html_url":"https://github.com/dlevsha/compalex","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlevsha%2Fcompalex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlevsha%2Fcompalex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlevsha%2Fcompalex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlevsha%2Fcompalex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dlevsha","download_url":"https://codeload.github.com/dlevsha/compalex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247157283,"owners_count":20893220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compared-databases","database-management","database-migrations","database-schema","database-structure","mssql-diff","mysql-diff","mysqldiff","pgsql-http","postgresql-diff"],"created_at":"2024-10-15T01:11:39.720Z","updated_at":"2025-04-04T10:09:06.497Z","avatar_url":"https://github.com/dlevsha.png","language":"PHP","readme":"# README\n\n## What is Compalex?\nCompalex is a lightweight script to compare two database schemas. It supports MySQL, MS SQL Server and PostgreSQL.\n\nTry [demo](http://demo.compalex.net/) or visit [http://compalex.net/](http://compalex.net/)\n\n## How to use \n\nThe easiest way to use Compalex is to use Docker.\n\nYou can build your own container using Dockerfile or use Docker Hub image:\n\n```bash\ndocker run -it -e DATABASE_DRIVER='mysql' \\\n-e DATABASE_ENCODING='utf8' \\\n-e SAMPLE_DATA_LENGTH='100' \\\n-e DATABASE_HOST='host.docker.internal' \\\n-e DATABASE_PORT='3306' \\\n-e DATABASE_NAME='compalex_dev' \\\n-e DATABASE_USER='root' \\\n-e DATABASE_PASSWORD='password' \\\n-e DATABASE_DESCRIPTION='Developer database' \\\n-e DATABASE_HOST_SECONDARY='host.docker.internal' \\\n-e DATABASE_PORT_SECONDARY='3306' \\\n-e DATABASE_NAME_SECONDARY='compalex_prod' \\\n-e DATABASE_USER_SECONDARY='root' \\\n-e DATABASE_PASSWORD_SECONDARY='password' \\\n-e DATABASE_DESCRIPTION_SECONDARY='Production database' \\\n-p 8000:8000 dlevsha/compalex\n```\n\nYou need to change variables for your own \n\n`DATABASE_DRIVER` - database driver, possible value\n\n- `mysql` - for MySQL database\n- `pgsql` - for PostgreSQL database\n- `dblib` - for Microsoft SQL Server database\n- `oci`   - for Oracle database\n\n`DATABASE_HOST` and `DATABASE_HOST_SECONDARY`  - database host name or IP for first and second server\n\nIf your compared DB run locally:\n\n- for [MacOS](https://docs.docker.com/docker-for-mac/networking/) and [Windows](https://docs.docker.com/docker-for-windows/networking/) \nuser: use ```host.docker.internal``` instead of ```localhost``` in ```DATABASE_HOST``` and ```DATABASE_HOST_SECONDARY``` param.\nBecause we run script inside container we need to use Host machine IP for connection. \n\n- for [Linux](https://docs.docker.com/network/host/) user: use ```--network host``` option and ```localhost``` in ```DATABASE_HOST``` and ```DATABASE_HOST_SECONDARY``` param.\n\nIf you connect to DB outside your machine (external IP) use: ```-e DATABASE_HOST='[Your external IP]'```.\n\n`DATABASE_PORT` and `DATABASE_PORT_SECONDARY` - database port for first and second server\n\nDefault ports for DB:\n\n- `3306` - Mysql\n- `5432` - PostgreSQL\n- `1433` - MSSQL\n- `1521` - Oracle\n\n`DATABASE_NAME` and `DATABASE_NAME_SECONDARY` - first and second database name\n\n`DATABASE_USER` / `DATABASE_PASSWORD`  and `DATABASE_USER_SECONDARY` / `DATABASE_PASSWORD_SECONDARY` - login and password to access your databases \n\n`DATABASE_DESCRIPTION` and `DATABASE_DESCRIPTION_SECONDARY` - server description (not necessary). For information only. These names will display as a database name.\n\nYou can also use ```docker-compose.yml```.\n\n```\nversion: \"3.7\"\n\nservices:\n  compalex:\n    image: dlevsha/compalex\n    container_name: compalex\n    environment:\n      - DATABASE_DRIVER=mysql\n      - DATABASE_ENCODING=utf8\n      - SAMPLE_DATA_LENGTH=100\n      - DATABASE_HOST=host.docker.internal\n      - DATABASE_PORT=3306\n      - DATABASE_NAME=compalex_dev\n      - DATABASE_USER=root\n      - DATABASE_PASSWORD=password\n      - DATABASE_DESCRIPTION=Developer database\n      - DATABASE_HOST_SECONDARY=host.docker.internal\n      - DATABASE_PORT_SECONDARY=3306\n      - DATABASE_NAME_SECONDARY=compalex_prod\n      - DATABASE_USER_SECONDARY=root\n      - DATABASE_PASSWORD_SECONDARY=password\n      - DATABASE_DESCRIPTION_SECONDARY=Production database\n    ports:\n      - \"8000:8000\"\n```\n\n## Requirements\nIf you prefer use Compalex as PHP script please read instruction bellow. \n\nCompalex is only supported by PHP 5.4 and up with PDO extension.\n\n## Installation\n\n\t$ git clone https://github.com/dlevsha/compalex.git\n\t$ cd compalex\n\t\nOpen `.environment`. You'll see configuration params\n\n```ini\n[ Main settings ]\n; Possible DATABASE_DRIVER: 'mysql', 'pgsql', 'dblib', 'oci'.\n; Please use 'dblib' for Microsoft SQL Server\nDATABASE_DRIVER = mysql\nDATABASE_ENCODING = utf8\nSAMPLE_DATA_LENGTH = 100\n\n[ Primary connection params ]\nDATABASE_HOST = localhost\nDATABASE_PORT = 3306\nDATABASE_NAME = compalex_dev\nDATABASE_USER = root\nDATABASE_PASSWORD =\nDATABASE_DESCRIPTION = Developer database\n\n[ Secondary connection params ]\nDATABASE_HOST_SECONDARY = localhost\nDATABASE_PORT_SECONDARY = 3306\nDATABASE_NAME_SECONDARY = compalex_prod\nDATABASE_USER_SECONDARY = root\nDATABASE_PASSWORD_SECONDARY =\nDATABASE_DESCRIPTION_SECONDARY = Production database\n```\n\nwhere \n\n`DATABASE_DRIVER` - database driver, possible value\n\n- `mysql` - for MySQL database\n- `pgsql` - for PostgreSQL database\n- `dblib` - for Microsoft SQL Server database\n- `oci`   - for Oracle database\n\n`[ Primary connection params ]` and `[ Secondary connection params ]`sections describes settings for first and second databases.\n\nWhere\n\n`DATABASE_HOST` and `DATABASE_HOST_SECONDARY`  - database host name or IP for first and second server\n\n`DATABASE_PORT` and `DATABASE_PORT_SECONDARY` - database port for first and second server\n\nDefault ports:\n\n- `3306` - Mysql\n- `5432` - PostgreSQL\n- `1433` - MSSQL\n- `1521` - Oracle\n\n\n`DATABASE_NAME` and `DATABASE_NAME_SECONDARY` - first and second database name\n\n`DATABASE_USER` / `DATABASE_PASSWORD`  and `DATABASE_USER_SECONDARY` / `DATABASE_PASSWORD_SECONDARY` - login and password to access your databases \n\n`DATABASE_DESCRIPTION` and `DATABASE_DESCRIPTION_SECONDARY` - server description (not necessary). For information only. These names will display as a database name.\n\nInside `compalex` directory run  \n\n\t$ php -S localhost:8000\n\t\nNow open your browser and type `http://localhost:8000/`\n\nYou'll see database schema of two compared databases.\n\n-\n![Database Compare Panel](https://cloud.githubusercontent.com/assets/1639576/9703302/1327b858-5488-11e5-856a-96b139c7b938.png)\t\n-\n\nYou can run this script in terminal (for example, if you don't have direct connection to database).\n\nI recommend [eLinks](https://en.wikipedia.org/wiki/ELinks) (free text-based console web browser) because it supports HTML-formatting and colors.\n\nInstall the script and run web-server as described above on your server. \n\nThen run:\n\n\t$ elinks http://localhost:8000\n\nYou'll see database schema in your terminal\n\n![Database schema in terminal](https://cloud.githubusercontent.com/assets/1639576/10304652/248de29e-6c24-11e5-863b-c94bf337f47d.png)\n\nSometimes you have only SSH access to remote database server and you can't open port for external connections. \nIn this case you can use port forwarding via SSH\n\n\n    ssh -L 1522:localhost:1521 [user name]@[remote host 1]\n    ssh -L 1523:localhost:1521 [user name]@[remote host 2]\n\nThis command will forward `1521` port from remote servers to local `1522` and `1523` respectively. \n\nLICENSE\n-------\n\nCopyright (c) 2021, Levsha Dmitry\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\t\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdlevsha%2Fcompalex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdlevsha%2Fcompalex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdlevsha%2Fcompalex/lists"}