2012-05-15 97 views
2

我敏捷Web開發使用Rails(第4版)第7章,當我運行rake測試:單元,我得到以下錯誤:爲什麼PostgreSQL告訴我一個模式不存在?

rake aborted! 
PG::Error: ERROR: invalid value for parameter "search_path": "public" 
DETAIL: schema "public" does not exist 
: SET search_path TO public 

Tasks: TOP => db:test:load => db:test:purge 
(See full trace by running task with --trace) 

我在MacBook Pro上使用OSX 10.7。 4。我有Ruby 1.9.3,Rails 3.1.0,Rake 0.9.2.2和PostgreSQL 9.1。我的生產,開發和測試數據庫都存在,已經遷移到並匹配我的config/database.yml文件中的名稱,用戶和密碼。所有這些模式都是公開的。

任何人都可以幫助我嗎?

+0

您用來連接到postgres的用戶是否有權限訪問該架構? 嘗試連接命令行 – Strae

回答

1

根據錯誤消息,架構public不存在。你有沒有檢查,它在那裏?這是另一種可以像其他任何方式一樣丟棄的模式。

+0

所有三個數據庫,開發,生產和測試都有一個公共模式和一個使用'rake db:migrate'的表。我正在從命令行完成所有這些工作,特別是iTerm。 – mightberobot

2

http://www.postgresql.org/docs/9.1/static/infoschema-schemata.html(強調我自己):

 The view schemata contains all schemas in the current database that are owned by a currently enabled role.

如果您正在使用比默認的用戶(postgres)以外的用戶進行連接時,public模式可能不會顯示。 (是的,即使該用戶創建並擁有該數據庫中,public模式由postgres [1]。資)

[1] http://archives.postgresql.org/pgsql-general/2008-10/msg01320.php

4

請確保您的用戶默認數據庫有一個公共的架構。例如,如果使用用戶「postgres」連接到數據庫,那麼應該有一個名爲「postgres」的數據庫,並使用名爲「public」的模式。

相關問題