Skip to content

Commit

Permalink
Created migration funtion in the social service and internship persis…
Browse files Browse the repository at this point in the history
…ting data.
  • Loading branch information
Emanuel-Palestino committed Sep 15, 2024
1 parent c1aa0ef commit 4c499c8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
13 changes: 12 additions & 1 deletion app/store/internship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,18 @@ export const useInternshipStore = create<InternshipStore>()(
{
name: 'internship-storage',
skipHydration: true,
storage: createStorage<InternshipStore>()
storage: createStorage<InternshipStore>(),
version: 1,
migrate: (persistedState: any, version) => {
if (version === 0) {
if (persistedState.periodData) {
persistedState.periodData.schedules = [persistedState.periodData.schedule]
delete persistedState.periodData.schedule
}
}

return persistedState
}
}
)
)
13 changes: 12 additions & 1 deletion app/store/socialService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,18 @@ export const useSocialServiceStore = create<SocialServiceStore>()(
{
name: 'social-service-storage',
skipHydration: true,
storage: createStorage<SocialServiceStore>()
storage: createStorage<SocialServiceStore>(),
version: 1,
migrate: (persistedState: any, version) => {
if (version === 0) {
if (persistedState.periodData) {
persistedState.periodData.schedules = [persistedState.periodData.schedule]
delete persistedState.periodData.schedule
}
}

return persistedState
}
}

)
Expand Down

0 comments on commit 4c499c8

Please sign in to comment.