-
Notifications
You must be signed in to change notification settings - Fork 61
Synced data migrations
William O'Beirne edited this page Jan 15, 2019
·
1 revision
If you change any of the reducer shapes that get backed up into storage, you'll need to create a migration to handle transforming any old stored data into the new format. Here's how to do it:
- Increment the version of the affected config in the
SyncConfig
object insrc/app/utils/sync.ts
- Add a migration key that has a key for the version you're upgrading
- For instance, if you're bumping from 1 -> 2, you'd have a migration config of
{ 2: (oldData) => ... }
- For instance, if you're bumping from 1 -> 2, you'd have a migration config of
{
data: string;
}
{
key: 'test',
version: 1,
encrypted: false,
selector: selectTestedState,
action: setTestedState,
triggerActions: [...],
},
{
data: Array<string>;
}
{
key: 'test',
version: 1,
encrypted: false,
selector: selectTestedState,
action: setTestedState,
triggerActions: [...],
migrations: {
2: (oldState: any) => {
return [oldState.data];
},
},
},