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

has duplicate #1615

Closed
victorcode1 opened this issue Apr 2, 2024 · 7 comments
Closed

has duplicate #1615

victorcode1 opened this issue Apr 2, 2024 · 7 comments
Assignees
Labels
Needs-Attention Reporter has responded. Review comment. O-Community SDK-Use:Local T-Bug

Comments

@victorcode1
Copy link

victorcode1 commented Apr 2, 2024

....

Copy link

sync-by-unito bot commented Apr 2, 2024

➤ PM Bot commented:

Jira ticket: RDART-995

@nielsenko
Copy link
Contributor

Did you make Entity.id a primary key, when updating the schema?

@nielsenko
Copy link
Contributor

Realm is complaining that there are multiple objects with the same id after the migration, which is now illegal since it has become a primary key.

You need to remove all duplicates. The simplest thing is probably to just delete the realm entirely, if you can afford to loose the content.

@nielsenko
Copy link
Contributor

nielsenko commented Apr 2, 2024

Yes, it would affect any user who updates. You should only delete the realm, if you can afford to loose the data in it.

If you have customer data you need to preserve, then you need to either drop making id unique, or remove duplicates explicitly in your migration callback to avoid the issue.

Is it by any chance so that all id values are null? If you added the id column as part of the schema change, then it needs to be populated for all existing entries as part of the migration.

@nielsenko
Copy link
Contributor

Read up on: https://www.mongodb.com/docs/realm/sdk/flutter/realm-database/model-data/update-realm-object-schema/#other-migration-tasks.

If you sort Entity from oldRealm on _id you can find the duplicates.

@nielsenko
Copy link
Contributor

Migration is currently only for local realms. See https://www.mongodb.com/docs/realm/sdk/flutter/realm-database/model-data/update-realm-object-schema/#updating-the-schema-of-a-synced-realm

Embedded objects are used for aggregate types. One advantage is that you don't have to setup dedicated subscriptions for embedded objects. They always follow their parent.

@nirinchev
Copy link
Member

Can you post the error message with the full stack trace?

@sync-by-unito sync-by-unito bot added Waiting-For-Reporter Waiting for more information from the reporter before we can proceed More-information-needed More information is needed to progress. The issue will close automatically in 2 weeks. labels Apr 6, 2024
@github-actions github-actions bot added Needs-Attention Reporter has responded. Review comment. and removed More-information-needed More information is needed to progress. The issue will close automatically in 2 weeks. Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels Apr 6, 2024
@victorcode1 victorcode1 changed the title has duplicate values after migration has duplicate Apr 9, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs-Attention Reporter has responded. Review comment. O-Community SDK-Use:Local T-Bug
Projects
None yet
Development

No branches or pull requests

3 participants