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
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
- Open
rails console
- Note how many releases there are with
Release.count
- Create some old duplicate releases with
Release.last.dup.update_attribute(:released_at, 5.years.ago)
- Note how many new releases there are
- Run the migration
- Release count should be back to original number (or lower if you had existing duplicates)
To test the validation
- Open
rails console
- Try to save a duplicate
Release.last.dup.save!
- 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.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #31869 (closed)