forked from github/wulkanowy-mirror
Fix saving attachements with same url but from different messages (#2137)
This commit is contained in:
parent
f11354dd35
commit
a495fcbc5f
2435
app/schemas/io.github.wulkanowy.data.db.AppDatabase/55.json
Normal file
2435
app/schemas/io.github.wulkanowy.data.db.AppDatabase/55.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -48,6 +48,7 @@ import javax.inject.Singleton
|
||||
AutoMigration(from = 46, to = 47),
|
||||
AutoMigration(from = 47, to = 48),
|
||||
AutoMigration(from = 51, to = 52),
|
||||
AutoMigration(from = 54, to = 55, spec = Migration55::class),
|
||||
],
|
||||
version = AppDatabase.VERSION_SCHEMA,
|
||||
exportSchema = true
|
||||
@ -56,7 +57,7 @@ import javax.inject.Singleton
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
|
||||
companion object {
|
||||
const val VERSION_SCHEMA = 54
|
||||
const val VERSION_SCHEMA = 55
|
||||
|
||||
fun getMigrations(sharedPrefProvider: SharedPrefProvider, appInfo: AppInfo) = arrayOf(
|
||||
Migration2(),
|
||||
|
@ -2,16 +2,14 @@ package io.github.wulkanowy.data.db.entities
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import java.io.Serializable
|
||||
|
||||
@Entity(tableName = "MessageAttachments")
|
||||
@Entity(
|
||||
tableName = "MessageAttachments",
|
||||
primaryKeys = ["message_global_key", "url", "filename"],
|
||||
)
|
||||
data class MessageAttachment(
|
||||
|
||||
@PrimaryKey
|
||||
@ColumnInfo(name = "real_id")
|
||||
val realId: Int,
|
||||
|
||||
@ColumnInfo(name = "message_global_key")
|
||||
val messageGlobalKey: String,
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
package io.github.wulkanowy.data.db.migrations
|
||||
|
||||
import androidx.room.DeleteColumn
|
||||
import androidx.room.migration.AutoMigrationSpec
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
|
||||
@DeleteColumn(
|
||||
tableName = "MessageAttachments",
|
||||
columnName = "real_id",
|
||||
)
|
||||
class Migration55 : AutoMigrationSpec {
|
||||
|
||||
override fun onPostMigrate(db: SupportSQLiteDatabase) {
|
||||
db.execSQL("DELETE FROM Messages")
|
||||
db.execSQL("DELETE FROM MessageAttachments")
|
||||
}
|
||||
}
|
@ -40,7 +40,6 @@ fun List<SdkMessage>.mapToEntities(
|
||||
fun List<SdkMessageAttachment>.mapToEntities(messageGlobalKey: String) = map {
|
||||
MessageAttachment(
|
||||
messageGlobalKey = messageGlobalKey,
|
||||
realId = it.url.hashCode(),
|
||||
url = it.url,
|
||||
filename = it.filename
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user