HI All,
I'm new in south and I'm wondering how I can merge two models into one.
I have a model book which derives from the model media.
So book has a media_id_ptr (which is already a pk).

No I would like to merge all attributes from media into book and get rid of 
media.

I was doing the following:

1.) Added all media attributes in the book model, but with _tmp ending.
2.) Created a schemamigration (also creates a correlation table with ending 
_tmp)
3.) Created a datamigration and copied the attribute value into the 
attribute_tmp for all existing book objects.
4.) modified the book model to get rid of the _tmp ending.
5.) Created a schemamigration and exchanged (delete/add with rename column) 
additionally I would like to rename media_id_ptr into id and use it as 
primary key.

But it always fails when I would like to rename the media_id_ptr into id.
I have different tables (m2m and normal foreign keys) which point to 
media_id_ptr.

Therefore I have 2 question:
1.) I guess it is not that easy to reuse the former foreign key as a 
primary key. Is there a best practice to handle that? DO I have to remove 
the foreign key and add it after renaming for all tables which referenced 
it before?

2.) Best practice to rename the m2m_tmp table DO I have to delete the 
unique keys and re-add them after renaming?

Thanks for any hints how to solve this issue.

Regards
Marcel

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2c2cd22d-0f48-4f86-903c-6a7ccdec792c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to