2012-02-17 155 views
1

我正在使用以下gem,georuby,spatial_adapter運行rails 2項目。 Postgres數據庫作爲後端。但是我正面臨着這個錯誤。我厭倦了安裝postgis,但仍然得到這個。任何想法我應該嘗試。這是一個rails 2.3項目,所以我缺少一些版本要求。聲明似乎是正確的,我也將它綁起來。請幫忙。在Rails 2項目上運行Rake命令時出現錯誤

[[email protected] 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) 

感謝

+0

我覺得你的問題在於你的PostgreSQL/PostGis的安裝,而不是rails/ruby​​相關。 – shingara 2012-02-17 09:40:03

+0

是我也覺得,但是你能否確認語法是否正確。還建議我可能需要哪個版本的postgres和/或postgis。我目前在fedora盒子上使用gr 8.4和postgis 1.5.3。 – 2012-02-17 10:21:29

+0

我還沒有鏈接postgres和postgres。因此面臨這個問題。 請按照postgis站點上的步驟將第一個和第一個創建數據庫鏈接起來。 – 2012-02-17 13:02:02

回答

2

我還沒有掛後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 
相關問題