2 from forum.models import KeyValue
\r
3 from django.db import connection, transaction
\r
5 KEY = 'PG_FTSTRIGGERS_VERSION'
\r
10 version = KeyValue.objects.get(key=KEY).value
\r
11 if version < VERSION:
\r
19 f = open(os.path.join(os.path.dirname(__file__), 'pg_fts_install.sql'), 'r')
\r
22 cursor = connection.cursor()
\r
23 cursor.execute(f.read())
\r
24 transaction.commit_unless_managed()
\r
27 kv = KeyValue.objects.get(key=KEY)
\r
29 kv = KeyValue(key=KEY)
\r
34 except Exception, e:
\r
35 import sys, traceback
\r
36 traceback.print_exc(file=sys.stdout)
\r