So I have a model in my Django project (for arguments sake called 'app'), for example;
class ModelA(models.Model):
fieldA = models.IntegerField(default=0)
and I can run python manage.py makemigrations app; which gives me
Migrations for 'app':
app/migrations/0001_initial.py
- Create model ModelA
If I then add a new field to ModelA so it looks like;
class ModelA(models.Model):
fieldA = models.IntegerField(default=0),
fieldB = models.IntegerField(default=1)
and then run makemigrations again, I get;
Migrations for 'app':
app/migrations/0002_auto_20170529_1737.py
- Remove field fieldA from modela
- Add field fieldB to modela
The auto-generated file backs this up;
operations = [
migrations.RemoveField(
model_name='modela',
name='fieldA',
),
migrations.AddField(
model_name='modela',
name='fieldB',
field=models.IntegerField(default=1),
),
]
Why does it remove fieldA?
My understanding was that it should only script changes to the models, i.e. That fieldB has been added.