Skip to content

Instantly share code, notes, and snippets.

@llagerlof
Created August 1, 2018 12:11
Show Gist options
  • Save llagerlof/ef1318cb55f24cc95a07adb98bca8441 to your computer and use it in GitHub Desktop.
Save llagerlof/ef1318cb55f24cc95a07adb98bca8441 to your computer and use it in GitHub Desktop.
How to use DBDiff to discover differences between databases' tables structures

How to use DBDiff

https://github.com/DBDiff/DBDiff

  • Create a .dbdiff file in project root directory with the connection settings for 2 servers. Add to "tablesToIgnore" a list of tables and views that should be ignored on comparisson.

.dbdiff

server1:
    user: root
    password:
    port: 3306
    host: localhost
server2:
    user: AzureDiamond
    password: hunter2
    port: 3306
    host: 192.168.1.1
template: templates/db-migrate.tmpl
type: schema
include: up
nocomments: false
tablesToIgnore:
- vw_view1
- vw_view2
  • Create a db-migrate.tmpl in templates directory
-- UP

{{ $up }}

-- END UP


-- DOWN

{{ $down }}

-- END DOWN
  • Execute the command below to generate the database diff file migration.sql
$ ./dbdiff server1.yourdatabase:server2.yourdatabase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment