Schedule the creation of a unique index on lfs_objects_projects
What does this MR do and why?
We have a validation in the model but we don't have an index to enforce it.
This change schedules the creation of a unique index on lfs_objects_projects over `(project_id, lfs_object_id, repository_type)
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
Try something similar to the steps described in: https://docs.gitlab.com/ee/development/database/adding_database_indexes.html#verify-indexes-created-asynchronously
For example
- Enable async index operations (
Feature.enable(:database_async_index_operations),Feature.enable(:database_async_index_creation)andFeature.enable(:database_reindexing)) - Run migrations
bundle exec rails db:migrate - Check that async operation has been scheduled in the
postgres_async_indexestable - Rollback the migration and check that the async operation is no long scheduled
- Run the migration again and execute the async operation (
bundle exec rails gitlab:db:execute_async_index_operations:all) - Check that the unique index has been added to
lfs_objects_projects
Related to #467119 (closed)