Hello there, we are facing a problem with `ROOM D...
# room
v
Hello there, we are facing a problem with
ROOM DB
it says the newly added column is not found, room library version is
2.1.0
, the app crashes, we have handled adding of the column in the migration, the migration seems to be successful since the user can use other parts of the app, but when the tables where a new column is added it crashes saying, Not all users are facing this problem only
10% of users
are having this problem, and mainly on
Samsung s9
with Android 9 facing more. This was the old table
Copy code
CREATE TABLE "pfile" ("id" INTEGER PRIMARY KEY NOT NULL ,"name" VARCHAR,"lname" VARCHAR,"rlhip" VARCHAR,"sex" VARCHAR,"wk" VARCHAR,"un" VARCHAR,"fun" VARCHAR,"pn" BOOL NOT NULL DEFAULT (1) ,"dd" DOUBLE,"add" DOUBLE,"ph" BLOB,"hk" BOOL,"th" VARCHAR,"fun" VARCHAR, "swk" VARCHAR)
Changed to the below( data type of some columns changed and tun column is added)
Copy code
CREATE TABLE pfile_new (id INTEGER PRIMARY KEY NOT NULL ,name TEXT, lname TEXT, " +
     "rlhip TEXT, sex TEXT, wk TEXT, un TEXT, lun TEXT, " + "pn INTEGER NOT NULL, " +
     "dd REAL, pdd REAL, ph BLOB, hk INTEGER, th TEXT, fun TEXT, swk TEXT, tun TEXT)
This is the code in the migrate function
Copy code
database.execSQL("CREATE TABLE pfile_new (id INTEGER PRIMARY KEY NOT NULL ,name TEXT, lname TEXT, " +
      "rlhip TEXT, sex TEXT, wk TEXT, un TEXT, lun TEXT, " + "pn INTEGER NOT NULL, " +
      "dd REAL, pdd REAL, ph BLOB, hk INTEGER, th TEXT, fun TEXT, swk TEXT, tun TEXT)")
database.execSQL("INSERT INTO pfile_new (id, name, lname, rlhip, sex, wk,un,lun,on,dd,pdd,ph,hk,th,fun,swk) " +
     "SELECT id, name, name, rlhip, sex, wk,lun, pn,dd,pdd,ph,hk,theme, fun +swk " +
     "FROM pfile")
database.execSQL("UPDATE profile_new set tun = '$tun'")
database.execSQL("DROP TABLE pfile")``database.execSQL("ALTER TABLE pfile_new RENAME TO pfile")
This is the method in the DAO
Copy code
@Query("SELECT * FROM pfile")
fun getData(): List<Pfile>
Following is the error we see, java.lang.IllegalArgumentException
column 'tun' does not exist
. Available columns: [id, name, lname, rlhip, sex, wk, un, lun, pn, dd, pdd, photo, hk, th, fun, swk] com.example.database.dao.UserDao_Impl.getData (edited)