Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Migration is required due to the following errors in React native (Realm)

We are getting error like for following while APK file installation for particular OS version ( 8.0) in Android. But, This is working fine while development.

Error is following

Error: Migration is required due to the following errors:

ReactNativeJS: - Property 'Some Field' has been added.
ReactNativeJS: - Property 'other Field' has been added.

We are using Realm DB in our React Native project. As per some forums suggestions, We have deleted node modules and reset cache, Delete nodemodules/realm too. And done npm install too.

But, Still same error showing while trying to install APK, But, This issue not happening while we run in development mode.

Note: This issue happening only particular devices (OS version 8.0), Other devices its working fine.

Any suggestions?

like image 583
Anilkumar iOS - ReactNative Avatar asked Oct 21 '25 06:10

Anilkumar iOS - ReactNative


1 Answers

I know that is late but for anyone who comes for this here the answer: Realm requires for any update made to its schema to be solved using something called a Migration. This was invented having in considering that when you update your app from an version to another it might have some changes to the database that may make you data inconsistent. The easiest way the get rid of this is deleting all the current database data if you change your schema add deleteRealmIfMigrationNeeded add configurations as below

Realm.open({ schema: [BookSchema], deleteRealmIfMigrationNeeded: true, })

The other way is buy creating a migration your self as described at the official documentation

like image 141
sutuioncode Avatar answered Oct 23 '25 00:10

sutuioncode