Skip to content
Snippets Groups Projects
Commit c9bf3581 authored by Jacob Vosmaer's avatar Jacob Vosmaer
Browse files

Merge pull request #7619 from BlueBayTravel/taggable-migration

Delete invalid taggings during label migration
parents c9054319 63e25c2b
No related branches found
No related tags found
No related merge requests found
Loading
@@ -2,6 +2,12 @@ class MigrateTaggableLabels < ActiveRecord::Migration
Loading
@@ -2,6 +2,12 @@ class MigrateTaggableLabels < ActiveRecord::Migration
def up def up
taggings = ActsAsTaggableOn::Tagging.where(taggable_type: ['Issue', 'MergeRequest'], context: 'labels') taggings = ActsAsTaggableOn::Tagging.where(taggable_type: ['Issue', 'MergeRequest'], context: 'labels')
taggings.find_each(batch_size: 500) do |tagging| taggings.find_each(batch_size: 500) do |tagging|
# Clean up orphaned taggings while we are here
if tagging.taggable.blank? || tagging.tag.nil?
tagging.destroy
print 'D'
next
end
create_label_from_tagging(tagging) create_label_from_tagging(tagging)
end end
end end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment