3

I am using django-tenant-schemas for multi-tenancy on my app (see: https://github.com/bernardopires/django-tenant-schemas)

It works fine locally, but on Heroku I face a problem when I try to run migrations for a non-public schema:

My backend engine is django.contrib.gis.db.backends.postgis; when django creates a non-public schema and sets the search path to the newly created schema for migration, it tries to run CREATE EXTENSION IF NOT EXISTS postgis, which throws the following error:

NOTICE:  extension "postgis" already exists, skipping
ERROR:  relation "spatial_ref_sys" does not exist

If I run the same command on my public schema, psql handles it gracefully and just gives me the notice, and of course it only happens on heroku.

Not sure if it is relevant, but the following is included in my buildpacks:
https://github.com/cyberdelia/heroku-geo-buildpack

I searched a lot, but so far have not found a solution. Any help on how to fix this error is much appreciated! 🙂