2012-01-03 93 views
4

我使用Rails 3.1,我与PostGIS的geometry数据类型的表不完全兼容。这些似乎与rake db:schema:dumprake db:test:clonerake test:*任务不兼容。包含这个数据类型的表只是不被这些rake任务处理和实例化。Rails的PostgreSQL的+ PostGIS几何数据类型

是否有补丁或解决方案呢?

+0

我有我的PostGIS数据库指向类似的问题,我们认为,我们已经把范围缩小到SchemaDumper方法,可能与spacial_adapter。我还没有解决方法。 – 2012-01-13 17:17:01

回答

4

有一个解决方案:

首先,你需要一个PostgreSQL template在PostGIS功能的支持。

创建模板数据库:

$ psql -U postgres 
> CREATE DATABASE template_postgis WITH TEMPLATE=template1 ENCODING='UTF8'; 
> \c template_postgis; 
> CREATE LANGUAGE plpgsql; 

加载必要的PostGIS功能为模板(我使用的是自制,于是找到路径到您的PostGIS SQL文件):

$ psql -f /usr/local/share/postgis/postgis.sql template_postgis 
$ psql -f /usr/local/share/postgis/spatial_ref_sys.sql template_postgis 

设置数据库模板和授予权限:

$ psql -U postgres template_postgis 
> UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis'; 
> GRANT ALL ON geometry_columns TO PUBLIC; 
> GRANT ALL ON spatial_ref_sys TO PUBLIC; 

然后,添加gem 'postgis_adapter'到您的Gemfile并运行bundle。 之后添加template: template_postgisconfig/database.yml这样的:

development: 
    adapter: postgresql 
    template: template_postgis 
    database: postgis_db 

而且 - 瞧!欢迎加入!

相关问题