DbSchema uses its own model with a copy of the schema structure, separate from the database. The DbSchema model can be created by reverse engineering schema from an existing database or by designing the schema from scratch.
Working with a DbSchema model means that:
If you created a schema from scratch and want to update it in the database, all you have to do is:
These features are useful if you work on the schema without being connected to the database.
What does it mean to convert a schema to a different database?
The DbSchema model (.dbs) is an XML file, that can be opened in any text editor. This file can be stored in a version repository like GIT, Mercurial, SVN, CVS, etc. Multiple developers can work on it and synchronize the changes.
Model files store the schema, so why not to synchronize it with another model file? Suppose you develop a schema, save it to the model file and store this file in a GIT or other versioning repository. Later you want to see the schema differences between the two different versions. You can open one file in DbSchema and compare it with the second. Then you can generate the migration script from one to the other.
In the Synchronization Dialog, there is a button for creating custom synchronization filters. Using these filters you may decide to reject certain differences. For example you may want to ignore tables existing on the server having a certain pattern. In the Sync Dialog, you will find a button for creating custom Synchronization Filters. Use this to create a rule for always rejecting certain differences. For example, you may always want to ignore tables that contain a certain person.
import com.wisecoders.dbs.dbms.sync.engine.diffs.*
import com.wisecoders.dbs.schema.*
return new SyncFilter() {
public boolean rejectDiff(AbstractDiff diff) {
if (diff instanceof TableExistsDiff) {
SyncPair pair = ((TableExistsDiff) diff).pair;
if (pair.right != null && pair.right.getName().startsWith("OTHER")) {
return true;
}
}
return false;
}
};
The complete list of DbSchema classes is documented in the DbSchema API.
DbSchema APIFor more examples regarding task automation using Groovy scripts, visit the DbSchema Automation page.
Schema synchronization can be done without the Graphical User Interface. DbSchema supports Groovy scripts with full access to DbSchema API. This can be saved to the file and passed as a parameter to DbSchema executable. Look for examples on our DbSchema Automation page.