mailr/lib/tasks/clear_db.rake
Wojciech Todryk 77c8d3e7d7 devel
2012-03-30 19:31:23 +02:00

24 lines
632 B
Ruby
Executable file

namespace :mailr do
desc "Removes all users data from db"
task :remove_all_data => :environment do
users = User.all
puts "Number of users in db: #{users.size}"
puts "Deleting data....."
User.destroy_all
puts "Done"
end
desc "Deletes users data (messages,folders,contacts)"
task :remove_users_data => :environment do
users = User.all
users.each do |u|
puts "Removing folders & messages for user #{u.email}"
u.folders.destroy_all
puts "Removing contacts for user #{u.email}"
u.contacts.destroy_all
end
end
end