diff --git a/update.md b/update.md index 064d53f212..e3d0166a45 100644 --- a/update.md +++ b/update.md @@ -512,6 +512,8 @@ Notifications 1. Lors de l'application des migrations `python manage.py migrate`, Django va vous demander s'il doit supprimer la table topicfollowed. Renseignez oui. 2. Exécuter la commande `python manage.py migrate_subscriptions` pour migrer les anciennes notifications vers les nouvelles. +Si vous constatez des problèmes de performance, lancez la commande suivante : `mysqloptimize -uroot -p zdsdb` + Liste des tags exclus --------------------- diff --git a/zds/notification/migrations/0008_auto_20160507_1504.py b/zds/notification/migrations/0008_auto_20160507_1504.py new file mode 100644 index 0000000000..192322aa4b --- /dev/null +++ b/zds/notification/migrations/0008_auto_20160507_1504.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('notification', '0007_auto_20160121_2343'), + ] + + operations = [ + migrations.AlterField( + model_name='notification', + name='object_id', + field=models.PositiveIntegerField(db_index=True), + ), + migrations.AlterField( + model_name='subscription', + name='object_id', + field=models.PositiveIntegerField(db_index=True), + ), + ] diff --git a/zds/notification/models.py b/zds/notification/models.py index 381f50faa7..5cf2d8ed1f 100644 --- a/zds/notification/models.py +++ b/zds/notification/models.py @@ -30,7 +30,7 @@ class Meta: is_active = models.BooleanField(_(u'Actif'), default=True, db_index=True) by_email = models.BooleanField(_(u'Recevoir un email'), default=False) content_type = models.ForeignKey(ContentType) - object_id = models.PositiveIntegerField() + object_id = models.PositiveIntegerField(db_index=True) content_object = GenericForeignKey('content_type', 'object_id') last_notification = models.ForeignKey(u'Notification', related_name="last_notification", null=True, default=None) @@ -267,7 +267,7 @@ class Meta: subscription = models.ForeignKey(Subscription, related_name='subscription', db_index=True) pubdate = models.DateTimeField(_(u'Date de création'), auto_now_add=True, db_index=True) content_type = models.ForeignKey(ContentType) - object_id = models.PositiveIntegerField() + object_id = models.PositiveIntegerField(db_index=True) content_object = GenericForeignKey('content_type', 'object_id') is_read = models.BooleanField(_(u'Lue'), default=False, db_index=True) url = models.CharField('URL', max_length=255)