CloudContainer.swift (2054B)
1 import CloudKit 2 3 /// Central identifiers for Crossmate's CloudKit containers. 4 /// 5 /// Synced game data lives in a *versioned* container. A breaking schema change 6 /// spins up a fresh container rather than mutating the append-only Production 7 /// schema in place; the app points at the current generation and abandons the 8 /// previous one's data. `v3Identifier` is retained only so a build can still 9 /// *read* the prior container to detect a user carrying pre-v4 data (the v3→v4 10 /// reset flow), and can be dropped a release after launch. 11 /// 12 /// The superseded generations stay entitled because abandoning a container does 13 /// not reclaim its records: they keep consuming the signed-in account's iCloud 14 /// quota indefinitely, so the storage audit needs to be able to inventory them. 15 /// 16 /// Bump `identifier` and add the new id to `Crossmate.entitlements` together on 17 /// the next breaking schema change. 18 enum CloudContainer { 19 /// The current synced-game container. 20 static let identifier = "iCloud.net.inqk.crossmate.v4" 21 22 /// The immediately-previous generation, kept readable one release for the 23 /// pre-v4 data probe. Remove once all users have moved off it. 24 static let v3Identifier = "iCloud.net.inqk.crossmate.v3" 25 26 /// The second generation, abandoned in favour of v3. Diagnostics only — 27 /// nothing reads or writes game data here. 28 static let v2Identifier = "iCloud.net.inqk.crossmate.v2" 29 30 /// The original CloudKit generation, which is also Crossmate's public 31 /// iCloud Documents container. It remains entitled so imported puzzle files 32 /// stay available and lets diagnostics inventory the original CloudKit data. 33 static let v1Identifier = "iCloud.net.inqk.crossmate" 34 35 static var container: CKContainer { CKContainer(identifier: identifier) } 36 static var v3Container: CKContainer { CKContainer(identifier: v3Identifier) } 37 static var v2Container: CKContainer { CKContainer(identifier: v2Identifier) } 38 static var v1Container: CKContainer { CKContainer(identifier: v1Identifier) } 39 }