First time here? Check out the FAQ!

Database IntegrityError in admin

Got a fresh install of askbot pulled from pip.

I have got some trouble using the admin so I activated the debug mode in

Whenever I try to delete a user, I have this error :

DatabaseError at /admin/auth/user/
relation "group_messaging_lastvisittime" does not exist
LINE 1: ..., "auth_user"."consecutive_days_visit_count" FROM "group_mes...

when I try to just update a User's record, I got this error after pressing Save button :

IntegrityError at /admin/auth/user/3/
update or delete on table "auth_user_groups" violates foreign key constraint "authusergroups_ptr_id_refs_id_5cdfc23b7859c44e" on table "askbot_groupmembership"
DETAIL:  Key (id)=(5) is still referenced from table "askbot_groupmembership".

It's a fresh install but at installation time, when I issued the command

python migrate askbot

I has a problem with postgres pip driver and server mismatch. So I had to fix the problem and re-run :

python migrate askbot

Would it be the cause of this messy database state ?

How can I resolve it ? (I'm not used to django)

Fabien Meghazi's avatar
Fabien Meghazi
asked 2013-01-17 10:06:58 -0500
edit flag offensive 0 remove flag close merge delete


add a comment see more comments

1 Answer


"relation does not exist" error suggests that you have missing tables/columns.

Try running python migrate --list and see which database migrations were not applied, then run the real migration with the same command, but without the --list argument.

Evgeny's avatar
answered 2013-01-18 14:52:33 -0500
edit flag offensive 0 remove flag delete link


I ran migrate [...] with the following listed commands : group_messaging, longerusername, robots. Those were the missing migrations according to migrate --list. According to the message I guess only group_messaging was relevant. Anyway, I restarted the server and I still have the exact same errors. Running python migrate --all --fake reports nothing to migrate for all targets. Any idea ?

Fabien Meghazi's avatar Fabien Meghazi (2013-01-21 04:27:55 -0500) edit

Sorry about my previous message, it is incomplete. Running the group_messaging migration command actually solved the first error (relation does not exists). Thanks ! I still experience the second problem when updating a user (Key (id)=(xxx) is still referenced from table "askbot_groupmembership").

Fabien Meghazi's avatar Fabien Meghazi (2013-01-21 04:27:57 -0500) edit
add a comment see more comments