Skip to content

Resolve "Duplicate rows with the same tag name in Release"

What does this MR do and why?

This MR adds a migration and constraints to prevent releases with duplicate tags for the same project

Screenshots or screen recordings

Analysis run of delete query

Output and performance of migrations

User Impact

Since creation of these duplicate releases are blocked at the service level there aren't many of these releases. Only the most recent of the duplicate releases would be available after this migration.

Also according to @shinya.maeda in these comments However, since invalid rows are very rare (we do NOT allow users to create such records in the service class) and they can't be operated correctly (e.g. it's fetched randomly), it's highly unlikely that users face issues.

Currently deletes 6695 rows

How to set up and validate locally

To test the migration

  1. Open rails console
  2. Note how many releases there are with Release.count
  3. Create some old duplicate releases with Release.last.dup.update_attribute(:released_at, 5.years.ago)
  4. Note how many new releases there are
  5. Run the migration
  6. Release count should be back to original number (or lower if you had existing duplicates)

To test the validation

  1. Open rails console
  2. Try to save a duplicate Release.last.dup.save!
  3. See that it fails

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #31869 (closed)

Edited by Allen Cook

Merge request reports

Loading