Rails 与 postgresql+postgis 几何数据类型不完全兼容
我使用的是 Rails 3.1,并且有带有 PostGIS geometry
数据类型的表。这些似乎与 rake db:schema:dump 或 rake db:test:clone 以及 rake test:* 任务不兼容。这些 rake 任务根本不会处理和实例化包含此数据类型的表。
有没有任何补丁或解决方案可以解决这个问题?
I'm using Rails 3.1, and I have tables with the PostGIS geometry
datatype. These don't seem to be compatible with rake db:schema:dump
or rake db:test:clone
and the rake test:*
tasks. The tables containing this datatype are simply not processed and instantiated by these rake tasks.
Is there any patch or solution for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一个解决方案:
首先,您需要一个支持 PostGIS 功能的 PostgreSQL
模板
。创建模板数据库:
将必要的 PostGIS 函数加载到模板中(我使用的是 Homebrew,因此找到 PostGIS SQL 文件的路径):
将数据库设置为模板并授予权限:
然后,添加
gem 'postgis_adapter'
到您的Gemfile
并运行bundle
。之后,将
template: template_postgis
添加到您的config/database.yml
中,如下所示:然后 - 瞧!欢迎登机!
There is a solution:
First of all, you need a PostgreSQL
template
with PostGIS functions support.Create a template database:
Load necessary PostGIS functions into template (I'm using Homebrew, so find the paths to your PostGIS SQL files):
Set database as template and grant permissions:
Then, add
gem 'postgis_adapter'
to yourGemfile
and runbundle
.After that add
template: template_postgis
to yourconfig/database.yml
like this:And - voila! Welcome on board!