We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 38d86fb commit efc809cCopy full SHA for efc809c
1 file changed
script/maintenance/fix_cross_account_taggings.rb
@@ -0,0 +1,15 @@
1
+#!/usr/bin/env ruby
2
+
3
+require_relative "../config/environment"
4
5
+cross_account_taggings = Tagging.joins(:tag).where("taggings.account_id != tags.account_id")
6
7
+puts "Found #{cross_account_taggings.count} cross-account taggings to fix"
8
9
+cross_account_taggings.find_each do |tagging|
10
+ correct_tag = tagging.account.tags.find_or_create_by!(title: tagging.tag.title)
11
+ tagging.update!(tag: correct_tag)
12
+ puts "Fixed tagging #{tagging.id}: reassigned to tag #{correct_tag.id} (#{correct_tag.title})"
13
+end
14
15
+puts "Done!"
0 commit comments