New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
trying to migrate 0.8.x ➡️ 1.0.x #208
Comments
found the issue |
It works on my MongoDB version. Which MongoDB version are you using? |
mongo:4.2.3 full example:
now both are in correct format yeah, also tried to write some usable migration file, but until this moment no success :/ |
Ok, I get it. Your MongoDB connection is not set to use the new UUID standard, it's using the legacy format (which is still the default). I explain it here in the doc : https://frankie567.github.io/fastapi-users/configuration/databases/mongodb/#setup-database-connection-and-collection But this is something I definitely should add in the migration documentation. I'll do this. To solve your problem:
db.getCollection('users').find().forEach(function(user) {
var uuid = new BinData(4, user.id.base64()); // Notice the 4 instead of 3
db.getCollection('users').update({_id: user._id}, [{$set: {id: uuid}}]);
});
I would also recommend that you try Robot 3T as it clearly tells if a field is a UUID or Legacy UUID. |
thank you, frankie. |
Which editor are you using to execute your queries? |
All work fine! |
Oh, okay, sorry I misread your answer 😃 Glad we worked it out ! Cheers! |
Thank you once again, if you find how to same thing in python (not in mongo shell), please share it |
Sure! Should be something like: import uuid
import motor.motor_asyncio
async def migrate_uuid():
client = motor.motor_asyncio.AsyncIOMotorClient(
DATABASE_URL, uuidRepresentation="standard"
)
db = client["database_name"]
users = db["users"]
async for user in users.find({}):
await users.update_one(
{"_id": user["_id"]},
{"$set": {"id": uuid.UUID(user["id"])}},
) |
I've added this information in the migration documentation. Thank you for raising this point 😃 |
Hello frankie
it returns legacy UUID, not a standard one |
I am trying to migrate from old version but suggested script for MongoDB
gives an error
so later i created new account and clearly see, that something have changed
Update
I managed to update user in DB(?) well I think so, but nothing have changed(still same as showed in first picture)
using admin user (which one was created in old version), I can't login, using a new one I can
The text was updated successfully, but these errors were encountered: