add database migration

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2025-05-20 11:32:24 +02:00 committed by Marcel Hibbe
parent c337d5087b
commit b4de86b84e
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
3 changed files with 23 additions and 3 deletions

View File

@ -95,7 +95,7 @@ data class ConversationEntity(
@ColumnInfo(name = "unreadMentionDirect") var unreadMentionDirect: Boolean,
@ColumnInfo(name = "unreadMessages") var unreadMessages: Int = 0,
@ColumnInfo(name = "hasArchived") var hasArchived: Boolean = false,
@ColumnInfo(name = "isSensitive") var isSensitive:Boolean = false
@ColumnInfo(name = "isSensitive") var isSensitive: Boolean = false
// missing/not needed: attendeeId
// missing/not needed: attendeePin
// missing/not needed: attendeePermissions

View File

@ -62,6 +62,13 @@ object Migrations {
}
}
val MIGRATION_14_15 = object : Migration(14, 15) {
override fun migrate(db: SupportSQLiteDatabase) {
Log.i("Migrations", "Migrating 14 to 15")
addisSensitive(db)
}
}
fun migrateToRoom(db: SupportSQLiteDatabase) {
db.execSQL(
"CREATE TABLE User_new (" +
@ -283,6 +290,18 @@ object Migrations {
}
}
fun addisSensitive(db: SupportSQLiteDatabase) {
try {
db.execSQL(
"ALTER TABLE Conversations " +
"ADD COLUMN isSensitive INTEGER NOT NULL DEFAULT 0;"
)
} catch (e: SQLException) {
Log.i("Migrations", "Something went wrong when adding column isSensitive to table Conversations")
}
}
fun addTempMessagesSupport(db: SupportSQLiteDatabase) {
try {
db.execSQL(

View File

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