File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 33from typing import TYPE_CHECKING
44
55from django .conf import settings
6+ from django .contrib .postgres .signals import (
7+ get_hstore_oids ,
8+ register_type_handlers ,
9+ )
610from django .db import ProgrammingError
711
812from . import base_impl
@@ -94,3 +98,22 @@ def prepare_database(self):
9498 "or add the extension manually." ,
9599 exc_info = True ,
96100 )
101+ return
102+
103+ # Clear old (non-existent), stale oids.
104+ get_hstore_oids .cache_clear ()
105+
106+ # Verify that we (and Django) can find the OIDs
107+ # for hstore.
108+ oids , _ = get_hstore_oids ()
109+ if not oids :
110+ logger .warning (
111+ '"hstore" extension was created, but we cannot find the oids'
112+ "in the database. Something went wrong." ,
113+ )
114+ return
115+
116+ # We must trigger Django into registering the type handlers now
117+ # so that any subsequent code can properly use the newly
118+ # registered types.
119+ register_type_handlers (self )
You can’t perform that action at this time.
0 commit comments