#34058: Widening AutoField to BigAutoField, fails to widen the sequence.
-------------------------------------+-------------------------------------
     Reporter:  Anders Kaseorg       |                    Owner:  Mariusz
                                     |  Felisiak
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  4.1
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:  fixed
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

 Replying to [comment:7 Anders Kaseorg]:
 > I found a scenario in which this fix doesn’t work: if the field had been
 renamed before the upgrade, the corresponding sequence will not have been
 renamed.
 >
 > To modify my above reproduction recipe, insert a new step between steps
 3 and 4 renaming the field:
 >
 > {{{
 > #!python
 > # my_app/models.py
 > from django.db import models
 > class Widget(models.Model):
 >     renamed_id = models.SmallAutoField(primary_key=True)
 > }}}
 >
 > {{{
 > #!console
 > $ ./manage.py makemigrations
 > Was widget.id renamed to widget.renamed_id (a SmallAutoField)? [y/N] y
 > Migrations for 'my_app':
 >   my_app/migrations/0002_rename_id_widget_renamed_id.py
 >     - Rename field id on widget to renamed_id
 > $ ./manage.py migrate
 > Operations to perform:
 >   Apply all migrations: my_app
 > Running migrations:
 >   Applying my_app.0002_rename_id_widget_renamed_id... OK
 > }}}
 >
 > (and then keep the new name in step 5).

 Good catch! It's partly
 
[https://github.com/django/django/blob/4a30e0db269a364cb480f48524fa48e6abcf9e94/django/db/backends/postgresql/schema.py#L128-L152
 a long-standing issue], however, IMO, we should backport
 [https://github.com/django/django/pull/16138 the fix].

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34058#comment:8>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701838cf09594-562671fd-e1ad-43a1-971c-fbd41e53c856-000000%40eu-central-1.amazonses.com.

Reply via email to