I have several classes, e.g. Band, Album, Song. Each has the fields title (which is sometimes called name instead) and slug, as well as other, class-specific fields.
I’d like to use South in order to convert them into children of a common base class, Article, which would contain every object’s title and slug. However, I’m not sure how South’s data migrations are supposed to work in my case; can you help?
You just need to think about the changes South will make to your models, and plan for that.
If
Articleis an abstract class, South will for the most part disregard it. That is to say all the fields will look as if they are fields directly on the model, pretty much the way you have it now. So, the only changes that will occur are where one model was usingnamebefore, it will now have a newtitlefield as well. For this reason, you should leave thenamefield attached through the schemamigration, then create a datamigration to move its value to the newtitlefield, and finally remove it in another schemamigration.If
Articleis a standard base class (multiple-table inheritance), then all your models will get a newOneToOneFieldto Article. Again, leave all the fields in tact on your models though the schemamigration, then create a datamigration where you will run through each and create anArticleinstance using the old data on the model and assign thatArticleinstance to the one-to-one field. Then, you can remove the old fields in another schemamigration.