fix: add index on clickers

This commit is contained in:
Vasily Zubarev 2023-01-12 12:51:06 +01:00
parent 114f054c0b
commit 3a95e4c61b
4 changed files with 33 additions and 4 deletions

View File

@ -15,7 +15,7 @@ docker-run-dev: ## Runs dev server in docker
docker-run-production: ## Runs production server in docker
poetry run python3 manage.py migrate
poetry run gunicorn vas3k_blog.asgi:application -w 7 -k uvicorn.workers.UvicornWorker --bind=0.0.0.0:8022 --capture-output --log-level debug --access-logfile - --error-logfile -
poetry run gunicorn vas3k_blog.asgi:application -w 5 -k uvicorn.workers.UvicornWorker --bind=0.0.0.0:8022 --capture-output --log-level debug --access-logfile - --error-logfile -
help: ## Display this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \

View File

@ -0,0 +1,30 @@
# Generated by Django 4.1.5 on 2023-01-12 11:50
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
("comments", "0003_alter_comment_options_alter_comment_created_at_and_more"),
("clickers", "0002_initial"),
]
operations = [
migrations.AlterField(
model_name="clicker",
name="block",
field=models.TextField(db_index=True),
),
migrations.AlterField(
model_name="clicker",
name="comment",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="clickers",
to="comments.comment",
),
),
]

View File

@ -3,8 +3,8 @@ from django.db import models
class Clicker(models.Model):
post = models.ForeignKey("posts.Post", related_name="clickers", on_delete=models.CASCADE)
comment = models.ForeignKey("comments.Comment", related_name="clickers", null=True, on_delete=models.CASCADE)
block = models.TextField()
comment = models.ForeignKey("comments.Comment", related_name="clickers", null=True, on_delete=models.SET_NULL)
block = models.TextField(db_index=True)
created_at = models.DateTimeField(auto_now_add=True)
ipaddress = models.GenericIPAddressField(db_index=True)
useragent = models.CharField(max_length=256)

View File

@ -6,6 +6,5 @@ class NotificationsConfig(AppConfig):
name = "notifications"
def ready(self):
pass
# register signals here
from notifications.signals.comments import create_comment # NOQA