generated from PhoenixEntertainment/SystemPackageTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Currently as of v1.0.0, the schema migration feature of this data system does not support migrating data that has existed before the schema was active. This makes it difficult to migrate older data to work with this system.
This can be supported by adding a function to the schema migration module with a keyname of ? -> 1. This function would take any data that is missing the schema version metadata and update it to conform to the 1st schema version. Here's an example of a game migrating its existing data to utilize this system's schema features:
Old data (prior to using schemas):
{
Coins = 120,
XP = 3600,
Inventory = {"Axe","Sword"}
}
Data schema version 2:
{
Currency = {
GoldCoins = 0,
Gems = 0
},
Progress = {
UnlockedWaystones = {},
XP = 0,
},
OwnedItems = {
Weapons = {},
Armor = {},
Consumables = {}
}
}
Schema migrations:
local SchemaMigrations = {}
SchemaMigrations["? -> 1"] = function(OldData)
local NewData = {
Currency = {
GoldCoins = OldData.Coins,
Gems = 0
},
OwnedItems = {
Weapons = {},
Armor = {},
Consumables = {}
},
XP = OldData.XP
}
for _,WeaponName in pairs(OldData.Inventory) do
table.insert(NewData.OwnedItems.Weapons,LegacyNameToItemID(WeaponName))
end
return NewData
end
SchemaMigrations["1 -> 2"] = function(Data)
Data.Progress = {
UnlockedWaystones = {},
XP = Data.XP
}
Data.XP = nil
return Data
endMetadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request