Hello everyone,
Recently we started to do some changes in our game, that made some of the saved collections structures. Not fully obsolete but some of the fields had change.
For example like this: [Json data]
example:
Collection : character_inventory
Key : character_access
In create time :
{
“character1_isUnlocked”: false,
“character2_isUnlocked”: true,
“character3_isUnlocked”: false,
“character4_isUnlocked”: true,
“character5_character”: false,
“character6_isUnlocked”: false,
“character7_isUnlocked”: false,
“character8_isUnlocked”: false,
“character9_isUnlocked”: true
}
And after game Updates : we Introduced new character so I changed collection json as:
After Update time :
{
“character1_isUnlocked”: false,
“character2_isUnlocked”: true,
“character3_isUnlocked”: false,
“character4_isUnlocked”: true,
“character5_character”: false,
“character6_isUnlocked”: false,
“character7_isUnlocked”: false,
“character8_isUnlocked”: false,
“character9_isUnlocked”: true,
“character10_isUnlocked”: false
}
In create time , I will init these type collections in
const afterCreate: nkruntime.AfterHookFunction<
nkruntime.Session,
nkruntime.AuthenticateEmailRequest
= function (
ctx: nkruntime.Context,
logger: nkruntime.Logger,
nk: nkruntime.Nakama,
data: nkruntime.Session,
req: nkruntime.AuthenticateEmailRequest
){
if (data.created) {
let user_id = ctx.userId;
let character_access = {ABOVE JSON}
let character_inventory: nkruntime.StorageWriteRequest = [
{
collection: “character_inventory”,
key: “character_access”,
userId: user_id,
value: JSON.parse(character_access),
},
];
try {
nk.storageWrite(character_inventory);
} catch (error) {
logger.info(“error”);
}
else
return; // if account is not new return
};
[In create time Json] at that time authenticating users had character1…character9 in collection.
After the update I will introduced new “character10” field or add a new object for the wallet and user collections…
Server code updates and Collection change, Fields add … It will effect to Newly authenticated user,
how will I migrate or add this collection and wallets fields and changes to old user also…
I don’t know we can call this as storage collection versioning, I feel like that or otherwise I need to change the flow?