21 lines
578 B
Ruby
21 lines
578 B
Ruby
|
# Load the Discourse environment
|
||
|
require File.expand_path("../../../config/environment", __FILE__)
|
||
|
|
||
|
# Define usernames to exclude from deletion
|
||
|
excluded_usernames = ["saint", "discobot", "system"]
|
||
|
|
||
|
# Find all users except the excluded ones
|
||
|
users_to_delete = User.where.not(username: excluded_usernames)
|
||
|
|
||
|
# Iterate over the users and delete each one
|
||
|
users_to_delete.each do |user|
|
||
|
begin
|
||
|
# puts "Deleting user: #{user.username}"
|
||
|
user.destroy
|
||
|
rescue => e
|
||
|
puts "Failed to delete user #{user.username}: #{e.message}"
|
||
|
end
|
||
|
end
|
||
|
|
||
|
puts "User deletion process completed."
|