How to setup django-hstore with an existing app managed by south?

后端 未结 3 1830
谎友^
谎友^ 2020-12-28 15:55

I tried to use django-hstore using this nice tutorial. I added two classes to an existing app managed by South:

clas         


        
3条回答
  •  伪装坚强ぢ
    2020-12-28 16:20

    I eventually found that the hstore extension wasn't installed for the specific database I was using:

    $ psql -d mydb
    psql (9.1.4)
    Type "help" for help.
    
    mydb=# SELECT t.oid, typarray FROM pg_type t JOIN pg_namespace ns ON typnamespace = ns.oid WHERE typname = 'hstore';
     oid | typarray 
    -----+----------
    (0 rows)
    
    mydb=# \dx
                     List of installed extensions
      Name   | Version |   Schema   |         Description          
    ---------+---------+------------+------------------------------
     plpgsql | 1.0     | pg_catalog | PL/pgSQL procedural language
    (1 row)
    
    mydb=# create extension hstore;
    WARNING:  => is deprecated as an operator name
    DETAIL:  This name may be disallowed altogether in future versions of PostgreSQL.
    CREATE EXTENSION
    mydb=# \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)
    
    mydb=# SELECT t.oid, typarray FROM pg_type t JOIN pg_namespace ns ON typnamespace = ns.oid WHERE typname = 'hstore';
      oid  | typarray 
    -------+----------
     58800 |    58805
    (1 row)
    

    I thought that a database created after the hstore installation would include the extension. Doesn't seem to be the case, am I misinterpreting how extensions work ? Are they database-specific ?

提交回复
热议问题