1.5 KiB
how to set up postgis
use docker-postgis
setting docker-postgis to use django unit testing
- get into the running docker shell
- open postgresql client as postgres user (you have to do this from the command line in the container as you cannot do it remotely)
- ALTER ROLE <user_name> SUPERUSER;
- 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'