Removing Django migration, which depends on custom field from old module

I have a Django 1.8 application whose initial migration is based on django-interval-field as follows:

import interval.fields migrations.CreateModel( name='Item', fields=[ ... ('estimated_time', interval.fields.IntervalField(null=True, blank=True)), 

Since then, I moved this field to use the built-in DurationField Django, and I no longer use this module, but I need to save it in the .txt requirements file so that my migrations will work.

However, this module throws errors when trying to switch to Django 1.9. In addition, I cannot support this module forever. It would be nice to get rid of him.

I tried to wrest the migration, but the compressed migration still contains the import interval.fields statement and creates the interval field. All distributions are a combination of all in one file.

Can someone tell me how to move towards removing this module?

The Django app is here .

+5
source share
2 answers

So your distribution is not a true distribution

  • Remove this package from requirements.txt
  • Remove import interval.fields from models.py
  • Change your interval.fields.IntervalField(xxx) to some type available in Django in the corresponding my_app_label/migrations/1234_some_migrations.py
  • Done
+4
source

In all migration files, find all interval.fields.IntervalField declarations (for the model field in question) and replace with IntegerField .

Until you have a data migration using the Interval field during the migration process, you should be fine.

+1
source

Source: https://habr.com/ru/post/1241860/


All Articles