Skip to content

Re-add unique index_tags_on_name index

Pedro Pombeiro requested to merge pedropombeiro/433256/readd-index into master

What does this MR do and why?

This MR re-adds the unique index_tags_on_name index, as apparently some installations don't have this index (see omnibus-gitlab#8579 (comment 1947034496) and #433256 (comment 1921833690)). It follows the same approach as !152360 (merged) to fix this particular deviation from the intended schema.

Normally, this will be a no-op. In the event that the unique index does not exist, it gets created. If duplicate values exist, we point the user to a thread that will help it remove the duplicates, so that the index can be created.

Closes #433256

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.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

image

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. In the ci database, drop the index_tags_on_name index:

    DROP INDEX index_tags_on_name;
  2. Create a duplicate value in the tags table, e.g.:

    INSERT INTO tags (name) VALUES ('runner-fleet')
  3. Run the migration.

  4. Notice the error message.

  5. Delete the duplicate row from the tags table

  6. Drop the invalid index_tags_on_name index:

    DROP INDEX index_tags_on_name;
  7. Run the migration again, this time it should finish successfully.

Edited by Pedro Pombeiro

Merge request reports