Migration is required due to the following errors: - Property 'Assets.Modified' has been made required


#1

I have no idea what this is referring to. I am incorporating Realm into a Desktop/Device application and the models are the same on both sides. I am deleting everything and starting fresh with each test so surely this shouldn’t be happening? Also this property probably hasn’t been changed except that at one time it might have been a nullable bool and I changed it to non nullable. The reason for the error “Property has been made required” doesn’t make sense as it’s always been required and it’s always been party of the model. Can someone shed some light on this for me please?

I can understand migrations in an ‘app’ development cycle but in a dedicated custom application for a client, that I have full control over, I would be inclined to think that this is something that should be an “opt in if required” kind of solution.

Any help would be much appreciated.


#2

This is exactly what the error says - Assets.Modified was optional before, because it was nullable, now it’s required, because it’s not nullable.

If you already created a database where the model was nullable, then ship a new version of the app where that is no longer nullable, this requires a migration because the database may contain entries that were null, but that is no longer a valid value. If you have experience with SQL databases, imagine a scenario where you want to change the column type from bigint to varchar - you would need to create a migration that will convert the integers to strings. Similarly, with Realm you need a migration that will convert the bool? values to bool.