• 5
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

Our app has DB version 14 and uses the android sqllite helpers. Now we are moving to use the room db and migrating all the DB stuff to room. we have defined all the migrations from 1_2, 2_3 .. to 13_14 and give all these int the build

.databaseBuilder(
                app,
                Database::class.java,
                "my.db"
        ).addMigrations(arrayOf(
        MIGRATION_1_2,
        MIGRATION_2_3,
       .....
        MIGRATION_10_11,
        MIGRATION_11_12,
        MIGRATION_12_13,
        MIGRATION_13_14
))
        .build()

Is this right way of doing. If i have the non room version of the app installed with DB version 14 and i try to update it to room version of the app with same db version 14, I am getting the error :

java.lang.IllegalStateException: Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number.

You only need to add a migration from your existing SQLite database to a Room-managed database. This should be an empty "do nothing" migration. This is required so that Room plays nicely with your existing database.

  • 1
Reply Report
      • 2
    • is it that i need to increase the version for migrating to room and add an empty migration_14_15
      • 2
    • @png Yes, an empty migration should do the trick. This is required just to get Room to play nicely with the existing database.
      • 2
    • ok, that would work if i have my db version 14 currently. Suppose a user has an older version of the app say with DB version 10 and now he tries to update to latest app with room and DB version 15. How would that work?
      • 2
    • @png My current solution in an app that I released is to keep my SQLiteOpenHelper subclass to manage upgrades from pre-Room versions. I'm not sure how to do this directly with Room.
      • 1
    • I have no change in DB from my sqlite version to the Room version, so what exactly I should add in migration