Add background migration to remove duplicates LFS object projects
The following discussion from !22418 (merged) should be addressed:
-
@krasio started a discussion: (+1 comment) Should this index be unique? If yes we'll need to deal with existing duplicates.
We have an existing unique validation on LfsObjectsProject
model for lfs_object_id
scoped by project_id
and repository_type
. We don't have a unique index for this though and we should add one. This way, we can utilize things like ApplicationRecord#safe_find_or_create_by
and keep data integrity in our database.
In this issue, we need to remove duplicate records first before adding the unique index.
Note: lfs_objects_projects
is a high traffic table.
Edited by Javiera Tapia