WeakAuras

WeakAuras

206M Downloads

Custom options migrations

emptyrivers opened this issue ยท 5 comments

commented

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.
commented

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

commented

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

self.update.desc = L["From version "] .. showVersion .. L[" to version "] .. showCompanionVersion
if updateData.versionNote then
self.update.desc = ("%s\n\n%s"):format(self.update.desc, updateData.versionNote)
end

update:SetScript("OnEnter", function()
animGroup:Play()
Show_Tooltip(button, update.title, update.desc)
end);

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.

commented

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.

commented

Well, it would be a nice feature, but I personally think the use case is pretty small.

commented

Alright, it looks like there aren't enough people who are actually enthusiastic about this to be worth doing. Thanks for your feedback, all (including the people who did not respond on this ticket directly).