Say I decided to switch from a third party app foo-tags to app bar-tags. 
Their Tag models are mostly identical so I just need to move the data from 
foo-tag to bar-tag. Since I don't control their migrations, I'd need to 
create a migration in one of my own apps:

./manage.py makemigrations my_app --empty

In this migration I'd need to explicitly list the dependencies on these 
external apps (otherwise was getting errors that the foo and bar apps were 
not available in the app registry):

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations

def migrate_tags(apps, schema_editor):
    FooTag = apps.get_model('foo_tag', 'FooTag')
    BarTag = apps.get_model('bar_tag', 'BarTag')
    for old_tag in FooTag.objects.all():
        new_tag = BarTag.objects.create(name=old_tag.name)

class Migration(migrations.Migration):
    dependencies = [
        ('my_app', '0001_initial'),
        ('foo_tag', '0001_initial'),
        ('bar_tag', '0001_initial'),
    ]

    operations = [
        migrations.RunPython(migrate_tags)
    ]


The migration itself works as expected. However if I now remove foo_tag 
from INSTALLED_APPS, Django will now give an error:

KeyError: "Migration my_app.0002_auto_20141212_1951 dependencies reference 
nonexistent parent node ('foo_tag', '0001_initial')"

What's the correct way to handle migrating data between 3rd party apps 
where one of the apps is eventually removed?

Thanks,
John-Scott

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d60b5693-408f-4ce4-8219-70d1e6c48f51%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to