X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/b484fb008ae574dd4ef10a12d4e530ab96743acc..55c9938df878cfcab4f15fb94ee4452e5fd16ba6:/forum_modules/pgfulltext/startup.py diff --git a/forum_modules/pgfulltext/startup.py b/forum_modules/pgfulltext/startup.py index 14eea8e..59990b5 100644 --- a/forum_modules/pgfulltext/startup.py +++ b/forum_modules/pgfulltext/startup.py @@ -1,38 +1,27 @@ -import os -from forum.models import KeyValue -from django.db import connection, transaction - -KEY = 'PG_FTSTRIGGERS_VERSION' -VERSION = 2 -install = False - -try: - version = KeyValue.objects.get(key=KEY).value - if version < VERSION: - install = True -except: - install = True - - -if install: - f = open(os.path.join(os.path.dirname(__file__), 'pg_fts_install.sql'), 'r') - - try: - cursor = connection.cursor() - cursor.execute(f.read()) - transaction.commit_unless_managed() - except: - pass - finally: - cursor.close() - - f.close() - - try: - kv = KeyValue.objects.get(key=KEY) - except: - kv = KeyValue(key=KEY) - - kv.value = VERSION - kv.save() - \ No newline at end of file +import os +from forum.models import KeyValue +from django.db import connection, transaction +import settings + +VERSION = 11 + +if int(settings.PG_FTSTRIGGERS_VERSION) < VERSION: + f = open(os.path.join(os.path.dirname(__file__), 'pg_fts_install.sql'), 'r') + + try: + cursor = connection.cursor() + cursor.execute(f.read()) + transaction.commit_unless_managed() + + settings.PG_FTSTRIGGERS_VERSION.set_value(VERSION) + + except Exception, e: + #import sys, traceback + #traceback.print_exc(file=sys.stdout) + pass + finally: + cursor.close() + + f.close() + +import handlers