diff options
Diffstat (limited to 'pgfulltext/management.py')
-rw-r--r-- | pgfulltext/management.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/pgfulltext/management.py b/pgfulltext/management.py new file mode 100644 index 00000000..04303092 --- /dev/null +++ b/pgfulltext/management.py @@ -0,0 +1,23 @@ +import os + +from django.db import connection, transaction +from django.conf import settings + +import forum.models + +if settings.USE_PG_FTS: + 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(): + f = open(os.path.join(os.path.dirname(__file__), '../sql_scripts/pg_fts_install.sql'), 'r') + cursor = connection.cursor() + cursor.execute(f.read()) + transaction.commit_unless_managed() + f.close() +
\ No newline at end of file |