Let's say in my Django project I have two models A and B.
class A(models.Model):
something...
class B(models.Model):
a = models.ForeignKey(A)
Later on I decided to use uuid as the primary key value. so I update the models:
import uuid
class A(models.Model):
id = models.UUIDField(
db_index=True,
default=uuid.uuid4,
editable=False
)
class B(models.Model):
id = models.UUIDField(
db_index=True,
default=uuid.uuid4,
editable=False
)
a = models.ForeignKey(A)
Now if I make a migration, Django will NOT pick the changes with the foreign key, i.e the type of fk B.a needs to be updated to uuid as well, not integer anymore.
Is this a bug with current version of Django? What is the best practice for handling such case?
Thanks,
Liuyang