summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2010-10-25 15:00:44 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2010-10-25 15:00:44 -0400
commit0aade4817a07392b874005180d815266cf6521ba (patch)
tree3857cf8b4f20766d6829556d4def4f2eb228dbb2
parent0b6edcbd782e63423984c1549319b98e4adad9a1 (diff)
downloadaskbot-0aade4817a07392b874005180d815266cf6521ba.tar.gz
askbot-0aade4817a07392b874005180d815266cf6521ba.tar.bz2
askbot-0aade4817a07392b874005180d815266cf6521ba.zip
included creation of procedural language plpgsql if it is needed to simplify postgres db creation
-rw-r--r--askbot/management/commands/init_postgresql_full_text_search.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/askbot/management/commands/init_postgresql_full_text_search.py b/askbot/management/commands/init_postgresql_full_text_search.py
index 15d3a936..f30ed2e6 100644
--- a/askbot/management/commands/init_postgresql_full_text_search.py
+++ b/askbot/management/commands/init_postgresql_full_text_search.py
@@ -8,10 +8,16 @@ class Command(NoArgsCommand):
dir = os.path.dirname(__file__)
sql_file_name = 'setup_postgresql_full_text_search.plsql'
sql_file_name = os.path.join(dir, sql_file_name)
- query = open(sql_file_name).read()
+ fts_init_query = open(sql_file_name).read()
cursor = connection.cursor()
try:
- cursor.execute(query)
+ #test if language exists
+ cursor.execute("SELECT * FROM pg_language WHERE lanname='plpgsql'")
+ lang_exists = cursor.fetchone()
+ if not lang_exists:
+ cursor.execute("CREATE LANGUAGE plpgsql")
+ #run the main query
+ cursor.execute(fts_init_query)
finally:
cursor.close()