Skip to content

Conversation

Sagar0-0
Copy link
Contributor

@Sagar0-0 Sagar0-0 commented Jun 9, 2025

🎯 Goal

Remove unnecessary @ColumnInfo(index = true) from a @PrimaryKey column, as Room and SQLite automatically index primary keys.

🛠 Implementation details

Removed @ColumnInfo(index = true) annotation from the primary key column in these two entity..
This cleanup helps avoid redundant annotations and keeps the entity definition minimal and accurate.

🧪 Testing

No runtime or behavioral impact expected, as primary keys are indexed by default.
Verified that Room compiles the schema correctly and no migrations are required for this change.

☑️Contributor Checklist

General

  • I have signed the Stream CLA (required)
  • Assigned a person / code owner group (required)
  • Thread with the PR link started in a respective Slack channel (#android-chat-core or #android-chat-ui) (required)
  • PR is linked to the GitHub issue it resolves

Code & documentation

  • Changelog is updated with client-facing changes
  • New code is covered by unit tests
  • Comparison screenshots added for visual changes
  • Affected documentation updated (KDocs, docusaurus, tutorial)

☑️Reviewer Checklist

  • UI Components sample runs & works
  • Compose sample runs & works
  • UI Changes correct (before & after images)
  • Bugs validated (bugfixes)
  • New feature tested and works
  • Release notes and docs clearly describe changes
  • All code we touched has new or updated KDocs

🎉 GIF

Please provide a suitable gif that describes your work on this pull request

@Sagar0-0 Sagar0-0 requested a review from a team as a code owner June 9, 2025 14:09
@Sagar0-0 Sagar0-0 force-pushed the sagar/duplicate-index branch from 101872a to ae49e38 Compare June 9, 2025 14:11
@Sagar0-0 Sagar0-0 force-pushed the sagar/duplicate-index branch from ae49e38 to ed22872 Compare June 9, 2025 14:13
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

@andremion andremion added the waiting for response Further information is requested label Sep 9, 2025
Copy link
Contributor

github-actions bot commented Oct 6, 2025

This pull request has been automatically marked as stale because it has been inactive for 14 days. It will be closed in 7 days if no further activity occurs.

@github-actions github-actions bot added the Stale label Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stale waiting for response Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants