﻿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
31499	Store ModeState.fields into a dict.	Simon Charette	Simon Charette	"`ModeState` initially stored its `fields` into a `List[Tuple[str, models.Field]]` because [https://github.com/django/django/blob/290eb987644c31aabcfd52d81bd5adcf7a1972aa/django/db/migrations/state.py#L368-L370 it wanted to preserve ordering].

However the auto-detector doesn't consider field re-ordering as a state change and Django doesn't support table column reordering in the first place. The only reason I'm aware of for keeping field ordering is to generate model forms out of them which is unlikely to happen during migrations and if it was the case the only the order in which field are ordered and validated would change if `Meta.fields = '__all__` is used [https://docs.djangoproject.com/en/3.0/topics/forms/modelforms/#selecting-the-fields-to-use which is discouraged].

Given storing fields this way results in awkward and inefficient lookup by name for no apparent benefits and that `dict` now preserves insertion ordering I suggest we switch `ModelState.fields` to `Dict[str, models.Field]`. I suggest we do the same for `ModelState.indexes` and `.constraints` since they suggest from the same awkwardness which was likely cargo culted from `ModelState.fields` design decision."	Cleanup/optimization	closed	Migrations	dev	Normal	fixed			Ready for checkin	1	0	0	0	0	0
