Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Realm on Android, How do you migrate (add) a new linking field

Ok so i have an app than had a Coin realm object. I am now upgrading my app, and adding multiple new fields to the existing Coin object. So far so good, but how do i migrate a LinkingObject, RealmResults type. linkedPortfolioCoins is what i want to migrate

public class Coin extends RealmObject {
    //a bunch of other fields here

    @LinkingObjects("coin")
    private final RealmResults<PortfolioCoin> linkedPortfolioCoins = null;
}

Also, There is only

.addRealmListField

Which i assume will be ok instead of RealmResults, but how do i make it a LinkingObject to Coin.

The error im getting is

 Caused by: io.realm.exceptions.RealmMigrationNeededException: Field count is more than expected - expected 18 but was 19
like image 497
MrRed Avatar asked Mar 08 '23 14:03

MrRed


1 Answers

Ok just to help anyone in future. It appears you dont have to migrate linking objects. Got it working by just not migrating the linkedPortfolioCoins and leaving it out. That would also explain my error :)

like image 84
MrRed Avatar answered Apr 25 '23 13:04

MrRed