serra/utils/migrations.py
Florian Baumann 0354830724 migrations
2022-01-07 11:45:54 +01:00

20 lines
461 B
Python

from pymongo import MongoClient
import os
import pymongo
CONNECTION_STRING = os.getenv("MONGODB_URI")
client = MongoClient(CONNECTION_STRING+'/admin')
# Create a new collection
collection = client["serra"]["cards"]
cards=collection.find()
for c in cards:
print(c["_id"])
f = { '_id': c["_id"] }
u = { "$set": { 'collectornumber': str(c["collectornumber"])} }
print("%s %s %s" % (f, u, c["collectornumber"]))
collection.update_one(f, u)