-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
58 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* eslint-disable no-unused-vars */ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
export interface MigrationState { | ||
[key: string]: any | ||
} | ||
|
||
interface Migrations { | ||
[version: number]: (state: MigrationState) => MigrationState | ||
} | ||
|
||
export const migrations: Migrations = { | ||
// Removes an existing function (deprecatedFunction) | ||
13: (state) => { | ||
const { deprecatedFunction, ...rest } = state | ||
return { | ||
...rest | ||
// Remove a deprecated function | ||
} | ||
}, | ||
|
||
// Removes an existing value (deprecatedValue) and repositions an existing value (existingValue) based on another value (anotherValue) | ||
14: (state) => { | ||
const { deprecatedValue, ...rest } = state | ||
return { | ||
...rest, | ||
existingValue: state.anotherValue + 1 // Change position of an existing value | ||
// Remove a deprecated value | ||
} | ||
}, | ||
|
||
// Adds a new value (newValue) based on an existing value (existingValue). Also adds a new function (newFunction) | ||
15: (state) => ({ | ||
...state, | ||
// Transformations for version 15 | ||
newValue: state.existingValue + 1, // Add new value based on existing value | ||
// Add a new function | ||
newFunction: () => console.log('New Function') | ||
}), | ||
|
||
16: (state) => ({ ...state }), | ||
17: (state) => ({ | ||
...state | ||
// Add new state properties or transform existing ones | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters