3

A rails application is configured to run with postgis. Database.yml is configured as follows:

development:
  adapter: postgis
  database: app_development
  username: simpleton
  schema_search_path: public, postgis

for the schema search path, the attempt is to ensure that postgis is not installed twice by enacting as follows
app_development=#

DROP EXTENSION PostGIS;

CREATE SCHEMA postgis;
CREATE EXTENSION PostGIS WITH SCHEMA postgis;
GRANT ALL ON postgis.geometry_columns TO PUBLIC;
GRANT ALL ON postgis.spatial_ref_sys TO PUBLIC;

which generates the error

ERROR:  function postgis_full_version() does not exist
LINE 1: SELECT PostGIS_full_version();
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

Oddly, if the configuration is without a schema, i.e.

schema_search_path: public, postgis
CREATE EXTENSION PostGIS;

the SELECT command runs and the database migration can occur.

Why is this behaviour apparently selective?

4

You need to add postgis to your search path:

Try

ALTER DATABASE name_of_your_db SET search_path = public, postgis;

Then disconnect from your database and reconnect. It should work.

  • Yes, this worked. Just for clarification purposes... by setting two search paths, this should not create confusion for postgresql (or have double installation of postgis?) And the postgis path should remain exclusive to postgis, correct? – Jerome Aug 21 '15 at 8:54
  • If you use CREATE EXTENSION, it's not possible to install 2 postgis in same database. So I wouldn't worry about it. That was an issue if you installed using the old script way. – LR1234567 Aug 21 '15 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.