2024-06-17 09:45:51 +00:00
|
|
|
# Load the Discourse environment
|
2024-08-15 16:49:02 +00:00
|
|
|
require File.expand_path("../../../../config/environment", __FILE__)
|
2024-06-17 09:45:51 +00:00
|
|
|
|
|
|
|
# Define usernames to exclude from deletion
|
2024-08-15 16:49:02 +00:00
|
|
|
excluded_usernames = ["saint", "discobot", "system","admin"]
|
2024-06-17 09:45:51 +00:00
|
|
|
|
|
|
|
# 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."
|