How do I mock a custom field that has been removed to make south migrations run?

I removed the app containing a couple of custom fields from my project. Now when I try to run my migrations I get ImportError

it naturally. These fields were the main settings as shown 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

      

Thus, none of them contain database-level settings.

When I removed this code, I created migrations, so the subsequent migration went fine. But when I try to run them on the database before deleting, I figured out my mistake.

I can recreate the bare-bones application and make this import work, but ideally I would like to know if South has a mechanism to deal with these problems? Or are there any best practices? It would be great if I could solve these problems simply by changing my migrations and not touching the codebase.

(Django 1.3, South 0.7.3)

+3


source to share


2 answers


South has no reference to the deleted field in subsequent migrations. If you deleted a custom field and generated a migration successfully ImportError

, it is likely because all of the custom fields still reference some of the canceled migrations before the delete migration. So



  • update your codebase to version right before the delete and delete migration.
  • migrates
  • update your codebase prior to deletion and migration.
+2


source


Such simple custom fields are very simple since South 0.7+ if defined for them add_introspection_rules

[ 1 ]. (in the same module after the custom field class) when the migration was created. Then the South does not "freeze" these fields, and they can be easily removed. Then if the previous answer from okm doesn't help you, re-create the correct migration.



+1


source







All Articles