Search code examples
pythondatabasedjangomigrationdjango-south

How do you create a new migration file using south without having to change the schema?


So what I need to do is change the value of a field across the entire database. I don't need to actually change anything related to the schema. Something like this.

def forwards(self, orm):
    the_things = Thing.objects.filter(widget="some value"):
    for thing in the_things:
      thing.widget = "some new value"
      thing.save()

def backwords(self, orm):
    the_things = Thing.objects.filter(widget="some new value"):
    for thing in the_things:
      thing.widget = "some value"
      thing.save()

I am new to using south so I am not sure the best way to do something like this. Is it bad practice to just manually make a migration file? It seems like it would be since running ./manage.py schemamigration app --auto seems to follow a naming convention in the file names it generates.


Solution

  • You need a data migration

    ./manage.py datamigration <your project> <descriptive_name>
    

    will create you a blank migration which you will then need to edit. Then migrate as normal.