在 Rails 2 项目上运行 rake 命令时出现错误

发布于 2025-01-06 07:44:47 字数 1152 浏览 2 评论 0原文

我正在运行一个 Rails 2 项目,其中包含以下 gem、georuby、spatial_adapter。和 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)

谢谢

I am runnning a rails 2 project with the following gems, georuby, spatial_adapter. And Postgres db as backend. But I am facing this error. I tired installing postgis also but still get this. Any ideas what i should try. This is a rails 2.3 project ,so is it some version requirements i am missing. The statement seems to be correct and i tied looking it up too. Please help.

[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)

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

习惯成性 2025-01-13 07:44:47

我没有将 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

I had not linked post gis with postgres. Thus was facing this issue.

Follow the steps below and create your db first.

The first step in creating a PostGIS database is to create a simple PostgreSQL database.

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文