Skip to content

refactor: improve sync merging categories#1559

Open
kaiserbh wants to merge 6 commits intojobobby04:masterfrom
syncyomi:feat/improve-sync-merging-categories
Open

refactor: improve sync merging categories#1559
kaiserbh wants to merge 6 commits intojobobby04:masterfrom
syncyomi:feat/improve-sync-merging-categories

Conversation

@kaiserbh
Copy link

@kaiserbh kaiserbh commented Feb 28, 2026

Improve the category merging logic by matching using UIDs first, with a fallback to matching by name for legacy remote categories.

Previously, categories were only matched by name, which could lead to incorrect merges if names were changed. This change ensures more accurate synchronisation by prioritising the unique identifier.

It works perfectly now, we can even change the order and it won't fail like before and if a category has been renamed it will rename it instead of creating a new category.

should close: syncyomi/syncyomi#70

For legacy and migration we should assign uid on insert, and modify existing one as well in the migration.
Add version, uid and lastModifiedAt fields to Category model to allow syncing.
Improve the category merging logic by matching using UIDs first, with a fallback to matching by name for legacy remote categories.

Previously, categories were only matched by name, which could lead to incorrect merges if names were changed. This change ensures more accurate synchronization by prioritizing the unique identifier. Conflict resolution is now based on the `version` field, and logging has been added for better visibility into the merging process.
If a category with the same UID exists, update it instead of creating a new one. Fallback to matching by name if no UID match is found.
This make sure the version is consistent, and it's not accidentally appended by the trigger, if it does then one device will always be ahead, than previous, and they need to make multiple changes to increase the version.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Duplicate categories after rename

1 participant