加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Rails PostGIS错误迁移数据库

发布时间:2020-12-16 20:01:08 所属栏目:百科 来源:网络整理
导读:我正在关注Daniel Azuma在 geospatial analysis with rails的演讲,但是当我运行rake db:在第二个项目中迁移时,我遇到困难. 我的设置细节如下:我正在运行Postgresql Postgres.app,它给了Postgres 9.1.3版本和PostGIS 2.0.0版本.我遇到几个问题与database.ym
我正在关注Daniel Azuma在 geospatial analysis with rails的演讲,但是当我运行rake db:在第二个项目中迁移时,我遇到困难.

我的设置细节如下:我正在运行Postgresql Postgres.app,它给了Postgres 9.1.3版本和PostGIS 2.0.0版本.我遇到几个问题与database.yml文件,并运行迁移. (我已经添加了相关的宝石,并在application.rb中要求他们的信息)

我的database.yml文件如下所示:

development:
   adapter: postgis
   postgis_extension: true
   host: localhost
   encoding: unicode
   database: my_app_development
   pool: 5
   username: my_app
   password:

如果我添加以下行schema_search_path:“public,postgis”我得到:

rake aborted!
 PG::Error: ERROR:  schema "postgis" does not exist
 : SET search_path TO public,postgis

如果我删除该行我尝试迁移我的数据库时收到以下错误:

rake aborted!
PG::Error: ERROR:  relation "geometry_columns" does not exist
LINE 1: SELECT * FROM geometry_columns WHERE f_table_name='schema_mi...                       ^
: SELECT * FROM geometry_columns WHERE f_table_name='schema_migrations'

有没有人想到如何解决这些问题?

解决方法

将PostGIS扩展在公共模式中,并在postgis模式中重新创建它.
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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读