Skip to content

Commit 5b52934

Browse files
committed
Refactor if conditions
1 parent 6d4c987 commit 5b52934

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
@@ -263,7 +263,7 @@ def alter_unique_together(
263263
def add_index(
264264
self, model, index, *, field=None, unique=False, column_prefix="", parent_model=None
265265
):
266-
idx = index.create_mongodb_index(
266+
idx = index.get_pymongo_index_model(
267267
model,
268268
self,
269269
field=field,
@@ -295,10 +295,8 @@ def remove_index(self, model, index):
295295
return
296296
if isinstance(index, SearchIndex | VectorSearchIndex):
297297
self.get_collection(model._meta.db_table).drop_search_index(index.name)
298-
elif isinstance(index, Index):
299-
self.get_collection(model._meta.db_table).drop_index(index.name)
300298
else:
301-
raise ValueError(f"{type(index)} isn't a supported index type")
299+
self.get_collection(model._meta.db_table).drop_index(index.name)
302300

303301
def _remove_composed_index(
304302
self, model, field_names, constraint_kwargs, column_prefix="", parent_model=None

0 commit comments

Comments
 (0)