This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module DiscourseUsersMerger | |
class Merger | |
def merge(target_username, source_username) | |
raise "User to merge and target user can't be the same" if target_username == source_username | |
target_user = User.find_by_username!(target_username) | |
source_user = User.find_by_username!(source_username) | |
puts "About to merge #{source_username} (#{source_user.email}) into #{target_username} (#{target_user.email})" | |
puts "#{source_user.topics.count} topics with #{source_user.posts.count} posts will be moved. Ok to continue? (y/n)" | |
continue = STDIN.gets.chomp.downcase == 'y' |