I am getting this error while running program with Room Database
Room cannot verify the data integrity. Looks like you\'ve changed schema but forgot to updat
In order to fix the problem in kotlin:
First
@Database(entities = [Contact::class], version = 2)
Second
val MIGRATION_1_2 = object : Migration(1, 2) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE Contact ADD COLUMN seller_id TEXT NOT NULL DEFAULT ''")
}
}
Third
private fun buildDatabase(context: Context) = Room.databaseBuilder(
context.applicationContext,
EpayDatabase::class.java,
"epay"
)
.addMigrations(MIGRATION_1_2)
.build()
For more details, check the official documentation