Skip to content

Commit

Permalink
feat: add project_uuid index and migration
Browse files Browse the repository at this point in the history
  • Loading branch information
helllllllder committed Oct 1, 2024
1 parent 5711aa3 commit bd434b6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions chats/apps/api/v1/external/rooms/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def create(self, validated_data):

room = Room.objects.create(
**validated_data,
project_uuid=str(project.uuid),
contact=contact,
queue=queue,
protocol=protocol,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.1.2 on 2024-09-30 19:43

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("rooms", "0012_room_service_chat"),
]

operations = [
migrations.AddField(
model_name="room",
name="project_uuid",
field=models.TextField(
blank=True, default="", null=True, verbose_name="project_uuid"
),
),
migrations.AddIndex(
model_name="room",
index=models.Index(
fields=["project_uuid"], name="rooms_room_project_890f5f_idx"
),
),
]
7 changes: 7 additions & 0 deletions chats/apps/rooms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def __init__(self, *args, **kwargs):
)
urn = models.TextField(_("urn"), null=True, blank=True, default="")

project_uuid = models.TextField(
_("project_uuid"), null=True, blank=True, default=""
)

callback_url = models.TextField(_("Callback URL"), null=True, blank=True)

ended_at = models.DateTimeField(
Expand Down Expand Up @@ -86,6 +90,9 @@ class Meta:
name="unique_contact_queue_is_activetrue_room",
)
]
indexes = [
models.Index(fields=["project_uuid"]),
]

def save(self, *args, **kwargs) -> None:
if self.__original_is_active is False:
Expand Down

0 comments on commit bd434b6

Please sign in to comment.