PG::UndefinedObject: 错误: 输入“hstore"不存在,但确实存在 [英] PG::UndefinedObject: ERROR: type "hstore" does not exist but it does

查看:44
本文介绍了PG::UndefinedObject: 错误: 输入“hstore"不存在,但确实存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,这可能看起来像:

First of all, this may look like a duplicate of:

postgres hstore 同时存在和不存在

但事实并非如此.虽然我在这种情况下收到相同的错误消息.查看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 ... SETALTER DATABASE ... SEThstore 添加到 search_path;
  • 将 hstore 扩展从 hstore 架构移动到 public;或
  • schema-qualify 所有对 hstore 的引用,例如hstore.hstore(...).操作员也必须这样做;-> 变成 OPERATOR(hstore.->)
  • Add hstore to search_path during connection setup;
  • Add hstore to search_path with an ALTER USER ... SET or ALTER DATABASE ... SET;
  • Move the hstore extension from the hstore schema into public; or
  • schema-qualify all references to hstore, e.g. hstore.hstore(...). This must be done for operators too; -> becomes OPERATOR(hstore.->)

这篇关于PG::UndefinedObject: 错误: 输入“hstore"不存在,但确实存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆