On Wed, Mar 27, 2013 at 11:49 PM, Tim Cook <[email protected]> wrote:
> I can't find a similar scenario in the list archives, so .....
>
> I had run the initial migration, etc and all seemed fine.
>
> I modified one model from this:
> class CCD(models.Model):
>     rm_version = models.ForeignKey(RMversion, 
> related_name='%(class)s_related+')
>     ...
>
> to this:
> class CCD(models.Model):
>     prj_name = models.ForeignKey(Project, verbose_name="Project Name")
>     ...
>
> The new ForeignKey in CCD, points to this, which already has the
> RMversion relation.
>
> class Project(models.Model):
>     prj_name = models.CharField("project name", max_length=110, unique=True)
>     rm_version = models.ForeignKey(RMversion, 
> related_name='%(class)s_related+')
>     owner_group = models.CharField(max_length=110) #must be a member
> of this group to edit this project
>
> During the migration, here are the prompts and my responses:
>

This should be many migrations, not one migration.

1) Schema migration: Add nullable foreign key to Project to CCD.
2) Data migration: Create Project objects as needed from 'RMversion' links
3) Data migration: Update CCD objects to point at projects
4) Schema migration: Drop RMversion foreign key from CCD
5) Schema migration: Make CCD->Project foreign key not null

Splitting it into multiple migration steps stops this from blowing up
in your face and preserves your data.

Cheers

Tom

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to