mirror of
https://github.com/clearml/clearml-server
synced 2025-04-23 15:44:16 +00:00
Update 0.15 mongo migration to drop indices (so new ones will be automatically created)
This commit is contained in:
parent
b0b09616a8
commit
c43ce3a17b
43
server/mongo/migrations/0.15.0.py
Normal file
43
server/mongo/migrations/0.15.0.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
from collections import Collection
|
||||||
|
from typing import Sequence
|
||||||
|
|
||||||
|
from pymongo.database import Database, Collection
|
||||||
|
|
||||||
|
|
||||||
|
def _drop_all_indices_from_collections(db: Database, names: Sequence[str]):
|
||||||
|
for collection_name in db.list_collection_names():
|
||||||
|
if collection_name not in names:
|
||||||
|
continue
|
||||||
|
collection: Collection = db[collection_name]
|
||||||
|
collection.drop_indexes()
|
||||||
|
|
||||||
|
|
||||||
|
def migrate_auth(db: Database):
|
||||||
|
"""
|
||||||
|
Remove the old indices from the collections since
|
||||||
|
they may come out of sync with the latest changes
|
||||||
|
in the code and mongo libraries update
|
||||||
|
"""
|
||||||
|
_drop_all_indices_from_collections(db, ["user"])
|
||||||
|
|
||||||
|
|
||||||
|
def migrate_backend(db: Database):
|
||||||
|
"""
|
||||||
|
Remove the old indices from the collections since
|
||||||
|
they may come out of sync with the latest changes
|
||||||
|
in the code and mongo libraries update
|
||||||
|
"""
|
||||||
|
_drop_all_indices_from_collections(
|
||||||
|
db,
|
||||||
|
[
|
||||||
|
"company",
|
||||||
|
"model",
|
||||||
|
"project",
|
||||||
|
"queue",
|
||||||
|
"settings",
|
||||||
|
"task",
|
||||||
|
"task__trash",
|
||||||
|
"user",
|
||||||
|
"versions",
|
||||||
|
],
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user