问题描述
首先,这可能看起来像:
First of all, this may look like a duplicate of:
但事实并非如此.虽然我在这种情况下收到相同的错误消息.查看db上是否安装了hstore的时候,可以看到是:
but it is not. While I am getting the same error message in the circumstance. When checking to see if hstore is installed on the DB, we can see that it is:
./psql -d photographerio_development -c '\dx'
List of installed extensions
Name | Version | Schema | Description
---------+---------+------------+--------------------------------------------------
hstore | 1.2 | hstore | data type for storing sets of (key, value) pairs
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
它也在 template_1 DB 上.
and it is too on the template_1 DB.
因此,当我尝试运行迁移以添加 hstore 时,我得到 PG::Error: ERROR: extension "hstore" already exists
并且当我注释掉此迁移时,在下一个需要 hstore,它说 PG::UndefinedObject: ERROR: type "hstore" does not exist
这有点矛盾.
So, when I try to run the migration to add the hstore, I get the PG::Error: ERROR: extension "hstore" already exists
and when I comment out this migration, on the next one, which requires the hstore, it says PG::UndefinedObject: ERROR: type "hstore" does not exist
which is a bit of a paradox.
这是一个带有 postgresql 9 的 Rails 4.0.1 应用程序,我让 hstore 在这台机器上运行其他几个项目.
It is a Rails 4.0.1 app with postgresql 9 and I have hstore working on a few other projects running on this machine.
推荐答案
您已经在名为 hstore
的架构中安装了 hstore
扩展,该架构可能不是您的默认 hstore
代码>搜索路径代码>.
You have installed the hstore
extension in a schema named hstore
which is presumably not on your default search_path
.
您必须执行以下操作之一:
You must do one of these:
- 在连接设置期间将
hstore
添加到search_path
; - 使用
ALTER USER ... SET
或ALTER DATABASE ... SET
将hstore
添加到search_path
; - 将 hstore 扩展从
hstore
架构移动到public
;或 - schema-qualify 所有对
hstore
的引用,例如hstore.hstore(...)
.操作员也必须这样做;->
变成OPERATOR(hstore.->)
- Add
hstore
tosearch_path
during connection setup; - Add
hstore
tosearch_path
with anALTER USER ... SET
orALTER DATABASE ... SET
; - Move the hstore extension from the
hstore
schema intopublic
; or - schema-qualify all references to
hstore
, e.g.hstore.hstore(...)
. This must be done for operators too;->
becomesOPERATOR(hstore.->)
这篇关于PG::UndefinedObject: 错误: 输入“hstore"不存在,但确实存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!