Chapter 5: Export, import and diff
In this chapter, the three most important auxiliary features introduced by pgModeler will be fully detailed. These features are the model export (or forward engineering), the database import (or reverse engineering), and model-database diff. However, before starting to describe them, it is important to mention that these features will work exclusively on PostgreSQL versions between 10.x and 18.x. Older versions of PostgreSQL (series 9.x) are supported via compatibility mode (enabled in the general settings), but there's no guarantee that these features will produce reliable results, so take extreme care when running the operations described in this chapter in older database versions.
The main pgModeler feature, the database modeling, would be almost useless if the export, import, and diff didn't exist. This is because often the user who is working on a database model needs to do real tests of the structure being created by exporting the model to a server to make the needed validations. In other moments, the user needs to generate a graphical representation from an existing database that was not generated from a model, so reverse engineering will be used to achieve the desired result.
Now, to keep any changes synchronized between the model and the database, or even between two databases, the user will need to run the diff process, which will analyze them, pointing out any divergences and generating the needed code to keep the involved entities in sync. For those reasons, these features are of great importance in the modeling process as a whole.
Since some of these operations are “invasive” to the database, to be able to execute them without any issues, at least one connection must be configured with a privileged user. A privileged user is not necessarily the superuser, but a role that is capable of creating a database (for the export process) and with privileges to read the system catalogs (for import and diff). Refer to the previous chapter, section Connections settings, to see how to configure connections in pgModeler.
These features are available as views of the main window, selected in the views bar: Export, Import and Diff (the last two are Plus features). The shortcuts of the import and diff views are Ctrl+Shift+I and Ctrl+Shift+D, respectively. The export view requires at least one model loaded in the Design view, and both the export and diff views take the model to be handled from the list of the loaded ones.