From 7a4a5eb03ee3c6cbe78fe532b24d55e47997d728 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Mon, 3 May 2021 17:36:49 +0300 Subject: [PATCH] Fix dropping index by name during the migration fails if the index does not exist --- apiserver/mongo/migrations/0.13.0.py | 3 +-- apiserver/mongo/migrations/0.14.0.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/apiserver/mongo/migrations/0.13.0.py b/apiserver/mongo/migrations/0.13.0.py index ce714e2..c9a1d1a 100644 --- a/apiserver/mongo/migrations/0.13.0.py +++ b/apiserver/mongo/migrations/0.13.0.py @@ -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): diff --git a/apiserver/mongo/migrations/0.14.0.py b/apiserver/mongo/migrations/0.14.0.py index c8be217..c83cb4b 100644 --- a/apiserver/mongo/migrations/0.14.0.py +++ b/apiserver/mongo/migrations/0.14.0.py @@ -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)