Daily iOS
Persistence

SwiftData schema migration

You shipped a SwiftData app and now want to add a priority field to Todo and clean up existing title values by trimming whitespace. Which change happens automatically, and which one needs VersionedSchema and SchemaMigrationPlan?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

Adding an optional field or one with a default value goes through lightweight migration. Changing existing values can't be inferred, so it needs a VersionedSchema and a custom stage in a SchemaMigrationPlan.

Share a question