In addition to the very useful indications that
wOxxOm
gave you,
I want to add some of my considerations.
Avoid like the plague to manage this thing with the onUpdateAvailable event because this event is irreversibly "linked"
to potential old versions that your users may still have installed.
You would find yourself having to deal with "onUpdateAvailable" + "onInstall" combinations that could give you some headache in the long run.
As for the "in memory" storage (localStorage and \ or browser.storage) there are no big problems;
one method is as good as another
(you can operate on one item at a time or create a temporary object that will replace the storage once deleted).
For the indexedDB this is a bit more complicated.
While it is true that at first sight it would be enough to increase the version number of the DB and then manage the version inside the "upgradeneeded" event,
it must remember that inside its handler it can't do everything.
We can perform "data definition" operations but not "data modification".
In practice, as long as there is to add\remove an objectStore or an index, no problem.
Problems arise when you have to change the structure of an objectstore or you have to translate\modify\aggregate\map its values
In this case it is better to create a new db, launch a conversion procedure (reading from the old one and writing to the new one)
and at the end of the procedure delete the old db (after having closed it!).
At that point you will also have to change the code where you open the db and replace the old name with the new one.
(it is not possible, as far as I know, to rename an indexedDB).
The operation that I have described to you depends a lot on the size of the DB and therefore it will certainly not be fast.
It is therefore likely that you will need an open window\tab to complete this job since the service worker may suddenly fall asleep.