]> git.openstreetmap.org Git - osqa.git/blobdiff - forum_modules/pgfulltext/management.py
install new pg fts triggers after migrations
[osqa.git] / forum_modules / pgfulltext / management.py
index 487580ff6ef66d438aea3be9a0d90b9130c6d8a9..60baecd80f78dcc7ba958a42dbae633552b88d35 100644 (file)
@@ -5,18 +5,9 @@ from django.conf import settings
 
 import forum.models
 
-if settings.DATABASE_ENGINE in ('postgresql_psycopg2', 'postgresql', ):
-    from django.db.models.signals import post_syncdb
-
-    def setup_pgfulltext(sender, **kwargs):
-        if sender == forum.models:
-           install_pg_fts()
-
-    post_syncdb.connect(setup_pgfulltext)
-
-def install_pg_fts():
+def install_pg_fts(**kwargs):
     f = open(os.path.join(os.path.dirname(__file__), 'pg_fts_install.sql'), 'r')
-    
+
     try:
         cursor = connection.cursor()
         cursor.execute(f.read())
@@ -27,3 +18,14 @@ def install_pg_fts():
         cursor.close()
 
     f.close()
+
+if settings.DATABASE_ENGINE in ('postgresql_psycopg2', 'postgresql', ):
+    from django.db.models.signals import post_syncdb
+    post_syncdb.connect(install_pg_fts, sender=forum.models, weak=False)
+
+
+try:
+    from south.signals import post_migrate
+    post_migrate.connect(install_pg_fts, weak=False)
+except:
+    pass
\ No newline at end of file