binayshaw7777
05/10/2024, 8:57 PMNeacsu Mihai Adrian
05/10/2024, 9:51 PMprivate val MIGRATION_1_2: Migration = object : Migration(1, 2) {
override fun migrate(database: SupportSQLiteDatabase) {}
}
// added a new value in the data class so i am adding it in the database too
private val MIGRATION_2_3: Migration = object : Migration(2, 3) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE yourTableName ADD COLUMN someNewColumn INTEGER")
}
}
After doing these, you need to add them to the databaseBuilder as :
Room.databaseBuilder(.....)
.addMigrations(
MIGRATION_1_2,
MIGRATION_2_3)
.build()
Neacsu Mihai Adrian
05/10/2024, 9:51 PMbinayshaw7777
05/10/2024, 10:34 PMNeacsu Mihai Adrian
05/10/2024, 10:38 PM