Full sync handling after destructive schema in backend (Realm app on mongodb.com)

I have this scenario,

I have an json schema definition in realm app on mongo cluster:
Dog{ "price": { "bsonType": "string" } }

and a realm Object on android app like so,
Dog : RealmObject{ price: String? = null }

The sync on the app is working fine upto this point.
Now, I make an destructive schema change on the realm app on mongo server i.e. I update the datatype of price to double like so:
Dog{ “price”: { “bsonType”: “double” } }

Now the sync is not working on the app and throw client error: Failed to transform received changeset: Schema mismatch.

I can solve this by updating the app’s Dog realm object but in my case there is possibility that the user does not update the app with new updated realm object code.
For that user, the sync wont work because the his app is outdated and has outdated Dog realm object schema. This is my problem.

Most of the examples and solutions I saw on the internet help with migrating after local realm object schema changes. I want to handle schema changes from backend on the app such that sync doesn’t not fail for someone with outdated realm object.

Hi @Lakshmi_Narasimhan_M, welcome to the community!

In this particular case, I’d turn it into a non-destructive schema change (at the expense of some data duplication).

I’d add a new optional attribute: “price2”: { “bsonType”: “double” }, while leaving price unchanged. I’d also add database triggers to make sure that price and price2 are kept consistent with each other.

Old versions of the mobile app should continue to work, while new versions can use the new attribute.