Add the ability to make RemoveField reversible for non-null fields
|Reported by:||harrislapiroff||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
RemoveField is an irreversible operation if a field's original state requires it be non-null.
- Write a model with a field with null=False
- Make and run initial migrations.
- Create and save some instances of your model.
- Remove the field.
- Make and run the migration.
- Attempt to migrate back to the initial migration (i.e., python manage.py migrate myapp 0001)
You'll get django.db.utils.IntegrityError: myapp_mymodel__new.field may not be NULL
This behavior is documented (https://docs.djangoproject.com/en/dev/ref/migration-operations/#django.db.migrations.operations.RemoveField), but I believe there should be a way to provide a default value for the field when unapplying the migration.
Change History (3)
comment:1 Changed 23 months ago by ihulub
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:2 Changed 23 months ago by timo
- Summary changed from RemoveField irreversible in certain cases to Add the ability to make RemoveField reversible for non-null fields
- Triage Stage changed from Unreviewed to Accepted
- Type changed from Bug to New feature