skygear-SDK-JS
skygear-SDK-JS copied to clipboard
migrate users
Hi
how to make migrate users from my server to skygear database.
can I use cloud function to create API to add my users to a skygear server?
Thanks.
@KhaledAld Have you solved the problem yet? You mentioned your problem in https://github.com/SkygearIO/skygear-SDK-JS/issues/359
To migrate users from your server to skygear, you don't need to do it in cloud function. There are several ways to do it.
-
The simplest way, you can create a node script and import skygear js sdk. In the node script, fetch your server users data, generate JWT token and call
loginWithCustomToken
. But this way will have a problem that all userscreated_at
andlast_login_at
will be the same (the time that you run the script.) If those information is important to you and you need to migrate them, you can consider method 2. -
Understand the user models in skygear postgresql db, migrate data to db directly. By using this way, you can fully control the data. When signing up a user, there will have 3 entries inserted into the db. They are
user
,_auth
and_sso_custom_token
.user._id
,auth.id
and_sso_custom_token.user_id
should be same uuid for each user._sso_custom_token.principal_id
is thesub
of JWT token.