I have room entity like this
@Entity(tableName = "AppUser",
indices = {@Index(value = {"UserId", "UserName"}, unique = true)})
public class AppUser {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "UserId")
public int id;
public AppUser(int id) {
this.id = id;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
What I want to do is to later add additional column to existing table by extending AppUser
class . Something like following
public class ExtendedUser extends AppUser {
public ExtendedUser(int id) {
super(id);
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
@ColumnInfo(name = "address")
String address;
}
So later if someone wants to modify the table , they do not need to modify AppUser
, rather they would simply extend it .
Can I achieve it ?