Skip to content

Commit

Permalink
AO3-6868 Add rake task to check for duplicate language names
Browse files Browse the repository at this point in the history
  • Loading branch information
connie-feng committed Dec 28, 2024
1 parent 4e7df30 commit e25ad32
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/tasks/language_tasks.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace :db do
desc "Check for duplicate language names before adding unique index migration"
task check_language_name_duplicates: :environment do
duplicates = Language.group(:name)
.having("COUNT(*) > 1")
.count

if duplicates.any?
puts "Duplicate language names found:"
duplicates.each do |name, count|
puts "#{name} appears #{count} times"
end

abort("Please resolve duplicate language names before running migrations.")
else
puts "No duplicate language names found."
end
end
end

0 comments on commit e25ad32

Please sign in to comment.