Device sync - Change Collection

Hi, we have a working device sync going but we need to change the atlas collection it is syncing to. Whats is the preferred method of achieving this?

Hi, unfortunately it is not an easy operation while sync is running. Do you have a live app with users? If not, I would just recommend terminating sync, updating the schemas in the backend to reference the new collection, and then enable sync.

If you want to do this while sync is running, it becomes an issue of backwards compatibility. Generally we recommend the approach of creating a new collection and using triggers to replicate data between the two collections in the meantime. See here for more details:


Thanks, we weren’t on a live sync, it’s just the initial dev. We ended up creating the new database, putting the device sync in dev mode, then renaming the realm objects in the code, once the new sync was established, we then renamed the objects back to the original names and the data was going into the right database. Bit of an around way of doing it. But it worked.

1 Like