User Tools

Site Tools


db:compareschemas

Comparing Schemas using Mysql Workbench

07.09.2015

This is a short guide how to use Mysql Workbench tool to compare and synchronize two database schemas.

Given situation

We have two (or more databases) with a primary one considered “source” and the rest considered “targets”. Our goal is to make sure that we synchronise the structure of the “source” with the rest of the databases.

Initial situation

Reverse Engineer the source db

(select your source db) → Database → Reverse Engineer

Go through every option in the new popups. Select source db (“prima”) as schema to be reversed when required. By the end of this procedure, two more tabs should appear (MySQL Model and EER Diagram)

After Reversing

Synchronize the model

Also the menu should contain now new options. We’re gonna use Database → Synchronize Model

Again, a couple of choices to be made. You can proceed by the default ones until you hit Select Schemata (4th screen). Here you should have the Model Schema already selected as “prima”. In order to work, select from the dropdown the target db (“secunda”) and click “Override Target”. Your result should look like in the next screenshot:

Selecting schemes

Check the produced differences

Going for the next steps, you’re gonna reach “Select Changes to Apply”. Here you can easily check for the differences.

The Result

Going for the next step you can see actually the sql produced and that needs to be applied for your schemas. You can do that either manually (after reviewing it) or just automatically using MysqlWorkbench.

Resulted SQL

db/compareschemas.txt · Last modified: 2015/09/07 16:45 by admin