[Patchew-devel] [PATCH 4/9] modify database in preparation for removing is_series_head
Paolo Bonzini
pbonzini at redhat.com
Thu Jan 16 15:09:04 UTC 2020
Otherwise, Django creates the RemoveField migration before AlterIndexTogether,
and the latter fails to apply. Also add a default so that reverting the
removal works.
Signed-off-by: Paolo Bonzini <pbonzini at redhat.com>
---
api/migrations/0055_auto_20200116_1034.py | 24 +++++++++++++++++++++++
api/models.py | 11 +++++------
2 files changed, 29 insertions(+), 6 deletions(-)
create mode 100644 api/migrations/0055_auto_20200116_1034.py
diff --git a/api/migrations/0055_auto_20200116_1034.py b/api/migrations/0055_auto_20200116_1034.py
new file mode 100644
index 0000000..12ee668
--- /dev/null
+++ b/api/migrations/0055_auto_20200116_1034.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.20 on 2020-01-16 10:56
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('api', '0054_populate_topic'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='message',
+ name='is_series_head',
+ field=models.BooleanField(default=False),
+ ),
+ migrations.AlterIndexTogether(
+ name='message',
+ index_together=set([('topic', 'date'), ('topic', 'project', 'last_reply_date'), ('topic', 'project', 'date'), ('topic', 'last_reply_date')]),
+ ),
+ ]
diff --git a/api/models.py b/api/models.py
index 6f4ea4b..0435527 100644
--- a/api/models.py
+++ b/api/models.py
@@ -457,7 +457,6 @@ class MessageManager(models.Manager):
msg.stripped_subject = m.get_subject(strip_tags=True)
msg.version = m.get_version()
msg.prefixes = m.get_prefixes()
- msg.is_series_head = False
if m.is_series_head():
msg.is_series_head = True
msg.topic = Topic.objects.for_stripped_subject(msg.stripped_subject)
@@ -578,7 +577,7 @@ class Message(models.Model):
recipients = jsonfield.JSONField()
tags = jsonfield.JSONField(default=[])
prefixes = jsonfield.JSONField(blank=True)
- is_series_head = models.BooleanField()
+ is_series_head = models.BooleanField(default=False)
is_complete = models.BooleanField(default=False)
is_patch = models.BooleanField()
is_merged = models.BooleanField(default=False, blank=True)
@@ -915,10 +914,10 @@ class Message(models.Model):
class Meta:
unique_together = ("project", "message_id")
index_together = [
- ("is_series_head", "project", "last_reply_date"),
- ("is_series_head", "project", "date"),
- ("is_series_head", "last_reply_date"),
- ("is_series_head", "date"),
+ ("topic", "project", "last_reply_date"),
+ ("topic", "project", "date"),
+ ("topic", "last_reply_date"),
+ ("topic", "date"),
]
--
2.21.0
More information about the Patchew-devel
mailing list