How do I mock a custom field that is deleted so that south migrations run?

Posted by muhuk on Stack Overflow See other posts from Stack Overflow or by muhuk
Published on 2012-04-07T05:01:40Z Indexed on 2012/04/07 17:30 UTC
Read the original article Hit count: 313

I have removed an app that contained a couple of custom fields from my project. Now when I try to run my migrations I get ImportError, naturally. These fields were very basic customizations like below:

from django.db.models.fields import IntegerField

class SomeField(IntegerField):
    def get_internal_type(self):
        return "SomeField"

    def db_type(self, connectio=None):
        return 'integer'

    def clean(self, value):
        # some custom cleanup
        pass

So, none of them contain any database level customizations.

When I removed this code, I've created migrations so the subsequent migration all ran fine. But when I try to run them on a pre-deletion database I realized my mistake.

I can re-create a bare-bones app and make these imports work, but Ideally I would like to know if South has a mechanism to resolve these issues? Or is there any best practises? It would be cool if I could solve these issues just by modifying my migrations and not touching the codebase.

(Django 1.3, South 0.7.3)

© Stack Overflow or respective owner

Related posts about django

Related posts about data-migration