Fix dropping index by name during the migration fails if the index does not exist

This commit is contained in:
allegroai 2021-05-03 17:36:49 +03:00
parent d029d56508
commit 7a4a5eb03e
2 changed files with 3 additions and 4 deletions

View File

@ -5,8 +5,7 @@ from pymongo.database import Database, Collection
def migrate_auth(db: Database):
collection: Collection = db["user"]
if "name_1_company_1" in [doc["name"] for doc in collection.list_indexes()]:
collection.drop_index("name_1_company_1")
collection.drop_indexes()
def migrate_backend(db: Database):

View File

@ -31,8 +31,8 @@ def migrate_auth(db: Database):
if not uuids:
return
collection = db["user"]
collection.drop_index("name_1_company_1")
collection: Collection = db["user"]
collection.drop_indexes()
_switch_uuid(collection=collection, uuid_field="_id", uuids=uuids)