Skip to content

Commit

Permalink
Add offline migration for system model 114
Browse files Browse the repository at this point in the history
  • Loading branch information
charlag committed Nov 25, 2024
1 parent 5b64a54 commit fa4b486
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/common/api/worker/offline/OfflineStorageMigrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { sys111 } from "./migrations/sys-v111.js"
import { tutanota76 } from "./migrations/tutanota-v76.js"
import { sys112 } from "./migrations/sys-v112.js"
import { tutanota77 } from "./migrations/tutanota-v77.js"
import { sys114 } from "./migrations/sys-v114.js"

export interface OfflineMigration {
readonly app: VersionMetadataBaseKey
Expand Down Expand Up @@ -76,6 +77,7 @@ export const OFFLINE_STORAGE_MIGRATIONS: ReadonlyArray<OfflineMigration> = [
tutanota76,
sys112,
tutanota77,
sys114,
]

const CURRENT_OFFLINE_VERSION = 1
Expand Down
23 changes: 23 additions & 0 deletions src/common/api/worker/offline/migrations/sys-v114.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { OfflineMigration } from "../OfflineStorageMigrator.js"
import { OfflineStorage } from "../OfflineStorage.js"
import { migrateAllElements, migrateAllListElements, Migration, removeValue } from "../StandardMigrations"
import { MailboxGroupRootTypeRef } from "../../../entities/tutanota/TypeRefs"
import { CustomerInfoTypeRef } from "../../../entities/sys/TypeRefs.js"
import { SomeEntity } from "../../../common/EntityTypes.js"

export const sys114: OfflineMigration = {
app: "sys",
version: 114,
async migrate(storage: OfflineStorage) {
await migrateAllListElements(CustomerInfoTypeRef, storage, [addUnlimitedLabelsToPlanConfiguration()])
},
}

function addUnlimitedLabelsToPlanConfiguration(): Migration {
return function addUnlimitedLabelsToPlanConfigurationMigration(entity: any): SomeEntity {
if (entity.customPlan != null) {
entity.customPlan.unlimitedLabels = false
}
return entity
}
}

0 comments on commit fa4b486

Please sign in to comment.