首先,这可能看起来像以下内容的重复:
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_path
与ALTER USER ... SET
or ALTER DATABASE ... SET
;
- 将 hstore 扩展从
hstore
架构成public
; or
- 架构限定所有引用
hstore
, e.g. hstore.hstore(...)
。运营商也必须这样做;->
变成OPERATOR(hstore.->)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)