PG::UndefinedObject:错误:类型“hstore”不存在,但确实存在

2023-11-25

首先,这可能看起来像以下内容的重复:

postgres hstore同时存在和不同时存在

但事实并非如此。虽然我在这种情况下收到了相同的错误消息。当检查数据库上是否安装了 hstore 时,我们可以看到它是:

./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 数据库上也是如此。

因此,当我尝试运行迁移来添加 hstore 时,我得到了PG::Error: ERROR: extension "hstore" already exists当我注释掉这个迁移时,在下一个需要 hstore 的迁移中,它说PG::UndefinedObject: ERROR: type "hstore" does not exist这有点悖论。

这是一个带有 postgresql 9 的 Rails 4.0.1 应用程序,我有 hstore 正在处理在这台机器上运行的其他几个项目。


您已经安装了hstore名为的模式中的扩展hstore这可能不是你的默认设置search_path.

您必须执行以下操作之一:

  • Add hstore to search_path在连接设置期间;
  • Add hstore to search_pathALTER USER ... SET or ALTER DATABASE ... SET;
  • 将 hstore 扩展从hstore架构成public; or
  • 架构限定所有引用hstore, e.g. hstore.hstore(...)。运营商也必须这样做;->变成OPERATOR(hstore.->)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

PG::UndefinedObject:错误:类型“hstore”不存在,但确实存在 的相关文章

随机推荐