最近I went into trouble Djangoでhstoreを使用しようとしています。私はhstoreのこの方法でインストール: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)
そして、単純には、私の新しいデータベースがhstoreのを含んであろうと思いました。それはそうではありません:
$ createdb dbtest
$ psql -d dbtest -c '\dx'
List of installed extensions
Name | Version | Schema | Description
---------+---------+------------+------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
(1 row)
新しく作成されたデータベースに自動的にhstoreを持つ方法はありますか?
+1正しいものであり、すべてを有用な形式にするためです。 'template1'以外のデータベースを使うことも考えられます。どのデータベースもテンプレートとして使用できます: 'CREATE DATABASE foo TEMPLATE mytemplate'。あるいは、 'template1'に追加のものがあれば、(デフォルトでは空の)' template0'を使うことができます。 –