Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
### ⚠️ Changed

### ❌ Removed
- Removed duplicate Index creation on PrimaryKey of `ReplyAttachmentEntity` and `AttachmentEntity`.[#5820](https://github.com/GetStream/stream-chat-android/pull/5820)

## stream-chat-android-state
### 🐞 Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package io.getstream.chat.android.offline.repository.domain.message.attachment.internal

import androidx.room.ColumnInfo
import androidx.room.Embedded
import androidx.room.Entity
import androidx.room.ForeignKey
Expand All @@ -39,7 +38,6 @@ import io.getstream.chat.android.offline.repository.domain.message.internal.Mess
indices = [Index("messageId")],
)
internal data class AttachmentEntity(
@ColumnInfo(index = true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would actually need to increment the DB version in ChatDatabase. Otherwise we would end up in an invalid state. You can reproduce the following by:

  1. Build the app from develop
  2. Login
  3. Re-build again from this branch
  4. You can see an error in the ChannelList with the exception: java.lang.IllegalStateException: Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number

Copy link
Contributor Author

@Sagar0-0 Sagar0-0 Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, but I couldn't understand why this issue is there. IMO, it should not cause this crash as the Index already exists on the column. Adding an index in the annotation also creates the same Index. Do you have any idea what is happening on the DB level.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure why. Maybe it is some inconsistence with the data already stored on the DB and some internal check that Room.
It shouldn't be a problem because the DB is only used as offline option, but repopulated whenever new info come from the API. Old DB data will be removed when a new update of the app with the new SDK version is instaled, but it shouild be fine.
So, to be able to merge it, we will need to increase the DB version as @VelikovPetar said before

@PrimaryKey
val id: String,
val messageId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package io.getstream.chat.android.offline.repository.domain.message.attachment.internal

import androidx.room.ColumnInfo
import androidx.room.Embedded
import androidx.room.Entity
import androidx.room.ForeignKey
Expand All @@ -39,7 +38,6 @@ import io.getstream.chat.android.offline.repository.domain.message.internal.Repl
indices = [Index("messageId")],
)
internal data class ReplyAttachmentEntity(
@ColumnInfo(index = true)
@PrimaryKey
val id: String,
val messageId: String,
Expand Down