2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-31 12:06:56 +08:00
|
|
|
class RenameTrustLevelBadges < ActiveRecord::Migration[4.2]
|
2014-09-05 14:38:29 +08:00
|
|
|
def rename(id, old, new)
|
|
|
|
execute "UPDATE badges SET name = '#{new}' WHERE name = '#{old}' AND id = #{id}"
|
|
|
|
rescue StandardError
|
|
|
|
puts "#{new} badge is already in use, skipping rename"
|
|
|
|
end
|
|
|
|
|
|
|
|
def up
|
|
|
|
rename 2, "Regular User", "Member"
|
|
|
|
rename 3, "Leader", "Regular"
|
|
|
|
rename 4, "Elder", "Leader"
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
rename 2, "Member", "Regular User"
|
|
|
|
rename 3, "Regular", "Leader"
|
|
|
|
rename 4, "Leader", "Elder"
|
|
|
|
end
|
|
|
|
end
|