Just realized the principal id is different when I login my local development system, staging system and release system( 3 app deployments). I am using principal id as user id in system, it will be a problem if I change the deployment, the existed user can’t retrieve their data.
Is it possible to keep the same principal for sign with the same anchor? or suggestions?
The principal ID is generated by a deterministic algorithm from the public key of the current user. Your systems all have different “identities” (pub/private key pairs). You won’t be able to have a single principal ID for a single anchor because you will login into different apps using a different delegate key for each app on the IC.
I see, which means I have to migrate user data if the deploy is changed. Thanks!
If the deploy changes, your app will have a new canister ID and will be considered a completely new app. Therefore, principal IDs are going to be different, and you will need to migrate users, as well as match new IDs with old IDs.
This diagram summarizes it really well. The identifier for the user remains the same. However, the canister identifier changes for every deployment and hence the principal changes between deployments
More context available here: