5.2. Import a database

The database import process, or reverse engineering as commonly known, consists in read the information about all database objects stored on the system catalogs (pg_catalog.* and information_schema.*) and, based upon these details, generate a reliable database model.

This process works quite well in pgModeler even being experimental but sometimes, depending on the database structure, this process may fail. But, fortunately there are some workarounds that can be used to create almost all database objects without much problems. The image below shows all available options in the import dialog and their details in the following table.

Field/Option Description
Connection Previous configured connection used as communication channel to the server. It is important to remember that the user configured in the selected connection must have the needed permissions to query the system catalogs or the process will certainly fail.
Import objects to the working model Creates all imported objects in the current working model instead of create a new one. This is useful to create several objects from another database to the current model. The option will be enabled only when there is at least one database model being handled on Design view.
Random color for relationships Random colors will be assigned to imported relationships facilitating the identification of links between tables mainly in large models.
Automatically resolve dependencies Try to resolve some of the object's dependencies by querying the catalog when a needed object does not exist on the loaded set. In some cases it's necessary to combine this option with others below. This option does not apply to database level objects like role, tablespace and language as well for data types and extensions.
Import system objects Enables the import of system built-in objects. It's recommend to select only those objects that are directly referenced by the ones to be imported. It's importat to note that trying to import a huge set of system objects can bloat the resultant model or even crash pgModeler due to memory/cpu overuse.
Import extension objects Enables the import of objects created by extensions. Generally there is no need to check this option but if there are objects in the database that directly references this category of objects this mode must be enabled.
Ignore import errors pgModeler ignores import errors and will try to create as many as possible objects. By checking this option the import operation will not be aborted but an incomplete model will be constructed. This option generates a log file on pgModeler's temp directory.
Debug mode All catalog queries as well the created objects' source code are printed to standard output (stdout).
Database This set of fields lists all available databases on the server. The tree view right below the database listing is used to organize the objects directly linked to the selected item above. This view is automatically updated whenever the user changes the working database.
Filter The user can use this to filter the tree view elements. As the user types the name of objects the view is updated. This is useful when you intend to import only a subset of objects and don't remember where exactly the objects are on database, so you can filter them by name and selecting the occurrences as they appear.
By OID This is a modifier for the Filter field. When checked this option causes the filter to match elements on the tree view by the OID (object identifier) instead of the object's name.
Command buttons The four command buttons at the bottom of the Database group are respectively used to select all objects on the tree view, clear the current object selection, expand all items and collapse all items.


In order to start an import process you first need to select the connection to be used in order to establish a new communication to the server. Once connected, all available databases will be listed in the combo box in Database group. Select the desired database and wait for the tree view to be updated with the database objects. Define the desired import options and click Import. The process can be a bit little slow depending on the amount of objects to be imported. Once finished, the dialog is automatically closed and the generated database model is loaded.


Aug 28, 2018 at 15:46