Realm-js: Migration when schema changed.

Created on 25 Feb 2016  路  5Comments  路  Source: realm/realm-js

Hello, I use react-native 0.20.0 and latest realm-js.

Everytime I change schema, iOS simulator failed execute because migration error.

I saw (solution)[https://github.com/realm/realm-js/issues/169] but is there any other solution?

Most helpful comment

You can delete all objects in a database with this method:

https://realm.io/docs/react-native/latest/api/Realm.html#deleteAll

All 5 comments

When changing your schema you need to pass in a new schemaVersion the next time you open the Realm. This is documented here: https://realm.io/docs/react-native/latest/#schema-version

Thank you @alazier. additional question. How can I reset realm database?

You can delete all objects in a database with this method:

https://realm.io/docs/react-native/latest/api/Realm.html#deleteAll

Thank you @alazier

I found that we must give realm config to all codes that like this:
Realm.open()
I thought it must be used only in new realm but we must use our new realm config in all Realm.open

Was this page helpful?
0 / 5 - 0 ratings

Related issues

max-zu picture max-zu  路  3Comments

fever324 picture fever324  路  4Comments

emrehayirci picture emrehayirci  路  3Comments

timanglade picture timanglade  路  3Comments

ugendrang picture ugendrang  路  3Comments