- Notifications
You must be signed in to change notification settings - Fork405
Description
We have our state persisted to local storage and currently do not use migrations. This state therefore does not have a version tag.
As we must specify a version in the migration as a string|number it seems the migration never runs. I would like to initially change a defaulted value in the state with this migration
export const callHistoryMigrations = [
{
version: 0,
key: 'callhistory',
versionKey: 'version',
migrate: (state:any) => {
return {
...state,
missedCallsCount: 100,
version: 1
};
}
}
];
but it doesn't run. I added the version field to my state model and the defaults.
Looking at the code in ngxs-storage the getValue would never work as it would be comparing version 0 to undefined:
const versionMatch =
strategy.version === getValue(storedValue, strategy.versionKey || 'version');
which is: const versionMatch = 0 === undefined;