#24260: Add migration support for logical field renames
----------------------------+--------------------
     Reporter:  pennersr    |      Owner:  nobody
         Type:  Bug         |     Status:  new
    Component:  Migrations  |    Version:  1.7
     Severity:  Normal      |   Keywords:
 Triage Stage:  Unreviewed  |  Has patch:  0
Easy pickings:  0           |      UI/UX:  0
----------------------------+--------------------
 Suppose you have a legacy model, defined like this:

 {{{
     class Foo(models.Model):
         foo_id = models.AutoField(primary_key=True)
 }}}

 Now, I would like to clean this up, into:

 {{{
     class Foo(models.Model):
         id = models.AutoField(primary_key=True, db_column='foo_id')
 }}}

 This is only a logical name change, without any impact on the
 database. Yet, there seems to be no way to convince `makemigrations`
 that nothing needs to happen.

 Whatever I do, it will always complain, or worse, attempt to remove
 the `foo_id` altogether:

 {{{
     operations = [
         migrations.RemoveField(
             model_name='foo',
             name='foo_id',
         ),
         migrations.AddField(
             model_name='foo',
             name='id',
             field=models.AutoField(default=0, serialize=False,
 primary_key=True, db_column=b'foo_id'),
             preserve_default=False,
         ),
     ]
 }}}

 Using South you could work around this by having empty
 forwards/backwards methods.  It would be nice if Django migrations
 offered a way out as well.

--
Ticket URL: <https://code.djangoproject.com/ticket/24260>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" 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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.3f4ea051e2e067fc2338590eb85a5b92%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to