gonczor
gonczor

Reputation: 4146

Django dependency hell with migrations

We had a 3rd party library which got outdated and I would like to get rid of it. The problem is it is used in one of previous migrations. How could this be dealt with? modifying migrations by hand, deleting this migration and using some django features to solve problems or am I doomed to keep it? This is 0026_something_something migraration:

from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
# import multi_email_field.fields


class Migration(migrations.Migration):

    dependencies = [
        ('invoices', '0025_auto_20161106_0931'),
    ]

    operations = [
        migrations.AlterField(
            model_name='company',
            name='email',
            field=multi_email_field.fields.MultiEmailField(verbose_name='email'),
        ),
        migrations.AlterField(
            model_name='invoice',
            name='bank_transfer',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='invoices', to='invoices.BankTransfer', verbose_name='bank transfer'),
        ),
    ]

The problem library is this multi_email_field. We have a few changes since then.

Upvotes: 0

Views: 384

Answers (1)

ptr
ptr

Reputation: 3384

You can squash your migrations- you lose the "history" for the migrations that are squashed but it will get rid of the migration with the reference to the library you want to remove in a way that doesn't involve manually tampering with migrations that have already been run (which is very risky and liable to cause headaches down the line).

Upvotes: 2

Related Questions