Friday, November 30, 2012

Drop foreign key, add another - keep data

Hello,

I'd like to drop a ForeignKey-field and add another using south (mysql database), but it won't work. Googling it takes me not far, but it seems to be a problem with dropping foreign key constraints with InnoDB.
What is the recommended way ot dropping a ForeignKey-field, and adding another?

Say the model looks like this:

class Model1(models.Model):
    test = models.ForeignKey(Model2) 

And I won't to change it to:

class Model1(models.Model):
    test2 = models.ForeignKey(Model3) 
 
Right now I don't really care if I lose data, but for future reference I'd prefer a method that keeps it.

Thank you.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/1XoEfk3TBlQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment