Ask Your Question

Database IntegrityError in admin

asked 2013-01-17 10:06:58 -0600

Fabien Meghazi's avatar

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)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-01-18 14:52:33 -0600

Evgeny's avatar

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

edit flag offensive delete link more


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 -0600 )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 -0600 )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

1 follower


Asked: 2013-01-17 10:06:58 -0600

Seen: 995 times

Last updated: Jan 18 '13