﻿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
34856	Running tests with historical migrations that contain index together fails with TypeError.	Sage Abdullah	Andrés Reverón Molina	"When running tests against Django's `main` branch on a project that has a historical migration that contains `index_together` (either via the `AlterIndexTogether` operation or as part of a `CreateModel` operation), running that migration fails with `TypeError: 'class Meta' got invalid attribute(s): index_together`. This is the case even if the model has already been updated to use `indexes` instead of `index_together` and new migrations have been created to update it.

To reproduce:
- Install Django < 5.1
- Start a new project and a new app
- Create a model with `index_together` and run `makemigrations`
  - or run `makemigrations` before adding `index_together` and run it again so `AlterIndexTogether` operation is created, same result
- Write a test that uses the database (a simple test with `TestCase` and not `SimpleTestCase` should suffice)
- Optional: Update the model to use `indexes` instead of `index_together` and run `makemigrations`
- Install latest Django `main`
- Run `python manage.py test -v3` and it fails when applying the migration that contains `index_together`

Reproducible example: https://github.com/laymonage/django-test-repro

This is likely because `""index_together""` has been removed from `django.db.models.options.DEFAULT_NAMES` in 2abf417c815c20f41c0868d6f66520b32347106e. Meanwhile, the historical model constructed by the migrations framework will try to build the model with the `Meta.index_together` option.

I'm not sure if this is expected. If it is, then that means developers have to update their old migrations to not use `index_together` at all, which doesn't seem to be ideal.

If it is not, the solution might be to reintroduce `""index_together""` in `DEFAULT_NAMES` even though it will be no-op. Not sure if that's all there is to it, but I'm happy to make a PR for a start."	Bug	closed	Migrations	dev	Release blocker	fixed			Ready for checkin	1	0	0	0	0	0
