Skip to content

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

  1. Enable async index operations (Feature.enable(:database_async_index_operations), Feature.enable(:database_async_index_creation) and Feature.enable(:database_reindexing))
  2. Run migrations bundle exec rails db:migrate
  3. Check that async operation has been scheduled in the postgres_async_indexes table
  4. Rollback the migration and check that the async operation is no long scheduled
  5. Run the migration again and execute the async operation (bundle exec rails gitlab:db:execute_async_index_operations:all)
  6. Check that the unique index has been added to lfs_objects_projects

Related to #467119 (closed)

Edited by Jerry Seto

Merge request reports

Loading