Fix extra unreferenced tags been created #1807
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1707
Fixes an issue where duplicate Tags are been created during scene scrapping but are not referenced by any scenes.
Includes a migration to remove unreferenced tags, i.e. where the count column in the tag = 0. If Tag records with the count of 0 exists and should be deleted but is referenced in the scene_tags table, it will not delete the unreferenced tags. This should not happen but is just a precaution, so a data referential integrity issue is not created.
I have updated the migration logic to allow a migration to be flagged to retry. This is useful where the migration is not required for the new version of Xbvr to run, e.g. the unreferenced tags are not causing an issue other than creating unused entries in the tags table. Another, example where this could be useful would be adding an index, adding the index would make the system faster but if the migration failed create the index, the new version would still run. Retriable migrations would not be the norm. To flag a migration to retry, you can add the Migration Id to the
retryMigration
array and return nil from the migration function. The Id will be removed from the migrations table so it tries again the next time xbvr runs.