In my addons I do not use ZO_SavedVars, so I am definitely in need for an alternative way to do this.
If persistence is a problem, maybe you can just put a "history" somewhere into ZO_Ingame.lua.
When the name of a character is changed in the pregame scene, or a character is deleted, or the displayName is changed you write that information to disk in pregame and once the client was ingame all addons can check what has changed and upgrade their vars accordingly.
It could look like this:
Lua Code:
accountHistory = {
{ACCOUNT_EVENT_CHARACTER_CREATED, "name", <timestamp>},
{ACCOUNT_EVENT_CHARACTER_NAME_CHANGED, "oldname", "newname", <timestamp>},
{ACCOUNT_EVENT_CHARACTER_RACE_CHANGED, <timestamp>},
{ACCOUNT_EVENT_CHARACTER_LOOK_CHANGED, <timestamp>},
{ACCOUNT_EVENT_CHARACTER_DELETED, "name", <timestamp>},
{ACCOUNT_EVENT_DISPLAYNAME_CHANGED, "oldname", "newname", <timestamp>},
}
It should be read-only so that an addon cannot change the information. Race and look change is probably not necessary, but wouldn't hurt either.
EDIT: Maybe instead of providing it via normal saveData you could also just return it from a function called GetAccountHistory.
In addition to timestamps you could give the events an id and if it is passed to GetAccountHistory it would only return events that come after that id.
EDIT2:
The upgrade code would then look something like this:
Lua Code:
for i=1, #accountHistory do
local id, type, timeStamp, name, newName = unpack(acountHistory[i])
if(type == ACCOUNT_EVENT_CHARACTER_NAME_CHANGED) then
saveData[GetDisplayName()][newName] = saveData[GetDisplayName()][name]
saveData[GetDisplayName()][name] = nil
elseif(type == ACCOUNT_EVENT_CHARACTER_DELETED) then
saveData[GetDisplayName()][name] = nil
elseif(type == ACCOUNT_EVENT_CHARACTER_CREATED) then
saveData[GetDisplayName()][name] = ZO_DeepTableCopy(defaultData)
elseif(type == ACCOUNT_EVENT_DISPLAYNAME_CHANGED) then
saveData[newName] = saveData[name]
saveData[name] = nil
end
lastId = id
end
(I changed the order for the timestamp to make it easier to get the right arguments)