Question

I'm using South (version 0.6, the one packaged in Ubuntu Lucid Lynx) to manage database migrations in Django, and currently using SQLite as a back end. I came across a situation where I generated a migration to add a column with:

./manage.py startmigration myapp --auto added_new_column

... which generated a migration that looked sensible. However, when I then applied the migration with:

./manage.py migrate myapp

I got an error because the column I was adding was non-NULL, but I hadn't specified a default value:

ValueError: You cannot add a null=False column without a default value.

What is one supposed to do if a migration fails in this way, and you want to go back and regenerate it? (What I did in practice, namely to delete the migration and generate a new one, has created several further problems.) Perhaps I've missed something obvious in the documentation about this...

Was it helpful?

Solution

In this case, migration failed and didn't get written into db, so you can safely remove old one and create again. Also you can try using newer south version, i believe they added default check for NOT NULL fields on creating step.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top