[Django] #31826: AlterField with only db_column changed should be a noop

14 views
Skip to first unread message

Django

unread,
Jul 25, 2020, 9:50:04 AM7/25/20
to django-...@googlegroups.com
#31826: AlterField with only db_column changed should be a noop
------------------------------------------------+------------------------
Reporter: Iuri de Silvio | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Migrations | Version: 3.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
When I change: `pink = models.Integer(default=0)` to `pink =
models.Integer(default=0, db_column="pink")` the migration can recreate
constraints if it is an FK or even reconstruct the table (SQLite).

The (same) constraint drop/create is a blocking operation for PostgreSQL,
so it is an undesirable and unexpected behavior.

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

Django

unread,
Jul 25, 2020, 9:53:17 AM7/25/20
to django-...@googlegroups.com
#31826: AlterField with only db_column changed should be a noop
-------------------------------------+-------------------------------------

Reporter: Iuri de Silvio | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Migrations | Version: 3.0
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Iuri de Silvio):

I sent a pull request here. https://github.com/django/django/pull/13237

--
Ticket URL: <https://code.djangoproject.com/ticket/31826#comment:1>

Django

unread,
Jul 25, 2020, 9:54:08 AM7/25/20
to django-...@googlegroups.com
#31826: AlterField with only db_column changed should be a noop
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: Iuri de
Type: | Silvio
Cleanup/optimization | Status: assigned
Component: Migrations | Version: 3.0
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Iuri de Silvio):

* owner: nobody => Iuri de Silvio
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/31826#comment:2>

Django

unread,
Jul 25, 2020, 9:54:48 AM7/25/20
to django-...@googlegroups.com
#31826: AlterField with only db_column changed should be a noop
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: Iuri de
Type: | Silvio
Cleanup/optimization | Status: assigned
Component: Migrations | Version: 3.0
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Iuri de Silvio:

Old description:

> When I change: `pink = models.Integer(default=0)` to `pink =
> models.Integer(default=0, db_column="pink")` the migration can recreate
> constraints if it is an FK or even reconstruct the table (SQLite).
>
> The (same) constraint drop/create is a blocking operation for PostgreSQL,
> so it is an undesirable and unexpected behavior.

New description:

When I change: `pink = models.Integer(default=0)` to `pink =

models.Integer(default=0, db_column="pink")` the migration recreate
constraints if it is an FK or even reconstruct the table (SQLite), but
nothing really changed.

The (same) constraint drop/create is a blocking operation for PostgreSQL,
so it is an undesirable and unexpected behavior.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/31826#comment:3>

Django

unread,
Jul 25, 2020, 10:16:12 AM7/25/20
to django-...@googlegroups.com
#31826: AlterField with only db_column changed should be a noop
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: Iuri de
Type: | Silvio
Cleanup/optimization | Status: assigned
Component: Migrations | Version: 3.0
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Iuri de Silvio:

Old description:

> When I change: `pink = models.Integer(default=0)` to `pink =


> models.Integer(default=0, db_column="pink")` the migration recreate
> constraints if it is an FK or even reconstruct the table (SQLite), but
> nothing really changed.
>

> The (same) constraint drop/create is a blocking operation for PostgreSQL,
> so it is an undesirable and unexpected behavior.

New description:

When I change `pink = models.Integer(default=0)` to `pink =

models.Integer(default=0, db_column="pink")` the migration drop/create the
same constraints when it is an FK or even reconstruct the table (SQLite),
but nothing really changed. The constraint drop/create is a blocking


operation for PostgreSQL, so it is an undesirable and unexpected behavior.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/31826#comment:4>

Django

unread,
Jul 25, 2020, 2:12:55 PM7/25/20
to django-...@googlegroups.com
#31826: AlterField with only db_column changed should be a noop
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: Iuri de
Type: | Silvio
Cleanup/optimization | Status: assigned
Component: Migrations | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Iuri de Silvio):

* version: 3.0 => master


--
Ticket URL: <https://code.djangoproject.com/ticket/31826#comment:5>

Django

unread,
Jul 27, 2020, 1:45:25 AM7/27/20
to django-...@googlegroups.com
#31826: AlterField with db_column addition should be a noop.

-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: Iuri de
Type: | Silvio
Cleanup/optimization | Status: assigned
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* cc: Simon Charette (added)
* has_patch: 0 => 1
* stage: Unreviewed => Accepted


Comment:

Thanks. See related ticket when
[https://code.djangoproject.com/ticket/29245#comment:1 Simon pointed out]
that such change should be a noop.

--
Ticket URL: <https://code.djangoproject.com/ticket/31826#comment:6>

Django

unread,
Jul 29, 2020, 7:11:24 AM7/29/20
to django-...@googlegroups.com
#31826: AlterField with db_column addition should be a noop.
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: Iuri de
Type: | Silvio
Cleanup/optimization | Status: assigned
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/31826#comment:7>

Django

unread,
Aug 8, 2020, 7:37:50 PM8/8/20
to django-...@googlegroups.com
#31826: AlterField with db_column addition should be a noop.
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: Iuri de
Type: | Silvio
Cleanup/optimization | Status: assigned
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Iuri de Silvio):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/31826#comment:8>

Django

unread,
Aug 13, 2020, 5:41:13 AM8/13/20
to django-...@googlegroups.com
#31826: AlterField with db_column addition should be a noop.
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: Iuri de
Type: | Silvio
Cleanup/optimization | Status: assigned
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Iuri de Silvio):

* needs_better_patch: 0 => 1


Comment:

Patch needs improvement because it depends on #31825 merge and then I'll
fix conflicts.

--
Ticket URL: <https://code.djangoproject.com/ticket/31826#comment:9>

Django

unread,
Aug 14, 2020, 5:12:43 AM8/14/20
to django-...@googlegroups.com
#31826: AlterField with db_column addition should be a noop.
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: Iuri de
Type: | Silvio
Cleanup/optimization | Status: assigned
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Iuri de Silvio):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/31826#comment:10>

Django

unread,
Aug 14, 2020, 7:14:48 AM8/14/20
to django-...@googlegroups.com
#31826: AlterField with db_column addition should be a noop.
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: Iuri de
Type: | Silvio
Cleanup/optimization | Status: assigned
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/31826#comment:11>

Django

unread,
Aug 14, 2020, 9:04:54 AM8/14/20
to django-...@googlegroups.com
#31826: AlterField with db_column addition should be a noop.
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: Iuri de
Type: | Silvio
Cleanup/optimization | Status: closed
Component: Migrations | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"632ccffc49658de5348c51a8918719364be54f37" 632ccffc]:
{{{
#!CommitTicketReference repository=""
revision="632ccffc49658de5348c51a8918719364be54f37"
Fixed #31826 -- Made AlterField operation a noop when adding db_column.

AlterField operation with adding a db_column is a noop if the column
name is not changed.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31826#comment:12>

Reply all
Reply to author
Forward
0 new messages