DbSchema keeps a local copy of your schema in the .dbs design model file. Synchronization lets
you keep that model in sync with a live database — in both directions — without writing migration
scripts by hand.
DbSchema works in two modes:
Switch to disconnected mode from the connection menu in the toolbar.
To pull the current database state into your model, click Refresh in the toolbar or go to Schema → Refresh Schema from Database. If the database has changed since you last synced (for example a colleague deployed a migration), DbSchema detects the differences and prompts you to choose an action.
Before applying any changes, DbSchema shows you exactly what differs between your local model and the live database. Open it from Schema → Compare Model with Database, or click Review Changes after a refresh.
The diff view lists added, removed, and modified objects — tables, columns, indexes, foreign keys. For each difference you can choose to update the model, push the change to the database, or skip it.
The Sync Dialog generates the SQL migration statements needed to bring the database in line with your model (or vice versa).
Tip: Save your model to a .dbs file before synchronizing. If something goes wrong, you can
restore the previous state from the file.
If you designed a schema offline and want to create it in a database for the first time, or upgrade an existing database to match your model:
DbSchema can migrate a schema from one database engine to another (e.g. MySQL to PostgreSQL) by remapping data types automatically.
Note: Changing the target database modifies the type mapping in your model. Make a backup copy
of the .dbs file before converting.
Schema synchronization can be scripted and run in headless mode using Groovy automation scripts or the DbSchemaCLI. This is useful for integrating schema deployments into CI/CD pipelines.
See also: Git Integration · Diagrams