Skip to content

Command line tool for comparing databases, built upon Doctrine DBAL

License

Notifications You must be signed in to change notification settings

talkrz/sql-compare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sql-compare

Command line tool for comparing database schemas, built upon Doctrine DBAL

Usage

Download the executable: sql-compare.phar

# Prefer to download from CLI? You can use wget or curl:
wget https://github.com/talkrz/sql-compare/releases/download/v1.0.0/sql-compare.phar
curl -L "https://github.com/talkrz/sql-compare/releases/download/v1.0.0/sql-compare.phar" -o sql-compare.phar

To compare two MySQL databases type:

php sql-compare.phar mysql://user:secret@server/db1 mysql://user:secret@server/db2

The tool will output a list of SQL queries required to update the first database schema to be identical with the second one. Let's assume that db1 database, when compared the db2, has following differences:

  • it does not contain missing_table table
  • some_table table does not contain the missing_field column
  • the changed_field of some_table has different type
  • the index on some_id field in some_table is missing

Then the output of the command will be as follows:

CREATE TABLE missing_table (id INT NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB
ALTER TABLE some_table ADD missing_field INT DEFAULT NULL, CHANGE changed_field changed_field VARCHAR(255) DEFAULT NULL
CREATE INDEX missing_index ON some_table (some_id)

You can use any database URL allowed by Doctrine DBAL. Look ad the docs for more details: http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url

About

Command line tool for comparing databases, built upon Doctrine DBAL

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages