Rails + PostGIS errors migrating database
Drop PostGIS extenion in public schema and recreate it in postgis schema.
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
Here is how I solved the issue. I first created a new migration to add postgis to the database. (I have already installed both postgis and postgresql through homebrew on a mac.)
rails g migration add_postgis_to_database
In the migration file I removed the change method and used the execute method to add POSTGIS.
execute("CREATE EXTENSION postgis;")
After that you can check the database to make sure that postgis is available.
psql your_database_nameSELECT PostGIS_full_version();
Actually, the install command needs to invoke the postgis version
sudo apt-get install -y postgis postgresql-9.3-postgis-2.1
The simplest way forward is then to declare
sudo -u postgres psql -c "CREATE EXTENSION postgis" your-pg-database-name
avoiding migration hiccups.