Automatic lightweight migrations in SwiftData VersionedSchema?

Currently, I have an Unversioned Schema, and lightweight changes are automatically applied to the Models.

However, I'm planning to transition to a VersionedSchema, and I have a few questions:

  1. Do I need to write all lightweight migrations in the Migration Plan? or is it automatically applied like the Unversioned Schema?

  2. What happens if I do not create a lightweight migration? and just directly do lightweight changes to the latest VersionedSchema (example: Add a new property)?

Answered by Ygee in 816909022

I've experimented with it a bit and these are what I found out.

  1. There are no automatic lightweight migrations, you have to write every changes to your model in the migration

  2. If you do not create a lightweight migrations, your app will crash.

CONCLUSION:

If you have transitioned to a VersionedSchema, you now have to write every lchanges to your model in the migration or else your app will crash.

Accepted Answer

I've experimented with it a bit and these are what I found out.

  1. There are no automatic lightweight migrations, you have to write every changes to your model in the migration

  2. If you do not create a lightweight migrations, your app will crash.

CONCLUSION:

If you have transitioned to a VersionedSchema, you now have to write every lchanges to your model in the migration or else your app will crash.

Automatic lightweight migrations in SwiftData VersionedSchema?
 
 
Q