Django model migration from standard model to multi-table inherited model with FK relations
I have a task to migrate some existing models to multi-table inherited models (make them subclass of existing parent). I'm testing my code on local machine and I've managed to enforce multi-table inheritance without faults. However some models are ForeignKeys linked to another models and I'm wondering how to manage such relations swap to avoid data lose.
Example:
class Member(models.Model):
pass
class Person_A(models.Model):
member_ptr = OneToOneField(parent_link=True)
class Person_B(models.Model):
member_ptr = OneToOneField(parent_link=True)
class Group(models.Model):
person_a = models.ForeingKey(Person_A)
person_b = models.ForeignKey(Person_B)
So, Person_A and Person_B are on their way to be inherited from Member. All Member instances created and data prepopulated. Remains last step to remove _ptr field replacing models.Model with Member at the same time which causes drop of id field so ForeignKey link will be broken.
Is there an easy way to manage this ForeignKey transfer without data lose? I have some weird ideas of field duplications etc. but hoping there is some more convinient way.