Search code examples
pythondjangodjango-south

You cannot add a null=False column without a default value


I'm adding a new app, and while setting up the database using South I get the following:

... line 11, in forwards
db.add_column('experiments_dailyreport', 'test_group_size', 
  orm['experiments.dailyreport:test_group_size'])

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

Given that this is a new table with no data in it, is there some way to force this migration?


Solution

  • You can force a migration using:

    manage.py migrate --fake django-lean 0005
    

    where 0005 is the version number of the migration. All that matters in your situation are:

    • having the correct database schema in the end
    • having South think that all migrations have been run

    After that you can run the other migrations as normal. Alternatively, you can remove South, create the latest tables from django-lean using syncdb and then fake all the django-lean migrations.

    Lastly, if you're certain that there's something wrong with the migration, it's worth contacting the django-lean developer(s) about this.