Postgis is not setting up in Rails application

244 Views Asked by At

I am integrating PostGIS in a rails application and following their documentation https://github.com/rgeo/activerecord-postgis-adapter.

At this step

rake db:create

I get the following error.

ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR: syntax error at or near "SUPPORT" : CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public

My database.yml

default: &default
  adapter: postgresql
  encoding: unicode
  # For details on connection pooling, see Rails configuration guide
  # http://guides.rubyonrails.org/configuring.html#database-pooling
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
  adapter: postgis
  encoding: unicode
  postgis_extension: postgis      # default is postgis
  postgis_schema: public          # default is public
  schema_search_path: public,postgis
  pool: 5
  database: my_app_development    # your database name


test:
  <<: *default
  database: my_app_test

production:
  <<: *default
  database: my_app_production
  username: my_app
  password: <%= ENV['MY_APP_DATABASE_PASSWORD'] %>
1

There are 1 best solutions below

0
cnnr On

Just remove all options, that you don't really need in you database.yml.

default: &default
  adapter: postgis
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
  <<: *default
  database: my_app_development    # your database name

test:
  <<: *default
  database: my_app_test

production:
  <<: *default
  database: my_app_production
  username: my_app
  password: <%= ENV['MY_APP_DATABASE_PASSWORD'] %>