Opened 2 months ago

Closed 2 months ago

Last modified 4 hours ago

#35749 closed Bug (duplicate)

AlterIndexTogether raising TypeError: 'class Meta' got invalid attribute(s): index_together

Reported by: Dishen Wang Owned by:
Component: Migrations Version: 5.1
Severity: Normal Keywords: AlterIndexTogether, index_together
Cc: Dishen Wang Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

According to the documentation: "The AlterIndexTogether migration operation is now officially supported only for pre-Django 4.2 migration files. For backward compatibility reasons, it’s still part of the public API, and there’s no plan to deprecate or remove it, but it should not be used for new migrations. Use AddIndex and RemoveIndex operations instead." But when running make migrate it gave error TypeError: 'class Meta' got invalid attribute(s): index_together. Is this an issue or should am I misunderstanding the problem?

Change History (4)

comment:1 by Sarah Boyce, 2 months ago

Resolution: duplicate
Status: newclosed

Duplicate of #34856, #35679

The 4.2 release notes say the following:

Next, consider squashing migrations to remove index_together from historical migrations.

comment:2 by Andrés Reverón Molina, 6 hours ago

It seems like the suggested workaround is to squash migrations, but unfortunately the AlterIndexTogether operation is still included in the squashed migration, so this does not help.

comment:3 by Dishen Wang, 6 hours ago

That is correct Andrés, The work around for me was to modify the old migration/squashed files and replace AlterIndexTogether with a pair of operations RemoveIndex then AddIndex. You can then check for migrations and make sure the there are no changes after the modifications.

comment:4 by Andrés Reverón Molina, 4 hours ago

Thank you! I will do that.

However it seems to me like this a very valid bug report and it should not be marked as closed.

I think AlterIndexTogether should either be completely removed, or fixed so that it does not crash. The current state is quite confusing.

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