diff --git a/src/ralph/assets/migrations/0035_auto_20240425_1059.py b/src/ralph/assets/migrations/0035_auto_20240425_1059.py new file mode 100644 index 0000000000..ecbb95fc0d --- /dev/null +++ b/src/ralph/assets/migrations/0035_auto_20240425_1059.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +import ralph.lib.mixins.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('assets', '0034_auto_20240304_1511'), + ] + + operations = [ + migrations.AlterField( + model_name='asset', + name='hostname', + field=ralph.lib.mixins.fields.NullableCharFieldWithAutoStrip(verbose_name='hostname', max_length=255, blank=True, null=True, db_index=True, default=None), + ), + ] 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/migrations/0014_auto_20240425_1059.py b/src/ralph/virtual/migrations/0014_auto_20240425_1059.py new file mode 100644 index 0000000000..9fcf40a17c --- /dev/null +++ b/src/ralph/virtual/migrations/0014_auto_20240425_1059.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('virtual', '0013_auto_20190625_1239'), + ] + + operations = [ + migrations.AlterField( + model_name='cloudhost', + name='hostname', + field=models.CharField(verbose_name='hostname', max_length=255, db_index=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)