how can i migrate user accounts from nextauth (mongo with prisma) to better auth (drizzle + pgsql)

so it should be pretty straight forward, but about the userid and accountid can i generate that to be random?
Solution:
Yeah those can be random, if you really want it to match what Better-auth would generate out of the box you can use our function:
import { generateId } from "better-auth";
import { generateId } from "better-auth";
...
Jump to solution
18 Replies
Solution
Ping
Ping3mo ago
Yeah those can be random, if you really want it to match what Better-auth would generate out of the box you can use our function:
import { generateId } from "better-auth";
import { generateId } from "better-auth";
david
davidOP3mo ago
also what about the account table?
david
davidOP3mo ago
these have to have some kind of values?
No description
david
davidOP3mo ago
cuz i tried signing in with my account (resetted the password first and it worked) but the 2fa mail is not coming through
Ping
Ping3mo ago
2fa mail?
david
davidOP3mo ago
yeah otp lemme try again cuz i set all users to two fa disabled migrated again with the better auth id generator
Ping
Ping3mo ago
So you've already migrated everything right? This is just a separate question?
david
davidOP3mo ago
yeah logging in rn hold on
david
davidOP3mo ago
No description
david
davidOP3mo ago
these are strictly for oauth providers?
david
davidOP3mo ago
No description
Ping
Ping3mo ago
Yeah most cases, yeah
david
davidOP3mo ago
session is fine now lemme try to enable twofa
david
davidOP3mo ago
No description
david
davidOP3mo ago
oh it works now awesome
Ping
Ping3mo ago
nice
david
davidOP3mo ago
trying discord auth rn could i possibly migrate discord links too? nvm i can't cuz i don't have anything related to discord saved in the db only the id and discord email jesus my auth was so bad @Ping passwords have to be updated by the user, there's no way to do this automatically?
Ping
Ping3mo ago
If NextAuth is using a different hashing algorithm than Better-auth, then yes. Since hashes can't be "unhashed" it means we don't know their password, so we can't automate converting password hashes.

Did you find this page helpful?