#31826 closed Cleanup/optimization (fixed)

AlterField with db_column addition should be a noop.

Reported by: Iuri de Silvio Owned by: Iuri de Silvio
Component: Migrations Version: dev
Severity: Normal Keywords:
Cc: Simon Charette Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Iuri de Silvio)

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.

Change History (12)

comment:1 Changed 17 months ago by Iuri de Silvio

Last edited 17 months ago by Iuri de Silvio (previous) (diff)

comment:2 Changed 17 months ago by Iuri de Silvio

Owner: changed from nobody to Iuri de Silvio
Status: newassigned

comment:3 Changed 17 months ago by Iuri de Silvio

Description: modified (diff)

comment:4 Changed 17 months ago by Iuri de Silvio

Description: modified (diff)

comment:5 Changed 17 months ago by Iuri de Silvio

Version: 3.0master

comment:6 Changed 17 months ago by Mariusz Felisiak

Cc: Simon Charette added
Has patch: set
Summary: AlterField with only db_column changed should be a noopAlterField with db_column addition should be a noop.
Triage Stage: UnreviewedAccepted

Thanks. See related ticket where Simon pointed out that such change (1 & 2) should be a noop.

Last edited 17 months ago by Mariusz Felisiak (previous) (diff)

comment:7 Changed 16 months ago by Mariusz Felisiak

Patch needs improvement: set

comment:8 Changed 16 months ago by Iuri de Silvio

Patch needs improvement: unset

comment:9 Changed 16 months ago by Iuri de Silvio

Patch needs improvement: set

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

comment:10 Changed 16 months ago by Iuri de Silvio

Patch needs improvement: unset

comment:11 Changed 16 months ago by Mariusz Felisiak

Triage Stage: AcceptedReady for checkin

comment:12 Changed 16 months ago by Mariusz Felisiak <felisiak.mariusz@…>

Resolution: fixed
Status: assignedclosed

In 632ccffc:

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.

Note: See TracTickets for help on using tickets.
Back to Top