androidkotlinrealmrealm-java

Do I need a migration to change type Int to Long?


There is a birthday field in my RealmObject class which is a type of Int?. I need to change this field's type to Long?. I don't know whether I would need a migration or not.

From realm docs :

The integer types byte, short, int, and long are all mapped to long within Realm.

I have tried to install a version of the app without deleteRealmIfMigrationNeeded (meaning that Realm will try to do a migration if needed) on emulator and then changed the field from Int? to Long?. No crashes or exceptions. Also when I pulled my realm file from emulator, field's type stayed the same and still is Int?.

open class Profile : RealmObject() {

    @PrimaryKey
    var id = ""
    var email = ""
    var firstName = ""
    var lastName = ""
    var dateJoined = 0
    var gender: String? = null
    var birthday: Int? = null // I want to change this to Long?
}

What I am expecting is that I will need no migrations for this scenario. But I don't want to push the update without getting a real answer.


Solution

  • It is confirmed that there is no migration needed for this case. Do I need a migration to change type Int to Long?