Pgmodeler is a handy tool for designing databases with an ERD style interface specifically aimed at the PostgreSQL community. It can come in a couple of different ways, but I am going to covering the self build process here. So if you want to learn how to build and install pgmodeler read on!

To be able to build anything you’ll need to install the tools from Ubuntu’s repositories.

sudo apt-get install gcc libxml2-dev postgresql

The first dependency you will need to install is the from QT5 UI toolkit.

sudo add-apt-repository ppa:ubuntu-sdk-team/ppa && sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get install ubuntu-sdk

Next up you’ll need to install libpq:

sudo apt-get install libpq-dev

To ensure that QT is installed correctly verify that you get similar responses to me from the following commands:

pkg-config libpq --cflags --libs
# -I/usr/include -L/usr/lib64/libpq.so

pkg-config libxml-2.0 --cflags --libs
# -I/usr/include/libxml2 -lxml2

If you do not the there is a little manual intervention that you’ll need to perform by creating the /usr/lib/pkgconfig/libpq.pc manually. It should contain code of the following block.

prefix=/usr
libdir=${prefix}/lib/postgresql/[VERSION]/lib
includedir=${prefix}/include/postgresql

Name: LibPQ
Version: 5.0.0
Description: PostgreSQL client library
Requires:
Libs: -L${libdir}/libpq.so -lpq
Cflags: -I${includedir}

So that is all the dependencies taken care of and we can move onto building and installing the actual binary itself.

qmake pgmodeler.pro
make
sudo make install

The binary is now in the build directory so we can call it from there after passing it a few options with a start-up script.

Move into the build directory and create start-pgmodeler.sh.

cd build
vim start-pgmodeler.sh

In the start-up file we want to add the following lines of bash script.

#/bin/bash

# Specify here the full path to the pgmodeler's root directory
export PGMODELER_ROOT="."

export PGMODELER_CONF_DIR="$PGMODELER_ROOT/conf"
export PGMODELER_SCHEMAS_DIR="$PGMODELER_ROOT/schemas"
export PGMODELER_LANG_DIR="$PGMODELER_ROOT/lang"
export PGMODELER_TMP_DIR="$PGMODELER_ROOT/tmp"
export PGMODELER_PLUGINS_DIR="$PGMODELER_ROOT/plugins"
export PGMODELER_CHANDLER_PATH="$PGMODELER_ROOT/pgmodeler-ch"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$PGMODELER_ROOT"
export PATH=$PATH:$PGMODELER_ROOT

# Running pgModeler
pgmodeler

After writing that file and quitting vim you need to set the files executable bit using chmod.

chmod +x start-pdmodeler.sh

You can now run pgmodeler by calling the start-pgmodeler.sh shell script on the command line.

./start-pdmodeler.sh

After the application starts itself you will be greeted by the nice QT interface of pgmodeler. You’re done!