Skip to content

Commit 352ebed

Browse files
committed
Refactor
1 parent 6000c34 commit 352ebed

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

@@ -274,10 +274,8 @@ def add_index(
274274
model = parent_model or model
275275
if isinstance(idx, SearchIndexModel):
276276
self.get_collection(model._meta.db_table).create_search_index(idx)
277-
elif isinstance(idx, IndexModel):
278-
self.get_collection(model._meta.db_table).create_indexes([idx])
279277
else:
280-
raise ValueError(f"{type(idx)} isn't a supported index type")
278+
self.get_collection(model._meta.db_table).create_indexes([idx])
281279

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

0 commit comments

Comments
 (0)