2.2. Database initialization¶
Note that installing QWAT using the initialization script is only required for contributing to the model or extending the model. If you only need to test a demo or use a production database, a regular postgreSQL dump is enough. See Demo page for that.
Assuming you have installed a postgresql server. In a shell:
git clone https://github.com/qwat/qwat cd qwat
Update data-model submodule:
git submodule update --init --recursive
In order to create the database model you need to create a postgresql database. Do to this you may execute for example:
psql -U postgres -c 'create database qwat'
You can choose whatever name for the database and whatever user as its owner. The script that is used to create the database model looks for the .pg_service.conf file in the users home directory or in the directory specified by the PGSYSCONFDIR or PGSERVICEFILE variables.
Assuming you named your database
qwat, edit the
.pg_service.conf file and make it look like:
[qwat] #enter your database ip host=127.0.0.1 #database name dbname=qwat port=5432 user=postgres #you can also add your password if you like password=YourPassword
Now go to the
data-model directory and run the
cd data-model ./init_qwat.sh -p qwat -s 21781 -d -r
The script has the following options:
-pPG service to connect to the database.
--sridPostGIS SRID. Default to 21781 (ch1903)
--drop-schemadrop schemas (cascaded) if they exist
--create-rolescreate roles in the database
Viewer: Can consult tables and views.
User: Can edit data.
Manager: Can edit data and value lists.
Admin: Database administrator.
126.96.36.199. Restore demo datamodel¶
Optionally, you can restore a sample dataset. For that you need to download the data sample dump and restore it into the QWAT database with pgAdmin or with pg_restore, assuming you have named the download file qwat_dump.backup:
pg_restore -U postgres --dbname qwat -e --no-owner --verbose --jobs=3 --disable-triggers --port 5432 qwat_dump.backup