Skip to content

Database setup

Panoramax API relies on a PostgreSQL 12+ database with PostGIS 3.4+ extension to run.

Note

The recommended PostgreSQL version is 15+, since this way, granular permissions can be granted to the user.

You can use your own existing PostgreSQL server, a cloud-managed PostgreSQL database, or have PostgreSQL running in our Docker files. If you want to install your own PostgreSQL server, refer to these software documentation to know more about their install.

Danger

For production-grade deployment, be sure that your database is backuped, it would be a shame to loose all your data πŸ’₯!

Once your PostgreSQL server is ready and running, we recommend you to do the following:

  • Add a system/OS user named panoramax, for example under Linux:
$ sudo useradd panoramax

Tip

On older version of this documentation, the user was named geovisio, that is the case for your setup, either rename your user, or adapt the following commands.

  • Create a PostgreSQL role panoramax with this command:
$ sudo su - postgres -c "psql -c \"CREATE ROLE panoramax LOGIN PASSWORD 'mypassword'\""
  • Create a new database (with UTF-8 encoding) using this command:
$ sudo su - postgres -c "psql -c \"CREATE DATABASE panoramax ENCODING 'UTF-8' TEMPLATE template0 OWNER panoramax\""
  • Enable PostGIS extension in your database:
$ sudo su - postgres -c "psql -d panoramax -c \"CREATE EXTENSION postgis\""
  • Make sure your database is running at UTC timezone:
$ sudo su - postgres -c "psql -d panoramax -c \"ALTER DATABASE panoramax SET TIMEZONE TO 'UTC'\""
$ sudo su - postgres -c "psql -d panoramax -c \"GRANT SET ON PARAMETER session_replication_role TO panoramax\""

else, the user must have superuser privilege (but it's way better to only grant session_replication_role):

$ sudo su - postgres -c "psql -d panoramax -c \"ALTER USER panoramax WITH SUPERUSER\""

Troubleshooting

Got some issues on this part ? Here are a few hints that may help.

  • PostgreSQL server is not listening ?
  • Check the postgresql.conf file and verify that listen_adresses is set to *
  • PostgreSQL says Peer authentication failed ?
  • Check your pg_hba.conf file and verify that a rule exist to allow your panoramax user or any other OS user to login into your database
  • This is particularly useful if you're running only Panoramax API in Docker, with a PostgreSQL database server on your host, where database IP address might look like 172.17.0.*. You may have to add an entry like this to allow login:
host    panoramax   panoramax   172.17.0.0/24   trust