First time here? Check out the FAQ!
1

ValueError: The database backend does not accept 0 as a value for AutoField.

I am seeing this error when I run "python manage.py migrate askbot" My database is MySQL and its version is "Server version: 5.5.34-0ubuntu0.12.04.1"

I set up mysql using :

  1. sudo apt-get install build-essential
  2. python-dev libmysqlclient-dev sudo
  3. pip install mysql-python
  4. sudo apt-get install python-mysqldb
  5. sudo apt-get install mysql-server

I tried:

  1. python manage.py migrate askbot 0054 #migrate normally up to the 54th migration
  2. python manage.py migrate askbot 0055 --fake #skip this migration
  3. python manage.py migrate askbot #finish migrating askbot
  4. python manage.py migrate #finish migrating anything else (if necessary)

But I got error at #89, #92 and #98

Nikhil's avatar
79
Nikhil
asked 2013-11-21 07:50:57 -0500, updated 2013-11-21 08:30:10 -0500
edit flag offensive 0 remove flag close merge delete

Comments

I've made some changes in the migrations and was able to install with mysql without errors. However, I have not seen errors that you did.

Evgeny's avatar Evgeny (2013-11-25 14:28:59 -0500) edit

I'm experiencing the same problem. It seems there's a problem in the migration files. The following StackOverflow post suggest to remove the default value for foreign keys: http://stackoverflow.com/questions/15169001/south-raises-valueerror-when-trying-to-migrate If you want to keep the default value it seems you can still use None instead of 0 or False: http://rpki.net/ticket/607 It would be great if you could fix this. Thanks a lot!

Michel Krämer's avatar Michel Krämer (2013-11-28 10:25:17 -0500) edit

I just tested this and it works indeed. I had to edit the following migrations: 0055,0080,0093,0099 (two lines)

Michel Krämer's avatar Michel Krämer (2013-11-28 10:44:17 -0500) edit

I have raised a pull request that fixes this issue but it hasn't been merged yet: https://github.com/ASKBOT/askbot-devel/pull/207%3C/p (https://github.com/ASKBOT/askbot-devel/pull/207</p<>>)

Francis Devereux's avatar Francis Devereux (2014-04-23 06:34:00 -0500) edit
add a comment see more comments

1 Answer

1

I had the same problem. Four migration scripts set 0 as a default value for ForeignKey, which seems not accepted. Instead, you can set None as the default value. The following changes in the migrations script should fix this problem:

  • go to the askbot/migrations directory
  • type:

    sed -i.old 's|\(ForeignKey.*\)default=0|\1default=None|g' 0055_*.py 0080_*.py 0093_*.py 0099_*.py

tmonteil's avatar
63
tmonteil
answered 2014-03-31 09:06:28 -0500
edit flag offensive 0 remove flag delete link

Comments

1

This worked for me

alexsf's avatar alexsf (2014-07-28 13:18:05 -0500) edit
add a comment see more comments