gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 11:13:24 25 4
gpt4 key购买 nike

我正在关注 Daniel Azuma 在 geospatial analysis with rails 上的演讲但是每当我在第二个项目中运行 rake db:migrate 时都会遇到困难。

我的设置细节如下:我正在使用 Postgres.app 运行 Postgresql这给了我 9.1.3 版的 Postgres 和 2.0.0 版的 PostGIS。我在 database.yml 文件和运行迁移时遇到了一些问题。 (我已经添加了相关的 gem 并在 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'

有没有人知道如何解决这些问题?

最佳答案

在公共(public)模式中删除 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

关于ruby-on-rails - Rails + PostGIS 错误迁移数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12190178/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com