Removing a Django migration that depends on custom field from an old module
Asked Answered
W

2

8

I have a Django 1.8 application whose initial migration relies on django-interval-field like this:

import interval.fields

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

I've since migrated this field to use Django's built-in DurationField, and I'm not using this module anymore, but I need to keep it in requirements.txt in order for my migrations to run.

However, this module throws errors when trying to upgrade to Django 1.9. In addition, I can't keep this module around forever. It would be nice to get rid of it.

I've tried squashing the migrations, but the squashed migration still contains the import interval.fields statement, and creates the interval field. All squashing does is concatenate everything into one file.

Can someone tell me how to go forward towards removing this module?

The Django app in question is here.

Whaleback answered 30/1, 2016 at 1:17 Comment(0)
I
6

So, your squashing is not true squashing

  1. Remove this package from requirements.txt
  2. Remove import interval.fields from your models.py
  3. Modify your interval.fields.IntervalField(xxx) to some type available in Django in the related my_app_label/migrations/1234_some_migrations.py
  4. Done
Inurbane answered 30/1, 2016 at 18:32 Comment(0)
I
1

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

As long as you don't have data migration that make use of Interval field during migration process, you should be fine.

Intratelluric answered 30/1, 2016 at 14:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.