diff --git a/notifications/__init__.py b/notifications/__init__.py index b7599fd..de17f66 100644 --- a/notifications/__init__.py +++ b/notifications/__init__.py @@ -9,5 +9,3 @@ # PEP 386-compliant version number: N.N[.N]+[{a|b|c|rc}N[.N]+][.postN][.devN] __version__ = "1.8.0" - -default_app_config = "notifications.apps.Config" # pylint: disable=invalid-name diff --git a/notifications/migrations/0008_index_together_recipient_unread.py b/notifications/migrations/0008_index_together_recipient_unread.py index ae8eeab..ece6708 100644 --- a/notifications/migrations/0008_index_together_recipient_unread.py +++ b/notifications/migrations/0008_index_together_recipient_unread.py @@ -2,6 +2,24 @@ from django.conf import settings from django.db import migrations +from django.db.models import Index +from django.utils import version + +_version = version.get_version_tuple(version.get_version()) +if _version[0] >= 4 and _version[1] >= 2: + _operations = [ + migrations.AddIndex( + model_name="notification", + index=Index(fields=("recipient", "unread"), name="recipient_unread_idx"), + ), + ] +else: + _operations = [ + migrations.AlterIndexTogether( + name="notification", + index_together={("recipient", "unread")}, + ), + ] class Migration(migrations.Migration): @@ -10,9 +28,4 @@ class Migration(migrations.Migration): ("notifications", "0007_add_timestamp_index"), ] - operations = [ - migrations.AlterIndexTogether( - name="notification", - index_together={("recipient", "unread")}, - ), - ] + operations = _operations diff --git a/notifications/migrations/0016_rename_notification_recipient_unread_notificatio_recipie_8bedf2_idx.py b/notifications/migrations/0016_rename_notification_recipient_unread_notificatio_recipie_8bedf2_idx.py new file mode 100644 index 0000000..8243292 --- /dev/null +++ b/notifications/migrations/0016_rename_notification_recipient_unread_notificatio_recipie_8bedf2_idx.py @@ -0,0 +1,17 @@ +# Generated by Django 4.2.11 on 2024-05-03 00:08 + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("notifications", "0015_alter_notification_action_object_content_type_and_more"), + ] + + operations = [ + migrations.RenameIndex( + model_name="notification", + new_name="notificatio_recipie_8bedf2_idx", + old_fields=("recipient", "unread"), + ), + ] diff --git a/notifications/models/base.py b/notifications/models/base.py index 18462b0..1895f3f 100644 --- a/notifications/models/base.py +++ b/notifications/models/base.py @@ -116,7 +116,7 @@ class AbstractNotification(models.Model): abstract = True ordering = ("-timestamp",) # speed up notifications count query - index_together = ("recipient", "unread") + indexes = [models.Index(fields=["recipient", "unread"])] verbose_name = _("Notification") verbose_name_plural = _("Notifications") diff --git a/sample_website/sample_app/__init__.py b/sample_website/sample_app/__init__.py index a45fddd..e69de29 100644 --- a/sample_website/sample_app/__init__.py +++ b/sample_website/sample_app/__init__.py @@ -1,3 +0,0 @@ -default_app_config = ( # pylint: disable=invalid-name - "notifications.tests.sample_notifications.apps.SampleNotificationsConfig" -)