Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Django warnings about index_together with new migration #862

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions taggit/migrations/0006_taggit_index_together_deprecation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.3 on 2023-07-06 09:04

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("taggit", "0005_auto_20220424_2025"),
]

operations = [
migrations.RenameIndex(
model_name="taggeditem",
new_name="taggit_tagg_content_8fc721_idx",
old_fields=("content_type", "object_id"),
),
Comment on lines +12 to +16

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using migrations.SeparateDatabaseAndState might do the trick to do this with zero downtime as explained in this article: https://adamj.eu/tech/2020/07/27/how-to-modernize-your-django-index-definitions/

]
2 changes: 1 addition & 1 deletion taggit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,5 @@ class Meta:
verbose_name = _("tagged item")
verbose_name_plural = _("tagged items")
app_label = "taggit"
index_together = [["content_type", "object_id"]]
indexes = [models.Index(fields=["content_type", "object_id"])]
unique_together = [["content_type", "object_id", "tag"]]