-
Notifications
You must be signed in to change notification settings - Fork 302
Remove duplicate Indices on PrimaryKeys. #5820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
101872a
to
ae49e38
Compare
ae49e38
to
ed22872
Compare
indices = [Index("messageId")], | ||
) | ||
internal data class AttachmentEntity( | ||
@ColumnInfo(index = true) |
There was a problem hiding this comment.
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:
- Build the app from
develop
- Login
- Re-build again from this branch
- 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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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. |
🎯 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
Code & documentation
☑️Reviewer Checklist
🎉 GIF
Please provide a suitable gif that describes your work on this pull request