Versioned storage with migrations #49
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MichaelContento/redux-storage#49
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi,
I am just curious if you thought about store migrations? What if we change structure? I think it should be responsibility of every reducer reviver.
Hi,
currently there is no built-in functionality to handle migrations at all. But it should be pretty easy to create a custom engine decorator for this purpose. Here is a short (untested!) draft:
All you have to do in the
migrationDecoratoris to ....migrationDecorator) in the state tree onsave()load()So for the example in the draft above: if the current version is
v3and the loaded one isv1, we need to apply callbacks forv2andv3.Is this a good starting point for you?
Feel free to submit such a decorator as a PR! I'm thankful for every contribution :)
Awesome answer, thank you! Once I will implemented it, I will send you a PR.
Thanks! I'll close this issue for now :)
Here is it: https://gist.github.com/steida/f5e53c69c4e3b423c15d
I simplified api, and I don't think we need explicit current version, since it's defined by migrations array.
Unfortunately, because
cognitive overhead, I'm not able to send PR forTwo spaces ftw.
Re-opened as a reminder. If someone want to contribute @steida's gist as a PR, I'd be very happy 😃
That's what I am using https://gist.github.com/steida/85443aac1dcb6daaa245 No time to send PR yet, maybe later :-)