Skip to main content
Version: 2.0.0 (latest)

From model to database

A model is only a description. This page shows the short path from a finished model to a database. All the options of the export dialog are in Export a model.

Before exporting

  1. Validate the model (Alt + V, then Validate) and fix what is reported (the Apply fixes button handles most of the errors). The export fails or produces a broken script on a model that does not validate.
  2. Save the model (Ctrl + S).
  3. If you are exporting to a server that already has the database, make a backup first: exporting over an existing database can destroy data. To update an existing database without recreating it, use the diff instead of exporting.

Export to a SQL file

This is the safest first export, as nothing is sent to a server. Open the export dialog with Ctrl + Shift + E, choose SQL file, pick the file name and click Export. The result is an ordinary script that you can read, run with psql or keep in your repository.

Export to a server

In the same dialog, choose the Database server mode. You need a connection to the server: if you do not have one yet, create it in the dialog itself or in the connections settings. Select the connection and click Export. The progress and any error returned by PostgreSQL appear in the Output tab.

Other formats

The same dialog exports the model as a PNG or SVG image (for documents and presentations) and as a data dictionary in HTML or Markdown (a readable description of tables and columns).

When the database already exists

Two features cover this case, and both are worth knowing early. They are pgModeler Plus features; in Community, work with SQL files, or with the export to a server, instead (see Community and Plus editions):

  • Import a database (Ctrl + Shift + I) reads an existing database and builds the model from it (reverse engineering).
  • Compare model and database (Ctrl + Shift + D) compares the model with a database and generates the SQL to synchronize them, or applies it directly.