Considerations for schema migration
To evolve your @Model schema across app versions, use SwiftData's standard migration mechanisms (VersionedSchema, SchemaMigrationPlan, MigrationStage, and @Attribute(originalName:)). Define your versioned schemas and plan as usual, then pass the plan to GDSecureModelContainer.create(_:migrationPlan:).
let config = try GDSecureModelConfiguration(name: "Notes",
versionedSchema: NotesSchemaV2.self,
storeURL: storeURL)
let container = try GDSecureModelContainer.create(config,
migrationPlan: NotesMigrationPlan.self)
Before you ship a schema change, review the following considerations for the BlackBerry Dynamics secure store.
|
Consideration |
Details |
|---|---|
|
Migration plans require |
A |
|
Widen required to optional ( |
Automatic lightweight migration is supported. You can ship the change without a custom migration stage. |
|
Drop a relationship |
Automatic lightweight migration is supported. There is no automatic orphan cleanup. If you need cascade-delete behavior, implement it in a |
|
Rename a property with |
Automatic lightweight migration is supported when you include the |
|
Change an attribute's type |
Automatic migration is not supported for type changes such as |
|
Tighten optional to required when null values exist |
Automatic migration is not supported. Backfill null values in a |
|
Add a new required field with no default |
Automatic migration is not supported. Make the field optional, give it a default, or populate it in a |
|
Rename a property without |
Automatic migration is not supported. The migration fails instead of silently discarding data. Add the |
|
Migration failure |
When a migration fails, the BlackBerry Dynamics SDK throws an error with code |