LXJ
LXJ

Reputation: 1616

questions on ObjectBox data model rename

Say I want to rename property "user" to "customer". I understand that I can add @Uid of "user" at the new property name. Like:

@Uid(123985252953064306)
String customer;

So I presume during the next build and run of my app, "user" in the database is renamed to "customer". My first questions are: can I then remove @Uid(123985252953064306) from my code for further builds? I guess the answer is yes if the app is only used by myself? So to maintain compatibility for endusers of the app, I still need to keep the @Uid annotation in the code. Is it correct?

My next question is: what if later I want to rename "customer" to "client"? Should I add an additional @Uid at the new property? Like:

@Uid(123985252953064306)
@Uid(124568645726267383)
String client;

Upvotes: 1

Views: 143

Answers (1)

Markus Junginger
Markus Junginger

Reputation: 7090

The questions you are asking are covered by the docs in Data Model Updates and with some more background in Meta Model, IDs, and UIDs.

In short, once you put an @Uid on an property (or an entity) you can rename it anyway you want as often you want. ObjectBox takes the UID to identify the property and knows it been there before. Thus you need to keep it on the property.

So from

@Uid(123985252953064306)
String customer;

you can go to

@Uid(123985252953064306)
String someFancyName;

and back to

@Uid(123985252953064306)
String customer;

with keeping the same data for the property in the database.

Upvotes: 1

Related Questions