* owner: nobody => Mariusz Felisiak
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/34058#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_docs: 0 => 1
* has_patch: 0 => 1
* needs_tests: 0 => 1
Comment:
[https://github.com/django/django/pull/16134 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/34058#comment:3>
* needs_docs: 1 => 0
* needs_tests: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/34058#comment:4>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"19e6efa50b603af325e7f62058364f278596758f" 19e6efa5]:
{{{
#!CommitTicketReference repository=""
revision="19e6efa50b603af325e7f62058364f278596758f"
Fixed #34058 -- Changed sequence types when altering pre-Django 4.1 auto
fields on PostgreSQL.
Thanks Anders Kaseorg for the report.
Thanks Florian Apolloner for pair programming.
Regression in 2eea361eff58dd98c409c5227064b901f41bd0d6.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34058#comment:5>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"97353bc64baca2affe6be6a0c4e5c3cc1de496ec" 97353bc6]:
{{{
#!CommitTicketReference repository=""
revision="97353bc64baca2affe6be6a0c4e5c3cc1de496ec"
[4.1.x] Fixed #34058 -- Changed sequence types when altering pre-Django
4.1 auto fields on PostgreSQL.
Thanks Anders Kaseorg for the report.
Thanks Florian Apolloner for pair programming.
Regression in 2eea361eff58dd98c409c5227064b901f41bd0d6.
Backport of 19e6efa50b603af325e7f62058364f278596758f from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34058#comment:6>
Comment (by 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).
--
Ticket URL: <https://code.djangoproject.com/ticket/34058#comment:7>
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>
Comment (by GitHub <noreply@…>):
In [changeset:"bc3b8f152452ba0e41f28baa93c0bf8f39cddb09" bc3b8f1]:
{{{
#!CommitTicketReference repository=""
revision="bc3b8f152452ba0e41f28baa93c0bf8f39cddb09"
Refs #34058 -- Fixed changing/deleting sequences when altering pre-Django
4.1 auto fields on PostgreSQL.
Thanks Anders Kaseorg for the report.
Follow up to 19e6efa50b603af325e7f62058364f278596758f.
Regression in 2eea361eff58dd98c409c5227064b901f41bd0d6.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34058#comment:9>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"96c541ecef98e2b93db8eba144be2d8c48e6c2cf" 96c541e]:
{{{
#!CommitTicketReference repository=""
revision="96c541ecef98e2b93db8eba144be2d8c48e6c2cf"
[4.1.x] Refs #34058 -- Fixed changing/deleting sequences when altering
pre-Django 4.1 auto fields on PostgreSQL.
Thanks Anders Kaseorg for the report.
Follow up to 19e6efa50b603af325e7f62058364f278596758f.
Regression in 2eea361eff58dd98c409c5227064b901f41bd0d6.
Backport of bc3b8f152452ba0e41f28baa93c0bf8f39cddb09 from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34058#comment:10>