Change realm database table name


#1

I have a table created with the name A and I need to write a migration to change the name to B, keeping the data and columns intact. I am using realm database javascript.

I have raised a question here as well.


#2

There is no tables is realm. It’s an object base database.

If you are changing an existing realm models name, then it should raise a migration, however you should/need to bump your schema version too.
With that, you can handle the changes is a migration block, where you will need:

  • get all of your model A objects
  • convert it to model B
  • add to realm
  • delete all old model A objects (*optional step, you dont necessery need to do it. Its good for backup in case something happens)

You can find more info about migrations here: https://realm.io/docs/java/latest/#queries