savage-lands/share/readmes/postgis.md
2025-04-17 00:41:48 +03:00

1.5 KiB

how to set up postgis

use docker-postgis

setting docker-postgis to use django unit testing

  1. get into the running docker shell
  2. open postgresql client as postgres user (you have to do this from the command line in the container as you cannot do it remotely)
  3. ALTER ROLE <user_name> SUPERUSER;
  4. set <user_name> as admin

now the admin can run the tests

sudo docker exec -it minyanfinder_development_db bash

another more elegant solution to the problem

create extension without superuser role

potential problem if it's not working

createdb template_postgis; # create a new database psql -U postgres -c "UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis';" # make it a template psql -U postpsql -U postgres -d template_postgis -c "CREATE EXTENSION postgis;" # install postgis in it

example: createdb -h localhost -p 49032 -U admin template_postgis psql -h localhost -p 49032 -U admin minyanfinder_dev -c "UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis';" psql -h localhost -p 49032 -U admin -d template_gis -c "CREATE EXTENSION postgis;"

in local settings file:

DATABASES['default']['TEST'] = dict() DATABASES['default']['TEST']['TEMPLATE'] = 'template_postgis'