Skip to content

Commit 1ecaa90

Browse files
committed
Refactor
1 parent 28ab176 commit 1ecaa90

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

django_mongodb_backend/schema.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
22
from django.db.models import Index, UniqueConstraint
3-
from pymongo.operations import IndexModel, SearchIndexModel
3+
from pymongo.operations import SearchIndexModel
44

55
from django_mongodb_backend.indexes import SearchIndex, VectorSearchIndex
66

@@ -270,10 +270,8 @@ def add_index(
270270
model = parent_model or model
271271
if isinstance(idx, SearchIndexModel):
272272
self.get_collection(model._meta.db_table).create_search_index(idx)
273-
elif isinstance(idx, IndexModel):
274-
self.get_collection(model._meta.db_table).create_indexes([idx])
275273
else:
276-
raise ValueError(f"{type(idx)} isn't a supported index type")
274+
self.get_collection(model._meta.db_table).create_indexes([idx])
277275

278276
def _add_composed_index(self, model, field_names, column_prefix="", parent_model=None):
279277
"""Add an index on the given list of field_names."""

0 commit comments

Comments
 (0)