gpt4 book ai didi

ruby-on-rails - 在 Rails 2 项目上运行 rake 命令时出错

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

我正在使用以下 gem、georuby、spatial_adapter 运行一个 Rails 2 项目。和 Postgres 数据库作为后端。但我正面临这个错误。我也厌倦了安装 postgis,但仍然可以。任何想法我应该尝试。这是一个 Rails 2.3 项目,所以我缺少一些版本要求。该声明似乎是正确的,我也查了一下。请帮忙。

[root@localhost webapp]# rake db:migrate 
(in /root/mysite/webapp)
== CreatePlaces: migrating ===================================================
-- create_table(:places, {:id=>false})
-> 0.0030s
-- execute("alter table places add primary key (id)")
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "places_pkey" for table "places"
-> 0.1144s
-- execute("select AddGeometryColumn('public', 'places', 'point_geometry', 4326, 'POINT', 3)")
rake aborted!
An error has occurred, this and all later migrations canceled:

PGError: ERROR: function addgeometrycolumn(unknown, unknown, unknown, integer, unknown, integer) does not exist
LINE 1: select AddGeometryColumn('public', 'places', 'point_geometry...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
: select AddGeometryColumn('public', 'places', 'point_geometry', 4326, 'POINT', 3)

谢谢

最佳答案

我没有将 post gis 与 postgres 联系起来。于是就面临着这个问题。

按照以下步骤首先创建您的数据库。

创建 PostGIS 数据库的第一步是创建一个简单的 PostgreSQL 数据库。

createdb [yourdatabase]

Many of the PostGIS functions are written in the PL/pgSQL procedural language. As such, the next step to create a PostGIS database is to enable the PL/pgSQL language in your new database. This is accomplish by the command

createlang plpgsql [yourdatabase]

Now load the PostGIS object and function definitions into your database by loading the postgis.sql definitions file (located in [prefix]/share/contrib as specified during the configuration step).

psql -d [yourdatabase] -f postgis.sql

For a complete set of EPSG coordinate system definition identifiers, you can also load the spatial_ref_sys.sql definitions file and populate the spatial_ref_sys table. This will permit you to perform ST_Transform() operations on geometries.

psql -d [yourdatabase] -f spatial_ref_sys.sql

If you wish to add comments to the PostGIS functions, the final step is to load the postgis_comments.sql into your spatial database. The comments can be viewed by simply typing \dd [function_name] from a psql terminal window.

psql -d [yourdatabase] -f postgis_comments.sql

关于ruby-on-rails - 在 Rails 2 项目上运行 rake 命令时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9325857/

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