modify database scheme

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2025-05-26 10:13:47 +02:00 committed by Marcel Hibbe
parent 2e41b27dc8
commit a943dc1070
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
2 changed files with 23 additions and 2 deletions

View File

@ -69,6 +69,26 @@ object Migrations {
}
}
val MIGRATION_15_16 = object : Migration(15, 16) {
override fun migrate(db: SupportSQLiteDatabase) {
Log.i("Migrations", "Migrating 15 to 16")
addisImportant(db)
}
}
fun addisImportant(db: SupportSQLiteDatabase) {
try {
db.execSQL(
"ALTER TABLE Conversations " +
"ADD COLUMN hasImportant INTEGER NOT NULL DEFAULT 0;"
)
} catch (e: SQLException) {
Log.i("Migrations", "Something went wrong when adding column hasImportant to table Conversations")
}
}
fun migrateToRoom(db: SupportSQLiteDatabase) {
db.execSQL(
"CREATE TABLE User_new (" +

View File

@ -49,7 +49,7 @@ import java.util.Locale
ChatMessageEntity::class,
ChatBlockEntity::class
],
version = 15,
version = 16,
autoMigrations = [
AutoMigration(from = 9, to = 10)
],
@ -117,7 +117,8 @@ abstract class TalkDatabase : RoomDatabase() {
Migrations.MIGRATION_11_12,
Migrations.MIGRATION_12_13,
Migrations.MIGRATION_13_14,
Migrations.MIGRATION_14_15
Migrations.MIGRATION_14_15,
Migrations.MIGRATION_15_16
)
.allowMainThreadQueries()
.addCallback(