clearml-server/apiserver/mongo/migrations/1_6_0.py

13 lines
392 B
Python
Raw Normal View History

2022-07-08 15:05:33 +00:00
from pymongo.collection import Collection
from pymongo.database import Database
def migrate_backend(db: Database):
projects: Collection = db["project"]
for doc in projects.find({"basename": None}):
name: str = doc["name"]
_, _, basename = name.rpartition("/")
projects.update_one(
{"_id": doc["_id"]}, {"$set": {"basename": basename}},
)