DatabaseError: column askbot_thread.text_search_vector does not exist
Hi Guys,
I recently upgraded from 0.29 to the latest git-master and everything worked fine (love the migrations!)
but some pages (example: questions/scope:all/sort:activity-desc/query:dissapear/page:3/
) generate a 500 server error with the following message:
VariableDoesNotExist: Failed lookup for key [request] in u'[{}]'
but if I look in the askbot.log I actually see this error occuring:
/opt/python-2.7.2/lib/python2.7/site-packages/django/core/handlers/base.py TIME: 2012-02-28 14:42:10,377 MSG: base.py:handle_uncaught_exception:209 Internal Server Error: /questions/scope:all/sort:activity-desc/query:dissapear/page:3/
Traceback (most recent call last):
File "/opt/python-2.7.2/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/srv/www/vhosts/askbot/askbot/views/readers.py", line 80, in questions
if paginator.num_pages < search_state.page:
File "/opt/python-2.7.2/lib/python2.7/site-packages/django/core/paginator.py", line 60, in _get_num_pages
if self.count == 0 and not self.allow_empty_first_page:
File "/opt/python-2.7.2/lib/python2.7/site-packages/django/core/paginator.py", line 48, in _get_count
self._count = self.object_list.count()
File "/opt/python-2.7.2/lib/python2.7/site-packages/django/db/models/query.py", line 334, in count
return self.query.get_count(using=self.db)
File "/opt/python-2.7.2/lib/python2.7/site-packages/django/db/models/sql/query.py", line 401, in get_count
number = obj.get_aggregation(using=using)[None]
File "/opt/python-2.7.2/lib/python2.7/site-packages/django/db/models/sql/query.py", line 367, in get_aggregation
result = query.get_compiler(using).execute_sql(SINGLE)
File "/opt/python-2.7.2/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
cursor.execute(sql, params)
File "/opt/python-2.7.2/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 44, in execute
return self.cursor.execute(query, args)
DatabaseError: column askbot_thread.text_search_vector does not exist
LINE 1: ...estion' AND "askbot_post"."deleted" = false AND askbot_thr...
Is this a bug or did something go wrong with the migrations?
syncdb
output:
> python manage.py syncdb
Syncing...
Creating tables ...
Installing custom SQL ...
Installing indexes ...
No fixtures found.
Synced:
> django.contrib.auth
> django.contrib.contenttypes
> django.contrib.sessions
> django.contrib.sites
> django.contrib.staticfiles
> django.contrib.admin
> django.contrib.sitemaps
> south
> askbot.deps.livesettings
> keyedcache
> robots
> django_countries
> djcelery
> djkombu
> followit
Not synced (use migrations):
- askbot.deps.django_authopenid
- askbot
(use ./manage.py migrate to migrate these)
migrate
output:
> python manage.py migrate
Running migrations for django_authopenid:
- Nothing to migrate.
- Loading initial data for django_authopenid.
No fixtures found.
Running migrations for askbot:
- Nothing to migrate.
- Loading initial data for askbot.
No fixtures found.
(running against a postgres db)
I just ran the askbot/search/postgresql/thread_and_post_models_01162012.plsql
file:
> psql -U askbot -f askbot/search/postgresql/thread_and_post_models_01162012.plsql
Password for user askbot:
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
setup_aggregates
------------------
t
(1 row)
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
psql: askbot/search/postgresql/thread_and_post_models_01162012.plsql:154: ERROR: cannot ...
Comments
In this case looks like the .plsql file is incorrect. Take a look at the repository and compare with yours https://github.com/ASKBOT/askbot-devel/blob/master/askbot/search/postgresql/thread_and_post_models_01162012.plsql#L172 there is no code like the traceback is showing on line 172.
Which version of postgres are you using? Maybe the function
get_dependend_answers_tsv
could not be replaced successfully? You could try dropping those functions beforehand...it's a clean clone from github. I do not know about the line numbers reported but if I open the file and check line 172 is shows the same as in github.
postgres (PostgreSQL) 9.1.1
Ok, maybe it's due to the version of postgres, we use 8.4. Try dropping any functions installed by the .plsql script and then running it again. The first error message is at line 154, so I'd start with that function. Ideally we need a script that runs on as many versions of the database as possible, failing that, we'll add some conditional statements in the python code. The line 172 shows stale code from the function that could not be replaced for some reason.