On Sunday, September 9, 2018 at 12:48:52 AM UTC+8, Jason wrote:
>
> https://docs.djangoproject.com/en/1.11/ref/migration-operations/#alterfield
>
> There are AlterField and RenameField operations available with migrations, 
> but you probably have to include them in your custom migrations.  Reason 
> being, how would django know that you're just renaming a field and not 
> deleting it and adding a new field in its place?  In other words, how would 
> django know going from 
>
> text = models.TextField()
> to
> other_name = models.TextField()
>
> is a rename operation instead of remove and add new column?
>

Hi Jason,

Thanks for explaining. It makes sense. I'm also thinking it might be much 
helpful to detect the rename as much as possible and give warning message 
about developer has to modify the migration to rename field properly. 
Alternatively, instead of detecting potential rename by django framework 
itself, it should be also helpful to add an option to makemigrations to do 
a rename migration, e.g.

    ./manage makemigrations --rename-field app

This new option would be useful for the case of creating a dedicated 
migration just to rename a field.

-- 
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/9103e0a3-1e2f-47a3-ba66-fd390cfee643%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to