From d97a030fa0d2cf99d604ef9983b32c419acb0491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Miedzi=C5=84ski?= Date: Fri, 15 Mar 2024 18:09:14 +0100 Subject: [PATCH] Add index to hostname --- src/ralph/assets/models/assets.py | 1 + src/ralph/virtual/models.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ralph/assets/models/assets.py b/src/ralph/assets/models/assets.py index a4ae5b4eb8..a1d645d0b5 100644 --- a/src/ralph/assets/models/assets.py +++ b/src/ralph/assets/models/assets.py @@ -368,6 +368,7 @@ class Asset(AdminAbsoluteUrlMixin, PriceMixin, BaseObject): max_length=255, null=True, verbose_name=_('hostname'), # TODO: unique + db_index=True, ) sn = NullableCharField( blank=True, diff --git a/src/ralph/virtual/models.py b/src/ralph/virtual/models.py index bde08a2e70..8b24395610 100644 --- a/src/ralph/virtual/models.py +++ b/src/ralph/virtual/models.py @@ -214,7 +214,8 @@ def save(self, *args, **kwargs): ) hostname = models.CharField( verbose_name=_('hostname'), - max_length=255 + max_length=255, + db_index=True, ) hypervisor = models.ForeignKey(DataCenterAsset, blank=True, null=True) image_name = models.CharField(max_length=255, null=True, blank=True)