Skip to content

Commit

Permalink
Fixed tests and migrations after ASKBOT#845
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin-BTS committed Jan 28, 2020
1 parent f30a932 commit 0ad74d2
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 65 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.core.management import BaseCommand
from django.db import connection as conn
import os.path
import askbot
from askbot.search.postgresql import setup_full_text_search
Expand All @@ -15,11 +16,17 @@ def add_arguments(self, parser):

def handle(self, **options):
dir_path = askbot.get_install_directory()

script_name = 'thread_and_post_models_03012016.plsql'
version = conn.cursor().connection.server_version
if version > 109999: # if PostgreSQL 11+
script_name = 'thread_and_post_models_03012016_pg11.plsql'

script_path = os.path.join(
dir_path,
'search',
'postgresql',
'thread_and_post_models_03012016.plsql'
script_name
)
setup_full_text_search(script_path)

Expand Down
50 changes: 26 additions & 24 deletions askbot/migrations/0004_auto_20151219_0751.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,32 @@

def init_postgresql_fts(apps, schema_editor):
conn = schema_editor.connection
if hasattr(conn, 'vendor') and conn.vendor == 'postgresql':
cursor = conn.cursor()
cursor.execute('select version()')
version_info = cursor.fetchone()[0].strip().split(' ')[1]
if int(version_info.split('.')[0]) >= 11:
script_name = 'thread_and_post_models_10032013_pg11.plsql'
else:
script_name = 'thread_and_post_models_10032013.plsql'

script_path = os.path.join(
askbot.get_install_directory(),
'search',
'postgresql',
script_name
)
setup_full_text_search(script_path)

script_path = os.path.join(
askbot.get_install_directory(),
'search',
'postgresql',
'user_profile_search_12192015.plsql'
)
setup_full_text_search(script_path)
# if conn does not have an attribute vendor, there is probalby something
# wrong with Django and we should raise an exception, i.e. provoke the
# AttributeError
if not hasattr(conn, 'vendor') or conn.vendor != 'postgresql':
return

script_name = 'thread_and_post_models_10032013.plsql'
version = conn.cursor().connection.server_version
if version > 109999: # if PostgreSQL 11+
script_name = 'thread_and_post_models_10032013_pg11.plsql'

script_path = os.path.join(
askbot.get_install_directory(),
'search',
'postgresql',
script_name
)
setup_full_text_search(script_path)

script_path = os.path.join(
askbot.get_install_directory(),
'search',
'postgresql',
'user_profile_search_12192015.plsql'
)
setup_full_text_search(script_path)


class Migration(migrations.Migration):
Expand Down
50 changes: 26 additions & 24 deletions askbot/migrations/0007_auto_20151220_0653.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,32 @@

def init_postgresql_fts(apps, schema_editor):
conn = schema_editor.connection
if hasattr(conn, 'vendor') and conn.vendor == 'postgresql':
cursor = conn.cursor()
cursor.execute('select version()')
version_info = cursor.fetchone()[0].strip().split(' ')[1]
if int(version_info.split('.')[0]) >= 11:
script_name = 'thread_and_post_models_10032013_pg11.plsql'
else:
script_name = 'thread_and_post_models_10032013.plsql'

script_path = os.path.join(
askbot.get_install_directory(),
'search',
'postgresql',
script_name
)
setup_full_text_search(script_path)

script_path = os.path.join(
askbot.get_install_directory(),
'search',
'postgresql',
'user_profile_search_12202015.plsql'
)
setup_full_text_search(script_path)
# if conn does not have an attribute vendor, there is probalby something
# wrong with Django and we should raise an exception, i.e. provoke the
# AttributeError
if not hasattr(conn, 'vendor') or conn.vendor != 'postgresql':
return

script_name = 'thread_and_post_models_10032013.plsql'
version = conn.cursor().connection.server_version
if version > 109999: # if PostgreSQL 11+
script_name = 'thread_and_post_models_10032013_pg11.plsql'

script_path = os.path.join(
askbot.get_install_directory(),
'search',
'postgresql',
script_name
)
setup_full_text_search(script_path)

script_path = os.path.join(
askbot.get_install_directory(),
'search',
'postgresql',
'user_profile_search_12202015.plsql'
)
setup_full_text_search(script_path)


class Migration(migrations.Migration):
Expand Down
34 changes: 18 additions & 16 deletions askbot/migrations/0009_auto_20160103_1150.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@

def init_postgresql_fts(apps, schema_editor):
conn = schema_editor.connection
if hasattr(conn, 'vendor') and conn.vendor == 'postgresql':
cursor = conn.cursor()
cursor.execute('select version()')
version_info = cursor.fetchone()[0].strip().split(' ')[1]
if int(version_info.split('.')[0]) >= 11:
script_name = 'thread_and_post_models_03012016_pg11.plsql'
else:
script_name = 'thread_and_post_models_03012016.plsql'

script_path = os.path.join(
askbot.get_install_directory(),
'search',
'postgresql',
script_name
)
setup_full_text_search(script_path)
# if conn does not have an attribute vendor, there is probalby something
# wrong with Django and we should raise an exception, i.e. provoke the
# AttributeError
if not hasattr(conn, 'vendor') or conn.vendor != 'postgresql':
return

script_name = 'thread_and_post_models_03012016.plsql'
version = conn.cursor().connection.server_version
if version > 109999: # if PostgreSQL 11+
script_name = 'thread_and_post_models_03012016_pg11.plsql'

script_path = os.path.join(
askbot.get_install_directory(),
'search',
'postgresql',
script_name
)
setup_full_text_search(script_path)

class Migration(migrations.Migration):

Expand Down

0 comments on commit 0ad74d2

Please sign in to comment.