This repository has been archived by the owner on Jun 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lib] Fix cumulative metrics [web] Implement migrations (#33)
- Loading branch information
1 parent
3188a31
commit 10b034e
Showing
14 changed files
with
110 additions
and
17 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
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
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
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
6 changes: 6 additions & 0 deletions
6
packages/web/src/entities/migrations/persistence/1688489405401_initial.ts
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,6 @@ | ||
export const migratePersistenceInitial = ( | ||
value: Record<string, any> | ||
): Record<string, any> => { | ||
// Applies the initial migration to add the version key | ||
return value; | ||
}; |
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,18 @@ | ||
import { migratePersistenceInitial } from "./1688489405401_initial"; | ||
|
||
const migrations: ((value: Record<string, any>) => Record<string, any>)[] = [ | ||
migratePersistenceInitial, | ||
]; | ||
|
||
export const persistenceVersion = migrations.length; | ||
|
||
export const migratePersistence = (value: Record<string, any>) => | ||
migrations.reduce((acc, migration, i) => { | ||
const version = i + 1; | ||
|
||
if ((acc.version ?? 0) >= version) return acc; | ||
return { | ||
...migration(acc), | ||
version, | ||
}; | ||
}, value); |
6 changes: 6 additions & 0 deletions
6
packages/web/src/entities/migrations/settings/1688489405401_initial.ts
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,6 @@ | ||
export const migrateSettingsInitial = ( | ||
value: Record<string, any> | ||
): Record<string, any> => { | ||
// Applies the initial migration to add the version key | ||
return value; | ||
}; |
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,18 @@ | ||
import { migrateSettingsInitial } from "./1688489405401_initial"; | ||
|
||
const migrations: ((value: Record<string, any>) => Record<string, any>)[] = [ | ||
migrateSettingsInitial, | ||
]; | ||
|
||
export const settingsVersion = migrations.length; | ||
|
||
export const migrateSettings = (value: Record<string, any>) => | ||
migrations.reduce((acc, migration, i) => { | ||
const version = i + 1; | ||
|
||
if ((acc.version ?? 0) >= version) return acc; | ||
return { | ||
...migration(acc), | ||
version, | ||
}; | ||
}, value); |
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
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