0

So I've recently made the jump from South to native Django migrations. All went smoothly with migrating my migrations, however some recent changes have not worked.

I had a model thus:

class MyModel(models.Model):
  f1 = models.IntegerField()

Which I changed to this:

class MyModel(models.Model):
  f1 = models.IntegerField(null=True,default=None,blank=True)

This change is not being picked up by ./manage.py makemigrations, but there is a NOT NULL on the field that means I can't create instances of MyModel with f1 left blank - I get:

IntegrityError: (1048, "Column 'f1' cannot be null")

What can I do? I'm using a MySQL backend.

fredley
  • 32,953
  • 42
  • 145
  • 236
  • Did you just forget to run `./manage.py migrate`? If that's not it, then is there other evidence than the `IntegrityError` that `makemigrations` did not see the change? (e.g Did you go into the generated migration and see that it is not picked up? Some other evidence?) – Louis Oct 24 '14 at 16:38
  • I've done both `migrate` (which runs fine) and `makemigrations`, which says there's nothing to do. – fredley Oct 24 '14 at 16:41
  • I've ran out of hypotheses. My next step in your situation would be to go over the existing migration files and what the migration system has recorded in the database, in reverse chronological order, and see if I can get a clue as to what the migration system saw at various stages. – Louis Oct 24 '14 at 16:47
  • @Louis This is my first migration post switch to native, so all I have is the initial migration (with the `NOT NULL` directive). – fredley Oct 24 '14 at 16:48

0 Answers0