Thursday, December 5, 2024

Meta indexes and makemigrations

Hello,

We want to have a partial index (db backend is Postgres) on a datetimefield, so we added this code to the Meta class:

class Episode(models.Model):
    channel_type = models.CharField(max_length=16, choices=CHANNEL_TYPES)
    last_seen_date = models.DateTimeField(auto_now_add=True)
    class Meta:
        indexes = [
            models.Index(
                name="ch_last_seen_date",
                fields=["last_seen_date"],
                condition=models.Q(channel_type="42"),
            ),
        ]

The problem is that makemigrations doesn't seem to recognize it.
What could be the problem? We're on Django 3.2, which I know is old but as per the documentation this should be fine..

Thanks

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/django-users/ee6aa542-aac2-4c78-821b-54d597c80b7cn%40googlegroups.com.

No comments:

Post a Comment