I am using Room persistence library in my android project. I have a database view and I want to add a column to it in new version of my application. what is the proper code for migration?
database.execSQL("????")
PS: I want to change a View, not Table and I tried this:
database.execSQL("ALTER TABLE table_name ADD COLUMN column_name data_type")
I got this error: Cannot add a column to a view (code 1 SQLITE_ERROR)
Update: the old version of my view:
@Data
@DatabaseView("SELECT site.name AS address, group_site.name AS groupName, group_site.member_id AS memberId " +
"FROM site, group_site " +
"INNER JOIN groupsite_join_site " +
"ON site.id = groupsite_join_site.site_id AND group_site.id = groupsite_join_site.group_site_id "
)
public class SiteDetail {
long memberId;
String address;
String groupName;
}
new version:
@Data
@DatabaseView("SELECT site.id as id, site.name AS address, group_site.name AS groupName, group_site.member_id AS memberId " +
"FROM site, group_site " +
"INNER JOIN groupsite_join_site " +
"ON site.id = groupsite_join_site.site_id AND group_site.id = groupsite_join_site.group_site_id "
)
public class SiteDetail {
long id;
long memberId;
String address;
String groupName;
}
As can be seen I want to add id column to my database view.