Migration new schema with Device sync

Hello, i just updated the schema in my exists app,
in “local” we just increase schemaVersion like that :

final config = Configuration.local([Person.schema], schemaVersion: 2);

but in “flexibleSync” there is no such argument to change :

final config = Configuration.flexibleSync(user, [Person.schema])); 

the error i got after updating my schema :

Message: Migration is required due to the following errors…
so how can i migration old schema with the new one using “flexibleSync” ?

Hello @abdelrahman_mokhtar , :wave:

Welcome to MongoDB Community :partying_face:

Thank you so much for raising your concern.

Please note migrations are only supported for local realms and flexible sync does not support migration. The local realm migrations in flutter is a new feature that will be released this week.

For changes to the schema for sync, there can be breaking or non-breaking changes. Please refer to the update Schema section in the documentation for the same.

I hope the provided information is helpful.

Please don’t hesitate to ask if you need further assistance.

Cheers, :performing_arts:
Henna

3 Likes

I found the solution in the realm packge :

If you change your data models often and receive a migration exception be sure to delete the old default.realm file in your application directory. It will get recreated with the new schema the next time the Realm is opened.

I need to delete the local realm files, there is no migration option in the flutter beta yet.

@henna.s this solution should be added to the mongodb flutter docs as it’s missing there, also there is a wrong information about it : Updating the Schema of a Synced Realm

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.