Ask Your Question

DatabaseError: column askbot_thread.text_search_vector does not exist

asked 2012-02-28 08:02:32 -0500

DavyLandman gravatar image

updated 2012-02-28 09:16:01 -0500

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/ TIME: 2012-02-28 14:42:10,377 MSG: 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/", line 111, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/srv/www/vhosts/askbot/askbot/views/", line 80, in questions
    if paginator.num_pages <
  File "/opt/python-2.7.2/lib/python2.7/site-packages/django/core/", 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/", 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/", 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/", 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/", 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/", 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/", 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 syncdb
Creating tables ...
Installing custom SQL ...
Installing indexes ...
No fixtures found.

 > 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 ./ migrate to migrate these)

migrate output:

> python 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: 
(1 row)

psql: askbot/search/postgresql/thread_and_post_models_01162012.plsql:154: ERROR:  cannot ...
edit retag flag offensive close merge delete


In this case looks like the .plsql file is incorrect. Take a look at the repository and compare with yours there is no code like the traceback is showing on line 172.

Evgeny gravatar imageEvgeny ( 2012-02-28 09:12:46 -0500 )edit

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...

Evgeny gravatar imageEvgeny ( 2012-02-28 09:21:43 -0500 )edit

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.

DavyLandman gravatar imageDavyLandman ( 2012-02-28 09:25:40 -0500 )edit

postgres (PostgreSQL) 9.1.1

DavyLandman gravatar imageDavyLandman ( 2012-02-28 09:27:03 -0500 )edit

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.

Evgeny gravatar imageEvgeny ( 2012-02-28 09:34:05 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2012-02-28 08:23:15 -0500

Evgeny gravatar image

Possibly in your case migration 106 did not succeed, most likely because your postgres does not have procedural language called plpgsql installed.

Please try logging in to the database shell and type


The command may still fail, because it apparently did not work for you, but will give a hint. Looks like migration is not catching some error condition.

Also you can try running this query askbot/search/postgresql/thread_and_post_models_01162012.plsql directly into the database.

The error messages should suggest something. Often it is a permission error.

edit flag offensive delete link more


askbot=&gt; CREATE LANGUAGE plpgsql; ERROR: language "plpgsql" already exists

DavyLandman gravatar imageDavyLandman ( 2012-02-28 08:59:55 -0500 )edit

I've added the output of the .plsql file to the question.

DavyLandman gravatar imageDavyLandman ( 2012-02-28 09:04:14 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-02-28 08:02:32 -0500

Seen: 785 times

Last updated: Feb 28 '12