Custom options migrations
emptyrivers opened this issue ยท 5 comments
This is a feature that i'm undecided on for custom options. @Stanzilla @InfusOnWoW @mrbuds I would be grateful for some of your thoughts on this, or if you have a different idea for a solution.
Problem:
Currently, when you import an update to an aura with custom options, there is a decently strong possibility that this will cause you to lose settings, because WeakAuras validates the custom configuration on every Add() call, to ensure that configuration always is valid for what the author specifies, but is not also smart enough (nor can WeakAuras be, I think) to gracefully fix outdated configurations. If the author deletes an option, this is not too surprising, but if they edit the key or type of the option, then this is not so benign.
Possible solution:
Introduce an interface where authors can write migrations for data.config (not unlike the migrations we write for aura data whenever the internalVersion updates), and an authorVersion value which the author can manipulate. When a user imports a new version which has new author-defined migrations to run, then run these once and only once before validating data.config.
Example:
Author changes option key from foo
to bar
, and writes the following migration script, and increments authorVersion to 2:
function(config)
config.bar = config.foo
config.foo = nil
end
Upon update, WeakAuras sees that newData.authorVersion > oldData.authorVersion, and so runs the provided function, passing in data.config
to be mutated. This result is then validated as usual. Future updates will not run the migration script for authorVersion of 2. Thus, whatever the user chose for option foo will be preserved when they update.
Problems:
- This is another point of failure, and a poorly written migration may do more harm then good. But that is, I think, worth the risk - an aura that uses a feature badly doesn't indicate that the feature is bad.
- Size of import can increase significantly over time, as more and more migrations are added. I don't think it would be wise to automagically delete old migrations over time, due to the fact that users will share auras between them directly.
That's a hard one, especially since we offer upgrades of auras now, users probably expect and rightfully so, that everything gets upgraded properly. I'm just not sure if it's worth to go the extra mile
IMO it's acceptable that an aura lose user custom option data after a major update, but author needs to have a proper way to advertise it.
From wago they can set a changelog
This changelog is visible from Companion app, and from the "wago update" animated button's tooltip
WeakAuras2/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasDisplayButton.lua
Lines 1024 to 1027 in c9658d7
WeakAuras2/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasDisplayButton.lua
Lines 1986 to 1989 in c9658d7
I was thinking about showing it in the big update tooltip, or as a modal text box, kinda like what Details addon show after an update.
Maybe, but nobody reads the changelogs. The # 1 question we see about the companion app is (aside from maybe bug reports), "will my changes be kept or will i have to redo everything". Currently we can't give people good news about custom options, and I'd like to fix that.
The changelog thing does sound like a good idea, I'm just not convinced that it would solve this particular problem.
Well, it would be a nice feature, but I personally think the use case is pretty small.