I have a django app with four models in it. I realize now that one of these models should be in a separate app. I do have south installed for migrations, but I don’t think this is something it can handle automatically. How can I migrate one of the models out of the old app into a new one?
Also, keep in mind that I’m going to need this to be a repeatable process, so that I can migrate the production system and such.
How to migrate using south.
Lets say we got two apps: common and specific:
Now we want to move model common.models.cat to specific app (precisely to specific.models.cat).
First make the changes in the source code and then run:
Now we need to edit both migration files:
Now both apps migrations are aware of the change and life sucks just a little less 🙂
Setting this relationship between migrations is key of success.
Now if you do:
will do both migration, and
will migrate things down.
Notice that for upgrading of schema I used common app and for downgrading, I used specific app. That’s because how the dependency here works.