﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33197	Renaming field and providing prior field name to db_column should be an SQL noop	Jacob Walls	Simon Charette	"Renaming a field and setting the prior implicit field name as the `db_column` to avoid db operations creates a migration emitting unnecessary SQL. Similar to #31826, which handled a very similar scenario but where there is no field rename, I would expect a SQL noop. I tested with SQLite and MySQL 5.7.31. 

{{{
class Apple(models.Model):
    core = models.BooleanField()
}}}

{{{
class Apple(models.Model):
    core_renamed = models.BooleanField(db_column='core')
}}}
{{{
Was apple.core renamed to apple.core_renamed (a BooleanField)? [y/N] y
Migrations for 'renamez':
  renamez/migrations/0002_rename_core_apple_core_renamed_and_more.py
    - Rename field core on apple to core_renamed
    - Alter field core_renamed on apple
}}}

`python manage.py sqlmigrate renamez 0002` showing unnecessary SQL:
{{{
BEGIN;
--
-- Rename field core on apple to core_renamed
--
ALTER TABLE ""renamez_apple"" RENAME COLUMN ""core"" TO ""core_renamed"";
--
-- Alter field core_renamed on apple
--
ALTER TABLE ""renamez_apple"" RENAME COLUMN ""core_renamed"" TO ""core"";
COMMIT;
}}}

Without renaming the field, follow the same flow and get an `AlterField` migration without SQL, which is what #31826 intended:

{{{
BEGIN;
--
-- Alter field core on apple
--
COMMIT;
}}}"	Cleanup/optimization	closed	Migrations	dev	Normal	fixed			Ready for checkin	1	0	0	0	0	0
