Skip to content
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

Add resource UUID to LocalChangeEntity, fixing changing UUID issue for the same resource #2210

Merged

Conversation

anchita-g
Copy link
Collaborator

@anchita-g anchita-g commented Sep 27, 2023

IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).

Fixes #2209

Description

  • We need to LocalChangeEntity agnostic of the resource ID as there can be cases where the resource ID of a resource might change (POST for creation). In such cases we can use resource UUID to keep the mapping between the resource and LocalChanges intact.
  • Fixing the ResourceDatabaseMigrationTest to use the migrated database for the particular implemented migration to run assertions
  • There are cases where in download of a resource which already exists in the database leads to new resource UUID being assigned to the same resource. Hence we need to keep the same resource UUID as the previous version in such cases

Alternative(s) considered
One alternative in the first scenario was to just keep the resourceUuid and remove resourceId. However, when LocalChanges are uploaded to the server, we would need to look up the ResourceEntity using the resourceUuid in the LocalChangeEntity to obtain the server recognisable identifier of the resource. This would be a problem in case of deleted resources, where in for any LocalChange of a resource that has been deleted, we would not be able to find the corresponding ResourceEntity. Hence, keeping resourceId is also crucial

Type
Choose one: Feature
Screenshots (if applicable)

Checklist

  • I have read and acknowledged the Code of conduct.
  • I have read the Contributing page.
  • I have signed the Google Individual CLA, or I am covered by my company's Corporate CLA.
  • I have discussed my proposed solution with code owners in the linked issue(s) and we have agreed upon the general approach.
  • I have run ./gradlew spotlessApply and ./gradlew spotlessCheck to check my code follows the style guide of this project.
  • I have run ./gradlew check and ./gradlew connectedCheck to test my changes locally.
  • I have built and run the demo app(s) to verify my change fixes the issue and/or does not break the demo app(s).

@anchita-g anchita-g changed the title Add resource UUID to LocalChangeEntity Add resource UUID to LocalChangeEntity, fixing changing UUID issue for the same resource Sep 29, 2023
Copy link
Collaborator

@MJ1998 MJ1998 left a comment

Choose a reason for hiding this comment

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

I don't understand why the alternative solution won't work.

In case of locally deleted resource, we can remove resourceId and still fetch the mapped ResourceEntity via LocalChangeEntity.resourceUuid.

@aditya-07
Copy link
Collaborator

aditya-07 commented Sep 29, 2023

I don't understand why the alternative solution won't work.

In case of locally deleted resource, we can remove resourceId and still fetch the mapped ResourceEntity via LocalChangeEntity.resourceUuid.

For the DELETE resource event, engine removes its entry from ResourceEntity and adds a corresponding DELETE entry into the LocalChangeEntity. Hence, to sync the change to sever, LocalChangeEntity should have the resourceID so that it can be uploaded / deleted properly on the server.

Copy link
Collaborator

@MJ1998 MJ1998 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@aditya-07 aditya-07 left a comment

Choose a reason for hiding this comment

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

LGTM!

@omarismail94 omarismail94 enabled auto-merge (squash) October 3, 2023 08:31
@omarismail94 omarismail94 merged commit dc9a921 into google:master Oct 3, 2023
3 checks passed
@anchita-g anchita-g deleted the add-resource-uuid-local-change branch October 3, 2023 09:07
@jingtang10
Copy link
Collaborator

@anchita-g have you tested the db migration on a real device? thanks!

@anchita-g
Copy link
Collaborator Author

@anchita-g have you tested the db migration on a real device? thanks!

Hello, yes I was able to test the db migration on a real device using the demo application. It works seamlessly and I was able to see the new column in the App Inspection database explorer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

Add resource UUID to LocalChangeEntity
5 participants