#29245: ForeignKeyField Renaming leads Remove and AddField instead of 
RenameField
Migration
-------------------------------------+-------------------------------------
     Reporter:  Taqi Abbas           |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Migrations           |                  Version:  master
     Severity:  Normal               |               Resolution:
     Keywords:  ForeignKey,          |             Triage Stage:  Accepted
  RenameField, db_column             |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

 * version:  2.0 => master
 * type:  Bug => Cleanup/optimization
 * stage:  Unreviewed => Accepted


Comment:

 The issue here is that the auto-detector won't be able to detect field
 renames if any other options has been changed in the mean time.

 Could you confirm that the following works:

 1. Only perform the `db_column='question_id'` change.
 2. Run `makemigrations` and assert that a migration with an `AlterField`
 operation was generated to include the `db_column='question_id'` change.
 3. Change the attribute name from `question` to `_question`.
 4. Run `makemigrations` and confirm the field rename. Assert that a
 migration with a `RenameField` operation was created.

 At this point both migrations should be SQL noops.

 I'm accepting on the basis that the auto-detector rename logic could be
 enhanced to better handle `db_column` changes by comparing implicit
 `db_column` values to implicit ones and prompt for a rename.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29245#comment:1>
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/065.24750b3ff74d3824dd79d81793e1380b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to