4.6. Manual update of the datamodel
This page explains how to update your datamodel manually. Alternatively, the data-model tool offers a graphical interface that automates these steps and is usually easier to use.
Update is done using PUM available on linux and windows environment. It does not require to be run on the server directly but can be run from a remote client or a virtual machine. Pirogue is required for views regeneration.
pg_restore must be available from the terminal, they are installed along with PostgreSQL. The version of the client postgresql and the server postgresql must match.
pg_restore are installed on the client, PUM has to use the proper version.
You can either:
Set the default
sudo ln -s /usr/lib/postgresql/XX/bin/pg_dump /usr/bin/pg_dump --force
Make use of the PUM config file.
The default python must be python 3.
220.127.116.11. PUM installation
pip3 install pum
To update PUM
pip3 install --upgrade pum
sudo can be used to install
pirogue system wide or the
--user flag can be used to install they into the current user’s home directory.
If you encounter any problem with PUM installation or usage, check the PUM documentation.
18.104.22.168. Pirogue installation
pip3 install pirogue
To update pirogue
pip3 install --upgrade pirogue
4.6.2. Database update
For the following commands the database is connected with the service
22.214.171.124. PostgreSQL service
The parameters to connect to the databases are provided in a service file (for instance the file
There are at least three services inside:
qgep_prod database to be updated
qgep_test database which will store a test of the update
qgep_comp current model, after the update the
qgep_comp models should be similar.
126.96.36.199. Database backup
It is recommended to backup the database before the update. In command line:
pg_dump -Fc -f /path/to/dump/qgep_prod.dump -d "service=qgep_prod"
188.8.131.52. Download and install current database release
Download current datamodel release from
<release_number>with the desired version, such as
1.5.4). Run the following commands from the unzipped directory.
Create current database. It is used for comparison (target).
psql -h host -p port -U postgres -c 'CREATE DATABASE qgep_comp;'
Install current datamodel release.
./scripts/db_setup.sh -f -r -p qgep_comp Launched from the
184.108.40.206. Create empty database
Create test database. It is used to test the update processus.
psql -h host -p port -U postgres -c 'CREATE DATABASE qgep_test;'
220.127.116.11. Launch update
The following command must be launched form the
pum test-and-upgrade -pp qgep_prod -pt qgep_test -pc qgep_comp -t qgep_sys.pum_info -f dump.dump -d delta/ -i constraints views indexes --exclude-schema public --exclude-schema qgep_migration -v int SRID 2056 -x.
-tTable which stores the database versions and update state
-fA backup file which is generated during the process. It is restored in
-iThe constraints, views and indexes are ignored (if they are not similar in
qgep_testafter the update, the processus continue anyway.
-- exclude-schemaschema which is ignored in the comparison
-vParameters of the delta scripts
-xIgnore restore errors (materialized views can generate
--exclude-field-pattern 'usr_%'if custom attributes were added