diff --git a/app/models/artist.rb b/app/models/artist.rb index 4557b581f..8ad7e9be3 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -1,6 +1,6 @@ class Artist < ActiveRecord::Base before_create :initialize_creator - before_save :normalize_name + before_validation :normalize_name after_save :create_version after_save :save_url_string after_save :categorize_tag diff --git a/script/fixes/026_fix_unicode_capitals.rb b/script/fixes/026_fix_unicode_capitals.rb new file mode 100644 index 000000000..8eb4b5d00 --- /dev/null +++ b/script/fixes/026_fix_unicode_capitals.rb @@ -0,0 +1,28 @@ +#!/usr/bin/env ruby + +require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment')) + +ActiveRecord::Base.connection.execute("set statement_timeout = 0") + +CurrentUser.user = User.admins.first +CurrentUser.ip_addr = "127.0.0.1" + +Tag.find_each do |tag| + next if tag.name.ascii_only? + mb_name = tag.name.mb_chars + if mb_name.downcase != mb_name + if Tag.where("name = ?", mb_name.downcase).exists? + tag.destroy + else + tag.update_column(:name, mb_name.downcase.to_s) + end + end +end + +Artist.find_each do |artist| + next if artist.name.ascii_only? + mb_name = artist.name.mb_chars + if mb_name.downcase != mb_name + artist.save # name will be normalized automatically + end +end