It is possible to synchronize a model in MySQL Workbench with a live database. By default, the synchronization process will change the live database to be the same as the model, but this is configurable during the synchronization process.
MySQL Workbench allows you control over the direction of synchronization, and the objects synchronized, in a completely flexible way. You can choose to synchronize only certain tables, allow synchronization to the live database only, allow synchronization from the live database to the model only, or a combination of directions. In effect you have complete control as to whether the synchronization is unidirectional or bidirectional, and which objects exactly are subject to synchronization. This is all controlled in the Select Changes to Apply page of the synchronization wizard:
In the above example the live database consists of
table1
, table2
and
table3
. In MySQL Workbench an additional table,
table4
, has been created, along with a
relationship between it and table3
. Further,
table5
exists in the live database, but not in
the model. The actions that are configured to occur would result
in table3
being altered (to include the
relationship with table4
),
table4
being created and
table5
being dropped, in the live database. It
is possible to reconfigure this though.
The next example shows how the direction of synchronization can be changed:
In this case the synchronization direction has been changed so
that rather than the default action of table5
being dropped from the live database, it will be incorporated into
the MySQL Workbench model.
For convenience the wizard provides three additional buttons to allows synchronization directions to be applied to a group of selected changes. The Update Model button causes the selected changes to only be applied to the model itself:
In the above example table7
would be added to
the model.
The Ignore button causes the selected changes to be ignored, no synchronization will take place for those changes:
In the above example no changes would take place.
The Update Source button causes the selected changes to only update the live database:
In this example table6
would be added to the
live database and table7
would be dropped from
the live database.
It is also possible to control individual changes by clicking on the arrows. Clicking an arrow causes it to change between the three available synchronization directions:
In the above example table6
will be created in
the live database, and table7
will be created
in the model.