add index on popularity count
authorJan Szejko <janek37@gmail.com>
Mon, 26 Feb 2018 14:05:06 +0000 (15:05 +0100)
committerJan Szejko <janek37@gmail.com>
Mon, 26 Feb 2018 14:05:06 +0000 (15:05 +0100)
src/catalogue/migrations/0022_auto_20180226_1503.py [new file with mode: 0644]
src/catalogue/models/book.py

diff --git a/src/catalogue/migrations/0022_auto_20180226_1503.py b/src/catalogue/migrations/0022_auto_20180226_1503.py
new file mode 100644 (file)
index 0000000..a673f42
--- /dev/null
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('catalogue', '0021_auto_20171222_1404'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='bookpopularity',
+            name='count',
+            field=models.IntegerField(default=0, db_index=True),
+        ),
+    ]
index 0f664c4..8b85ec7 100644 (file)
@@ -715,4 +715,4 @@ add_file_fields()
 
 class BookPopularity(models.Model):
     book = models.OneToOneField(Book, related_name='popularity')
 
 class BookPopularity(models.Model):
     book = models.OneToOneField(Book, related_name='popularity')
-    count = models.IntegerField(default=0)
+    count = models.IntegerField(default=0, db_index=True)