Commit c9bf3581 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Merge pull request #7619 from BlueBayTravel/taggable-migration

Delete invalid taggings during label migration
parents c9054319 63e25c2b
...@@ -2,6 +2,12 @@ class MigrateTaggableLabels < ActiveRecord::Migration ...@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment