相关疑难解决方法(0)

如何创建已安装hstore扩展的新数据库?

最近我在尝试使用Djang与Django时遇到了麻烦.我用这种方式安装了hstore:

$ sudo -u postgres psql
postgres=# CREATE EXTENSION hstore;
WARNING:  => is deprecated as an operator name
DETAIL:  This name may be disallowed altogether in future versions of PostgreSQL.
CREATE EXTENSION
postgres=# \dx
                           List of installed extensions
  Name   | Version |   Schema   |                   Description                    
---------+---------+------------+--------------------------------------------------
 hstore  | 1.0     | public     | data type for storing sets of (key, value) pairs
 plpgsql | 1.0     | pg_catalog | PL/pgSQL procedural language
(2 rows)
Run Code Online (Sandbox Code Playgroud)

并天真地认为我的新数据库将包括hstore.情况并非如此:

$ createdb dbtest …
Run Code Online (Sandbox Code Playgroud)

sql postgresql postgresql-9.1 hstore

54
推荐指数
1
解决办法
3万
查看次数

PG :: UndefinedObject:错误:类型"hstore"不存在但它确实存在

首先,这可能看起来像是重复:

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
Run Code Online (Sandbox Code Playgroud)

它也在template_1 DB上.

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

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

postgresql ruby-on-rails hstore

5
推荐指数
2
解决办法
7034
查看次数

标签 统计

hstore ×2

postgresql ×2

postgresql-9.1 ×1

ruby-on-rails ×1

sql ×1