Fix chat index
This commit is contained in:
parent
9b5f0c0969
commit
8b814640ea
2 changed files with 39 additions and 2 deletions
34
chat_box/migrations/0012_auto_20230308_1417.py
Normal file
34
chat_box/migrations/0012_auto_20230308_1417.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
# Generated by Django 3.2.18 on 2023-03-08 07:17
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("judge", "0154_add_submission_indexes"),
|
||||||
|
("chat_box", "0011_alter_message_hidden"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name="message",
|
||||||
|
options={
|
||||||
|
"ordering": ("-id",),
|
||||||
|
"verbose_name": "message",
|
||||||
|
"verbose_name_plural": "messages",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="message",
|
||||||
|
name="hidden",
|
||||||
|
field=models.BooleanField(default=False, verbose_name="is hidden"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="message",
|
||||||
|
index=models.Index(
|
||||||
|
fields=["hidden", "room", "-id"], name="chat_box_me_hidden_b2307a_idx"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -31,7 +31,7 @@ class Message(models.Model):
|
||||||
author = models.ForeignKey(Profile, verbose_name=_("user"), on_delete=CASCADE)
|
author = models.ForeignKey(Profile, verbose_name=_("user"), on_delete=CASCADE)
|
||||||
time = models.DateTimeField(verbose_name=_("posted time"), auto_now_add=True)
|
time = models.DateTimeField(verbose_name=_("posted time"), auto_now_add=True)
|
||||||
body = models.TextField(verbose_name=_("body of comment"), max_length=8192)
|
body = models.TextField(verbose_name=_("body of comment"), max_length=8192)
|
||||||
hidden = models.BooleanField(verbose_name="is hidden", default=False, db_index=True)
|
hidden = models.BooleanField(verbose_name="is hidden", default=False)
|
||||||
room = models.ForeignKey(
|
room = models.ForeignKey(
|
||||||
Room, verbose_name="room id", on_delete=CASCADE, default=None, null=True
|
Room, verbose_name="room id", on_delete=CASCADE, default=None, null=True
|
||||||
)
|
)
|
||||||
|
@ -44,7 +44,10 @@ class Message(models.Model):
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "message"
|
verbose_name = "message"
|
||||||
verbose_name_plural = "messages"
|
verbose_name_plural = "messages"
|
||||||
ordering = ("-time",)
|
ordering = ("-id",)
|
||||||
|
indexes = [
|
||||||
|
models.Index(fields=["hidden", "room", "-id"]),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class UserRoom(models.Model):
|
class UserRoom(models.Model):
|
||||||
|
|
Loading…
Reference in a new issue