mirror of
https://github.com/clearml/clearml-server
synced 2025-01-31 02:46:53 +00:00
Update migration to convert user preferences to JSON
This commit is contained in:
parent
f778837d4b
commit
72213dffa4
@ -1,6 +1,20 @@
|
|||||||
|
import json
|
||||||
|
|
||||||
from pymongo.database import Database, Collection
|
from pymongo.database import Database, Collection
|
||||||
|
|
||||||
|
|
||||||
def migrate_auth(db: Database):
|
def migrate_auth(db: Database):
|
||||||
collection: Collection = db["user"]
|
collection: Collection = db["user"]
|
||||||
collection.drop_index("name_1_company_1")
|
if "name_1_company_1" in [doc["name"] for doc in collection.list_indexes()]:
|
||||||
|
collection.drop_index("name_1_company_1")
|
||||||
|
|
||||||
|
|
||||||
|
def migrate_backend(db: Database):
|
||||||
|
collection: Collection = db["user"]
|
||||||
|
users = collection.find(
|
||||||
|
{"preferences": {"$exists": True, "$ne": None, "$type": "object"}}
|
||||||
|
)
|
||||||
|
for doc in users:
|
||||||
|
collection.update_one(
|
||||||
|
{"_id": doc["_id"]}, {"$set": {"preferences": json.dumps(doc["preferences"])}}
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user