Revert migration on deleted not null field

Viewed 2259

I've got a model with a non-null field which I deleted:

class Spam(models.Model):
    slug = models.SlugField(allow_unicode=True)  # deleted

After I made the migrations and applied them, I wanted to revert them. But obviously, this results in

django.db.utils.IntegrityError: NOT NULL constraint failed: eggs_spam.slug

How can I revert the migration?

2 Answers

There is an easier way:

  1. Find migration where you have initially add slug field
  2. Add default value to slug field
  3. Unapply last migration
  4. Remove default value from initial slug field migration
Related