I'm migrating over 70,000 users from old SQL database server to Firebase. And along with that, also their posts, comments, likes, followers, and many others.
I tried using a simple FirebaseAuth.instance.createUserWithEmailAndPassword but then I got
[firebase_auth/too-many-requests] We have blocked all requests from this device due to unusual activity. Try again later.
Then I found FirebaseAuth import users here. And it seems to be the right approach.
But this method requires that we provide the UID. However in my case, the previous user's id was an SQL auto-increment id's. (We don't want this kind of id in Firebase. And this was the reason why I did the previous method, to get the UID from FirebaseAuth prior to migrating all other data.)
So now if I'm gonna use the FirebaseAuth import mechanism, I'll need to create new UIDs myself (possibly by hashing emails) then use this new generated UID across all data (i.e: posts, comments, likes, etc) to identify the user who owns them.
But the question is: Will FirebaseAuth import mechanism preserve the given UID forever? Because according to this post there will be a new UID generated by FirebaseAuth (which probably makes sense due to security concerns).
Excerpted here:
You cannot create a user account, and then have the user "sign up" with the same UID.
If I understand it correctly, then for my case it would be a disaster because I will lost all references to the user's posts, comments and all other stuff.
I tried to read documentations but nothing states about this point here.
If the original given UIDs are not preserved, then is there another way to migrate users?
Your use-case is different from the one Hiranya answered on in the link. There they were implement a email-invite system, while you are "simply" important users.
Once a user exists in Firebase Authentication their UID will never be changed. So if you give your users a specific UID while importing them into Firebase Authentication, they will have that UID forever.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With