Note: additive and destructive schema changes are now referred to as non-breaking and breaking changes but the concepts are identical.
I hope you are having a good time getting information on the forums. As you are aware, I started as Community Manager for Realm in Dec and I have been going through some questions on the forum and I found Schema Changes to be frequently asked questions and hence the birth of the idea Realm Bytes
Every Week, I would be selecting anyone such topic and along with your collaboration, we would be talking more on that.
Schema Changes can be additive (backwards compatible) or destructive (not backwards compatible) and care should be taken when making changes to Schema for a running application.
A diagram is presented below to help identify whether a schema change is additive or destructive:
Additive Changes: These changes do not trigger a re-sync on the server and your SDK data models should be able to start using the new schema seamlessly. Your client-code (schema on mobile) can be a subset of your Cloud UI (schema on the server) Schema. Learn more
Note: Additive Changes can only Remove Fields if they are optional, removing Required fields will be a destructive change.
When you make an additive schema change there will be a brief update that takes place on the Realm Sync backend and changes may be delayed in propagating to MongoDB Atlas for a short period of time.
Destructive Changes: These changes will require a re-sync i.e Terminate and Re-enable Sync to map the new schema in place, and we strongly recommend making sure you have client reset logic in place first. These changes are preferably made directly in the cloud UI. Learn more
Note: Destructive changes are not allowed to be done via the Realm CLI or Code Deployment.
I hope the provided information is helpful.
I would love to hear from your experience, what worked and what didn’t. If there is a topic you want me to cover next week, please feel free to reach out.